零件输入的界面和程序

戻る

mscparts_start.pl

sub mscparts_start { my $self = shift; my(%t,@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{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{unit} = $self->dbh->selectrow_array("SELECT parts_Unit FROM parts_nu WHERE id = $rec[6]"); } else { $t{unit} = 'PCS'; } my %row = ( unit1 => $t{unit}, table => $t{ptable}, aid => $t{id}, id => $rec[0], name => $rec[1], code => $rec[2], group_id => $rec[3], dwg_id => $rec[4] ); push(@loop, \%row); } $t{sth}->finish; $template->param(id => $t{id}); $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="msc261"> <input type="hidden" name="table" value="main_type1"> <input type="hidden" name="items" value="id,name,series,gname_id,maker_id,GR,DWG,memo"> <input type="hidden" name="rm" value="modeshowall"> </form> <hr color="#003366"> id=><TMPL_VAR NAME="id"><br> ptable=><TMPL_VAR NAME="ptable"><br> 显示ptable的内容<br><br> <table> <tr bgcolor=white> <th>ID</th> <th>name</th> <th>code</th> <th>group_id</th> <th>dwg_id</th> <th>price</th> <th>Unit</th> <th>memo</th> <th>Parts修正</th> </tr> <TMPL_LOOP NAME="LOOP"> <tr bgcolor=cyan> <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="rm" value="modeparts_modify"> </form> </td> <tr> </TMPL_LOOP> </table> <hr> 追加ptable<br><br> <form action="" method="post"> <textarea name="group" cols="60" rows="10" wrap="hard"> </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="table" value="<TMPL_VAR NAME="ptable">"> <input type="hidden" name="rm" value="modeparts_add"> </form> </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{code} = $t{q}->param("code"); $t{unit1} = $t{q}->param("unit1"); # 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}); 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="id">"> <input type="hidden" name="rm" value="modeparts_start"> </form> <hr color="#003366"> <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="rm" value="modeparts_modify1"> </form> </BODY> </HTML>

mscparts_modify1.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"); # 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}); return $t{template}->output; } 1;

mscparts_add.pl

sub mscparts_add { my $self = shift; my(%t,@loop,$n); # Get CGI query object $t{q} = $self->query(); $t{id} = $t{q}->param("id"); $t{group} = $t{q}->param("group"); $t{html} = $t{q}->param("tmpl"); $t{table} = $t{q}->param("table"); $t{html} = $t{html} . '.htm'; $t{template} = $self->load_tmpl("$t{html}") || die "error loading tmpl"; @{ $t{line} } = split(/\n/,$t{group}); $t{name} = ''; for $n ( 0 .. $#{ $t{line} } ) { ($t{name1},$t{code1}) = split(/==/,$t{line}[$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{template}->param(id => $t{id}); $t{template}->param(table => $t{table}); $t{template}->param(DO => $t{DO}); $t{template}->param(sql => $t{sql}); return $t{template}->output; } 1;
戻る