零件输入程序和界面

戻る

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/==/\<br\>/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

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>Parts管理</TITLE> <style type="text/css"> body { background: lightcyan; color:black; margin-left:2em;margin-right:2em;} </style> </HEAD> <BODY> <center> <h2>Parts管理</h2></center> mode:modeparts_start <form action="" method="post"> <input type="submit" value="主機データ追加へ戻る"><p> <input type="hidden" name="tmpl" value="mscengine_data"> <input type="hidden" name="id" value="<TMPL_VAR NAME="id">"> <input type="hidden" name="name" value="<TMPL_VAR NAME="name">"> <input type="hidden" name="series" value="<TMPL_VAR NAME="series">"> <input type="hidden" name="rm" value="modeengine_data"> </form> <hr color="#003366"> id=><TMPL_VAR NAME="id">,主機タイプ=><TMPL_VAR NAME="name">,series=><TMPL_VAR NAME="series"><br> Parts name<br> <form action="" method="post"> <textarea name="partsname" cols="100" rows="10"><TMPL_VAR NAME="partsname"></textarea><br><br> Parts code<br> <textarea name="partscode" cols="100" rows="10"><TMPL_VAR NAME="partscode"></textarea><br> <input type="submit" value="PARTS追加"><p> <input type="hidden" name="tmpl" value="mscparts_add"> <input type="hidden" name="id" value="<TMPL_VAR NAME="id">"> <input type="hidden" name="name" value="<TMPL_VAR NAME="name">"> <input type="hidden" name="series" value="<TMPL_VAR NAME="series">"> <input type="hidden" name="table" value="<TMPL_VAR NAME="ptable">"> <input type="hidden" name="rm" value="modeparts_add"> </form> <hr> 显示ptable的内容<br><br> <table width=75% align="center" border=1 cellpadding=3> <tr bgcolor=white> <th width=5%>NO</th> <th width=5%>ID</th> <th width=20%>name</th> <th width=20%>code</th> <th width=5%>group_id</th> <th width=5%>dwg_id</th> <th width=10%>price</th> <th width=5%>Unit</th> <th width=20%>memo</th> <th width=5%>Parts修正</th> </tr> <TMPL_LOOP NAME="LOOP"> <tr bgcolor=cyan> <td><TMPL_VAR NAME="NO"></td> <td><TMPL_VAR NAME="id"></td> <td><TMPL_VAR NAME="name"></td> <td><TMPL_VAR NAME="code"></td> <td><TMPL_VAR NAME="group_id"> </td> <td><TMPL_VAR NAME="dwg_id"></td> <td></td> <td><TMPL_VAR NAME="unit1"></td> <td></td> <td> <form action="" method="post"> <input type="submit" value="Parts修正"><p> <input type="hidden" name="tmpl" value="mscparts_modify"> <input type="hidden" name="id" value="<TMPL_VAR NAME="aid">"> <input type="hidden" name="pid" value="<TMPL_VAR NAME="id">"> <input type="hidden" name="unit1" value="<TMPL_VAR NAME="unit1">"> <input type="hidden" name="name" value="<TMPL_VAR NAME="name">"> <input type="hidden" name="code" value="<TMPL_VAR NAME="code">"> <input type="hidden" name="table" value="<TMPL_VAR NAME="table">"> <input type="hidden" name="eid" value="<TMPL_VAR NAME="eid">"> <input type="hidden" name="ename" value="<TMPL_VAR NAME="ename">"> <input type="hidden" name="series" value="<TMPL_VAR NAME="series">"> <input type="hidden" name="rm" value="modeparts_modify"> </form> </td> <tr> </TMPL_LOOP> </table> <hr> </BODY> </HTML>

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

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>Parts項目追加</TITLE> <style type="text/css"> body { background: lightcyan; color:black; margin-left:2em;margin-right:2em;} </style> </HEAD> <BODY> <center> <h2>Parts項目追加</h2></center> mode:modeparts_add <form action="" method="post"> <input type="submit" value="Parts管理へ戻る"><p> <input type="hidden" name="tmpl" value="mscparts_start"> <input type="hidden" name="id" value="<TMPL_VAR NAME="id">"> <input type="hidden" name="name" value="<TMPL_VAR NAME="name">"> <input type="hidden" name="series" value="<TMPL_VAR NAME="series">"> <input type="hidden" name="partsname" value="END"> <input type="hidden" name="partscode" value="END"> <input type="hidden" name="rm" value="modeparts_start"> </form> <hr color="#003366"> id==><TMPL_VAR NAME="id"><br> 主機タイプ==><TMPL_VAR NAME="name"><br> series==><TMPL_VAR NAME="series"><br> table==><TMPL_VAR NAME="table"><br> pattern==><TMPL_VAR NAME="pattern"><br> </BODY> </HTML>

mscparts_add2.htm

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>Parts输入失败,格式有错,请返回后修改</TITLE> <style type="text/css"> body { background: lightcyan; color:black; margin-left:2em;margin-right:2em;} </style> </HEAD> <BODY> <center> <h2>Parts输入失败,格式有错,请返回后修改</h2></center> mode:modeparts_add2 <form action="" method="post"> <input type="submit" value="Parts管理へ戻る"><p> <input type="hidden" name="tmpl" value="mscparts_start"> <input type="hidden" name="id" value="<TMPL_VAR NAME="id">"> <input type="hidden" name="name" value="<TMPL_VAR NAME="name">"> <input type="hidden" name="series" value="<TMPL_VAR NAME="series">"> <input type="hidden" name="partsname" value="<TMPL_VAR NAME="partsname">"> <input type="hidden" name="partscode" value="<TMPL_VAR NAME="partscode">"> <input type="hidden" name="rm" value="modeparts_start"> </form> <hr color="#003366"> id==><TMPL_VAR NAME="id"><br> 主機タイプ==><TMPL_VAR NAME="name"><br> series==><TMPL_VAR NAME="series"><br> table==><TMPL_VAR NAME="table"><br> pattern==><TMPL_VAR NAME="pattern"><br> 重複パーツコート==><TMPL_VAR NAME="olds"><br> </BODY> </HTML>

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/\<br\>/==/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

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>Parts項目修正</TITLE> <style type="text/css"> body { background: lightcyan; color:black; margin-left:2em;margin-right:2em;} </style> </HEAD> <BODY> <center> <h2>Parts項目修正</h2></center> mode:modeparts_modify <form action="" method="post"> <input type="submit" value="Parts管理へ戻る"><p> <input type="hidden" name="tmpl" value="mscparts_start"> <input type="hidden" name="id" value="<TMPL_VAR NAME="eid">"> <input type="hidden" name="name" value="<TMPL_VAR NAME="ename">"> <input type="hidden" name="series" value="<TMPL_VAR NAME="series">"> <input type="hidden" name="partsname" value="END"> <input type="hidden" name="partscode" value="END"> <input type="hidden" name="rm" value="modeparts_start"> </form> <hr color="#003366"> id=><TMPL_VAR NAME="eid">,主機タイプ=><TMPL_VAR NAME="ename">,series=><TMPL_VAR NAME="series"><br> <form action="" method="post"> <table> <tr> <td>ID</td> <td><TMPL_VAR NAME="pid"></td> </tr> <tr> <td>name</td> <td><input type=text size=100 name=name value="<TMPL_VAR NAME="name">"></td></tr> <input type="hidden" name="name" value=""> <td>code</td> <td><input type=text size=100 name=code value="<TMPL_VAR NAME="code">"></td></tr> <input type="hidden" name="code" value=""> </table> UNIT <SELECT NAME="unit1"> <TMPL_LOOP NAME="LOOP"> <OPTION <TMPL_VAR NAME="id">><TMPL_VAR NAME="unit1"></OPTION> </TMPL_LOOP> </SELECT><br> <input type="submit" value="决定"><br> 按下决定后,完成修改。 <input type="hidden" name="tmpl" value="mscparts_modify1"> <input type="hidden" name="pid" value="<TMPL_VAR NAME="pid">"> <input type="hidden" name="id" value="<TMPL_VAR NAME="id">"> <input type="hidden" name="table" value="<TMPL_VAR NAME="table">"> <input type="hidden" name="eid" value="<TMPL_VAR NAME="eid">"> <input type="hidden" name="ename" value="<TMPL_VAR NAME="ename">"> <input type="hidden" name="series" value="<TMPL_VAR NAME="series">"> <input type="hidden" name="rm" value="modeparts_modify1"> </form> </BODY> </HTML>

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

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>Parts項目修正完了</TITLE> <style type="text/css"> body { background: lightcyan; color:black; margin-left:2em;margin-right:2em;} </style> </HEAD> <BODY> <center> <h2>Parts項目修正完了</h2></center> mode:modeparts_modify1 <form action="" method="post"> <input type="submit" value="Parts管理へ戻る"><p> <input type="hidden" name="tmpl" value="mscparts_start"> <input type="hidden" name="id" value="<TMPL_VAR NAME="eid">"> <input type="hidden" name="name" value="<TMPL_VAR NAME="ename">"> <input type="hidden" name="series" value="<TMPL_VAR NAME="series">"> <input type="hidden" name="partsname" value="END"> <input type="hidden" name="partscode" value="END"> <input type="hidden" name="rm" value="modeparts_start"> </form> <hr color="#003366"> id=><TMPL_VAR NAME="eid">,主機タイプ=><TMPL_VAR NAME="ename">,series=><TMPL_VAR NAME="series"><br> sql==><TMPL_VAR NAME="sql"><br> DO==><TMPL_VAR NAME="DO"><br> </BODY> </HTML>
戻る