零件输入程序和界面
戻る
mscparts_start.pl
sub mscparts_start { my $self = shift; my(%t,$n,@rec,$template); # Get CGI query object $q = $self->query(); $t{html} = $q->param("tmpl"); $t{html} = $t{html} . '.htm'; $template = $self->load_tmpl("$t{html}") || die "error loading tmpl"; $t{id} = $q->param("id"); $t{name} = $q->param("name"); $t{series} = $q->param("series"); $t{partsname} = $q->param("partsname"); $t{partscode} = $q->param("partscode"); $t{ptable} = sprintf("%06d",$t{id}); $t{ptable} = 'a' . $t{ptable}; $t{sth} = $self->dbh->prepare("SELECT * FROM $t{ptable}"); $t{sth}->execute; while ( @rec = $t{sth}->fetchrow_array ) { if ( $rec[6] ) { $t{unit1} = $self->dbh->selectrow_array("SELECT parts_Unit FROM parts_nu WHERE id = $rec[6]"); } else { $t{unit1} = 'PCS'; } if ( $t{codes}{$rec[2]} ) { $rec[2] .= '_a'; } $t{codes}{$rec[2]} = $rec[2]; $t{units}{$rec[2]} = $t{unit1}; $t{ids}{$rec[2]} = $rec[0]; $t{names}{$rec[2]} = $rec[1]; $t{group_ids}{$rec[2]} = $rec[3]; $t{dwg_ids}{$rec[2]} = $rec[4]; } $t{sth}->finish; $t{NO} = 0; # for $n ( sort { $a<=>$b } keys %{ $t{units} } ) { for $n ( sort keys %{ $t{units} } ) { $t{unit1} = $t{units}{$n}; $t{id1} = $t{ids}{$n}; $t{name1} = $t{names}{$n}; $t{name1} =~ s/==/\
/g; $t{group_id1} = $t{group_ids}{$n}; $t{dwg_id1} = $t{dwg_ids}{$n}; $t{NO}++; my %row = ( eid => $t{id}, ename => $t{name}, series => $t{series}, NO => $t{NO}, unit1 => $t{unit1}, table => $t{ptable}, aid => $t{id}, id => $t{id1}, name => $t{name1}, code => $n, group_id => $t{group_id1}, dwg_id => $t{dwg_id1} ); push(@loop, \%row); } $template->param(id => $t{id}); $template->param(name => $t{name}); $template->param(partsname => $t{partsname}); $template->param(partscode => $t{partscode}); $template->param(series => $t{series}); $template->param(ptable => $t{ptable}); $template->param(LOOP => \@loop); return $template->output; } 1;
mscparts_start.htm
Parts管理
Parts管理
mode:modeparts_start
">
">
">
id=>
,主機タイプ=>
,series=>
Parts name
Parts code
">
">
">
">
显示ptable的内容
NO
ID
name
code
group_id
dwg_id
price
Unit
memo
Parts修正
">
">
">
">
">
">
">
">
">
mscparts_add.pl
sub mscparts_add { my $self = shift; my(%t,$n,$n1,@rec); # Get CGI query object $t{q} = $self->query(); $t{id} = $t{q}->param("id"); $t{name} = $t{q}->param("name"); $t{series} = $t{q}->param("series"); $t{partsname} = $t{q}->param("partsname"); $t{partscode} = $t{q}->param("partscode"); $t{html} = $t{q}->param("tmpl"); $t{table} = $t{q}->param("table"); # 現在テーブル中のcodeを取得 $t{sth} = $self->dbh->prepare("SELECT code FROM $t{table}"); $t{sth}->execute; $t{oldcodes} = ''; while ( @rec = $t{sth}->fetchrow_array ) { if ( $rec[0] ne 'NULL' ) { $t{one1} = lc($rec[0]); $t{oldcodes} .= '_' . $t{one1}; $t{codeflag} = 1; } else { $t{codeflag} = 0; } } $t{sth}->finish; # 入力した名前とコートデータを取得 @{ $t{names} } = split(/\n/,$t{partsname}); @{ $t{codes} } = split(/\n/,$t{partscode}); $t{end1} = $#{ $t{names} } - 1; $t{end2} = $#{ $t{codes} } - 1; $t{flag} = 0; $t{olds} = "Old codes==>"; if ( $t{codeflag} == 1 ) { for $n ( 0 .. $t{end2} ) { $t{code1} = lc($t{codes}[$n]); if ( $t{oldcodes} =~ /$t{code1}/ ) { $t{olds} .= '_' . $t{codes}[$n]; $t{flag} = 1; } } } if ( $t{codes}[0] =~ /END/ or $t{end1} != $t{end2} or $t{flag}) { $t{pattern} = 2; } else { $t{pattern} = 1; } if ( $t{pattern} == 1 ) { for $n ( 0 .. $t{end1} ) { $t{name1} = $t{names}[$n]; $t{code1} = $t{codes}[$n]; $t{sql} = "INSERT INTO $t{table} (name,code,Nuid) "; $t{sql} .= 'VALUES("' . $t{name1} . '","'; $t{sql} .= $t{code1} . '","1")'; $t{DO} = $self->dbh->do("$t{sql}"); } $t{html} = $t{html} . '.htm'; $t{template} = $self->load_tmpl("$t{html}") || die "error loading tmpl"; } else { $t{html} = 'mscparts_add2.htm'; $t{template} = $self->load_tmpl("$t{html}") || die "error loading tmpl"; $t{template}->param(partsname => $t{partsname}); $t{template}->param(partscode => $t{partscode}); $t{template}->param(olds => $t{olds}); } $t{template}->param(id => $t{id}); $t{template}->param(name => $t{name}); $t{template}->param(series => $t{series}); $t{template}->param(table => $t{table}); $t{template}->param(pattern => $t{pattern}); return $t{template}->output; } 1;
mscparts_add.htm
Parts項目追加
Parts項目追加
mode:modeparts_add
">
">
">
id==>
主機タイプ==>
series==>
table==>
pattern==>
mscparts_add2.htm
Parts输入失败,格式有错,请返回后修改
Parts输入失败,格式有错,请返回后修改
mode:modeparts_add2
">
">
">
">
">
id==>
主機タイプ==>
series==>
table==>
pattern==>
重複パーツコート==>
mscparts_modify.pl
sub mscparts_modify { my $self = shift; my(%t,@loop,$n); # Get CGI query object $t{q} = $self->query(); $t{html} = $t{q}->param("tmpl"); $t{html} = $t{html} . '.htm'; $t{template} = $self->load_tmpl("$t{html}") || die "error loading tmpl"; $t{id} = $t{q}->param("id"); $t{pid} = $t{q}->param("pid"); $t{table} = $t{q}->param("table"); $t{name} = $t{q}->param("name"); $t{name} =~ s/\
/==/g; $t{code} = $t{q}->param("code"); $t{unit1} = $t{q}->param("unit1"); $t{eid} = $t{q}->param("eid"); $t{ename} = $t{q}->param("ename"); $t{series} = $t{q}->param("series"); # Parts Unit $t{sth} = $self->dbh->prepare("SELECT id, parts_Unit FROM parts_nu"); $t{sth}->execute; while ( @rec = $t{sth}->fetchrow_array ) { if ( $t{unit1} eq $rec[1] ) { $t{id1} = "SELECTED VALUE=$rec[0]"; } else { $t{id1} = "VALUE=$rec[0]"; } my %row = ( id => $t{id1}, unit1 => $rec[1] ); push(@loop, \%row); } $t{sth}->finish; $t{template}->param(LOOP => \@loop); $t{template}->param(id => $t{id}); $t{template}->param(pid => $t{pid}); $t{template}->param(table => $t{table}); $t{template}->param(name => $t{name}); $t{template}->param(code => $t{code}); $t{template}->param(eid => $t{eid}); $t{template}->param(ename => $t{ename}); $t{template}->param(series => $t{series}); return $t{template}->output; } 1;
mscparts_modify.htm
Parts項目修正
Parts項目修正
mode:modeparts_modify
">
">
">
id=>
,主機タイプ=>
,series=>
ID
name
">
code
">
UNIT
>
按下决定后,完成修改。
">
">
">
">
">
">
mscparts_modify.pl
sub mscparts_modify1 { my $self = shift; my(%t,@loop,$n); # Get CGI query object $t{q} = $self->query(); $t{html} = $t{q}->param("tmpl"); $t{html} = $t{html} . '.htm'; $t{template} = $self->load_tmpl("$t{html}") || die "error loading tmpl"; $t{id} = $t{q}->param("id"); $t{pid} = $t{q}->param("pid"); $t{table} = $t{q}->param("table"); $t{name} = $t{q}->param("name"); $t{code} = $t{q}->param("code"); $t{unit1} = $t{q}->param("unit1"); $t{eid} = $t{q}->param("eid"); $t{ename} = $t{q}->param("ename"); $t{series} = $t{q}->param("series"); # name $t{sql} = 'UPDATE ' . $t{table} . ' set name = "'; $t{sql} .= $t{name} . '" where id = ' . $t{pid}; $t{DO} = $self->dbh->do($t{sql}); # code $t{sql} = 'UPDATE ' . $t{table} . ' set code = "'; $t{sql} .= $t{code} . '" where id = ' . $t{pid}; $t{DO} = $self->dbh->do($t{sql}); # unit $t{sql} = 'UPDATE ' . $t{table} . ' set NUid = "'; $t{sql} .= $t{unit1} . '" where id = ' . $t{pid}; $t{DO} = $self->dbh->do($t{sql}); # $t{template}->param(id => $t{id}); $t{template}->param(sql => $t{sql}); $t{template}->param(DO => $t{DO}); $t{template}->param(eid => $t{eid}); $t{template}->param(ename => $t{ename}); $t{template}->param(series => $t{series}); return $t{template}->output; } 1;
mscparts_modify1.htm
Parts項目修正完了
Parts項目修正完了
mode:modeparts_modify1
">
">
">
id=>
,主機タイプ=>
,series=>
sql==>
DO==>
戻る