零件选择排序程序与界面

戻る

显示DB的全部零件,选择零件准备(mscshowparts10.pl)

sub mscshowparts10 { my $self = shift; my(%t,$n,@rec,@loop); # Get CGI query object $t{q} = $self->query(); # 取出数据 $t{tname} = $t{q}->param("tname"); $t{id} = $t{q}->param("id"); $t{enq1_id} = $t{q}->param("enq1_id"); $t{NE1} = $t{q}->param("NE1"); # enq1的主机排列序号 # 零件表名 $t{ptable} = sprintf("%06d",$t{id}); $t{ptable} = 'a' . $t{ptable}; @loop = (); $t{sth} = $self->dbh->prepare("SELECT * FROM $t{ptable}"); $t{sth}->execute; while ( @rec = $t{sth}->fetchrow_array ) { my $row_ref = (); # 这个清零很重要! $t{NO} = 'select_' . $rec[0]; # 给选择的变数取名 $$row_ref{NO} = $t{NO}; $$row_ref{name} = $rec[1]; $$row_ref{code} = $rec[2]; $$row_ref{group_id} = $rec[3]; $$row_ref{dwg_id} = $rec[4]; $$row_ref{Nuid} = $rec[5]; $$row_ref{weight} = $rec[6]; $$row_ref{price1} = $rec[7]; $$row_ref{memo} = $rec[15]; # 排位注意! push(@loop, $row_ref); } $t{sth}->finish; # 输出到HTML文件 $t{html} = $t{q}->param("tmpl"); $t{html} = $t{html} . '.htm'; $t{template} = $self->load_tmpl("$t{html}") || die "error loading tmpl"; $t{template}->param(enq1_id => $t{enq1_id}); $t{template}->param(tid => $t{id}); $t{template}->param(ptable => $t{ptable}); $t{template}->param(tname => $t{tname}); $t{template}->param(NE1 => $t{NE1}); $t{template}->param(THIS_LOOP => \@loop); return $t{template}->output; } 1;

mscparts10.htm

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>零件选择</TITLE> </HEAD> <BODY bgcolor="#FFFFFF"> <center> <h2>零件选择</h2></center> mode:mscparts10 <form action="" method="post"> <input type="submit" value="パーツ入力へ戻る"><p> <input type="hidden" name="id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="rm" value="modeenq1_parts"> </form> enq1_id=><TMPL_VAR NAME="enq1_id"> Equipment Type=><TMPL_VAR NAME="tname">,表格名=><TMPL_VAR NAME="ptable">,NE1=><TMPL_VAR NAME="NE1"> <hr color="#003366"> <form action="" method="post"> <input type="submit" value="选一个以上后点击去零件排序"> <table border=1 cellpadding=5> <tr bgcolor="#3399FF" align="center"> <th>选择</th> <th>Name</th> <th>Code</th> <th>group_id</th> <th>dwg_id</th> <th>Nuid</th> <th>weight</th> <th>price</th> <th>memo</th> </tr> <TMPL_LOOP NAME="this_loop"> <tr bgcolor="lightcyan" align="left"> <td><TMPL_VAR NAME="NO">,<INPUT TYPE="checkbox" NAME="<TMPL_VAR NAME="NO">"></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><TMPL_VAR NAME="Nuid"></td> <td><TMPL_VAR NAME="weight"></td> <td><TMPL_VAR NAME="price1"></td> <td><TMPL_VAR NAME="memo"></td> </tr> </TMPL_LOOP> </table> <input type="hidden" name="tmpl" value="mscparts20"> <input type="hidden" name="tname" value="<TMPL_VAR NAME="tname">"> <input type="hidden" name="tid" value="<TMPL_VAR NAME="tid">"> <input type="hidden" name="enq1_id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="NE1" value="<TMPL_VAR NAME="NE1">"> <input type="hidden" name="rm" value="modeshowparts20"> </form> <hr color="#003366"> </BODY> </HTML>

零件选择完成,零件排序准备(mscshowparts20.pl)

sub mscshowparts20 { my $self = shift; my(%t,$n,@rec,@loop); # Get CGI query object $t{q} = $self->query(); # 取出数据 $t{tname} = $t{q}->param("tname"); $t{tid} = $t{q}->param("tid"); $t{enq1_id} = $t{q}->param("enq1_id"); $t{NE1} = $t{q}->param("NE1"); # HTMLファイルに出力 $t{html} = $t{q}->param("tmpl"); $t{html} = $t{html} . '.htm'; # 零件表名 $t{ptable} = sprintf("%06d",$t{tid}); $t{ptable} = 'a' . $t{ptable}; # 把所有数据从TABLE中取出 $t{sth} = $self->dbh->prepare("SELECT * FROM $t{ptable}"); $t{sth}->execute; while ( @rec = $t{sth}->fetchrow_array ) { $t{NO} = 'select_' . $rec[0]; $t{s1} = $t{q}->param($t{NO}); # 只有被选择的项目才有值=1 if ( $t{s1} ) { $t{list_NO}{$rec[2]} = $t{NO}; $t{list_id}{$rec[2]} = $rec[0]; $t{list_name}{$rec[2]} = $rec[1]; $t{list_code}{$rec[2]} = $rec[2]; $t{list_group_id}{$rec[2]} = $rec[3]; $t{list_dwg_id}{$rec[2]} = $rec[4]; $t{list_Nuid}{$rec[2]} = $rec[5]; $t{list_weight}{$rec[2]} = $rec[6]; $t{list_price1}{$rec[2]} = $rec[7]; $t{list_memo}{$rec[2]} = $rec[15]; # 排位注意! } } $t{sth}->finish; # 按code排序后输出 @loop = (); $t{NO1}=0; @{ $t{lists} } = (); for $n ( sort keys %{ $t{list_NO} } ) { my $row_ref = (); # $t{NO1}++; $t{NO} = 'order_' . $t{list_id}{$n}; # 给排序的变量取名 $$row_ref{NO} = $t{NO}; $$row_ref{NO1} = $t{NO1}; $$row_ref{name} = $t{list_name}{$n}; $$row_ref{code} = $t{list_code}{$n}; $$row_ref{group_id} = $t{list_group_id}{$n}; $$row_ref{dwg_id} = $t{list_dwg_id}{$n}; $$row_ref{Nuid} = $t{list_Nuid}{$n}; $$row_ref{weight} = $t{list_weight}{$n}; $$row_ref{price1} = $t{list_price1}{$n}; $$row_ref{memo} = $t{list_memo}{$n}; push(@{ $t{lists} },$t{list_id}{$n}); push(@loop, $row_ref); } $t{plists} = join('=',@{ $t{lists} }); $t{template} = $self->load_tmpl("$t{html}") || die "error loading tmpl"; $t{template}->param(enq1_id => $t{enq1_id}); $t{template}->param(ptable => $t{ptable}); $t{template}->param(tname => $t{tname}); $t{template}->param(tid => $t{tid}); $t{template}->param(THIS_LOOP => \@loop); $t{template}->param(plists => $t{plists}); $t{template}->param(NE1 => $t{NE1}); return $t{template}->output; } 1;

mscparts20.htm

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>零件排序</TITLE> </HEAD> <BODY bgcolor="#FFFFFF"> <center> <h2>零件排序</h2></center> mode:mscparts20 <form action="" method="post"> <input type="submit" value="返回零件选择"><p> <input type="hidden" name="tmpl" value="mscparts10"> <input type="hidden" name="enq1_id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="id" value="<TMPL_VAR NAME="tid">"> <input type="hidden" name="tname" value="<TMPL_VAR NAME="tname">"> <input type="hidden" name="NE1" value="<TMPL_VAR NAME="NE1">"> <input type="hidden" name="rm" value="modeshowparts10"> </form> enq1_id=><TMPL_VAR NAME="enq1_id">,Equipment Type=><TMPL_VAR NAME="tname">,表格名=><TMPL_VAR NAME="ptable">,NE1=><TMPL_VAR NAME="NE1"><br> plists=><TMPL_VAR NAME="plists"> <hr color="#003366"> <form action="" method="post"> <input type="submit" value="排序后点击去输入零件数量"> <table border=1 cellpadding=5> <tr bgcolor="#3399FF" align="center"> <th>顺序</th> <th>Name</th> <th>Code</th> <th>group_id</th> <th>dwg_id</th> <th>Nuid</th> <th>weight</th> <th>price</th> <th>memo</th> </tr> <TMPL_LOOP NAME="this_loop"> <tr bgcolor="lightcyan" align="left"> <td><TMPL_VAR NAME="NO">=><TMPL_VAR NAME="NO1"> <input type="text" name="<TMPL_VAR NAME="NO">" value="<TMPL_VAR NAME="NO1">"></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><TMPL_VAR NAME="Nuid"></td> <td><TMPL_VAR NAME="weight"></td> <td><TMPL_VAR NAME="price1"></td> <td><TMPL_VAR NAME="memo"></td> </tr> </TMPL_LOOP> </table> <input type="hidden" name="tmpl" value="mscparts30"> <input type="hidden" name="ptable" value="<TMPL_VAR NAME="ptable">"> <input type="hidden" name="plists" value="<TMPL_VAR NAME="plists">"> <input type="hidden" name="tname" value="<TMPL_VAR NAME="tname">"> <input type="hidden" name="tid" value="<TMPL_VAR NAME="tid">"> <input type="hidden" name="enq1_id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="NE1" value="<TMPL_VAR NAME="NE1">"> <input type="hidden" name="rm" value="modeshowparts30"> </form> <hr color="#003366"> </BODY> </HTML>

零件排序完成,输入数量准备(mscshowparts30.pl)

sub mscshowparts30 { my $self = shift; my(%t,$n,@rec,@loop,@loop0,@loop1); # Get CGI query object $t{q} = $self->query(); # 取出数据 $t{tname} = $t{q}->param("tname"); $t{tid} = $t{q}->param("tid"); $t{enq1_id} = $t{q}->param("enq1_id"); $t{plists} = $t{q}->param("plists"); $t{NE1} = $t{q}->param("NE1"); # 取出零件名 @{ $t{lists} } = split(/=/,$t{plists}); @loop0 = (); @loop1 = (); for $n ( 0 .. $#{ $t{lists} } ) { $t{id} = $t{lists}[$n]; $t{NO} = 'order_' . $t{id}; $t{order} = $t{q}->param($t{NO}); $t{select}{$t{order}} = $t{id}; # 传递数据(把排序项目保存下来) my %row = ( NO => $t{NO}, NO1 => $t{order} ); push(@loop1, \%row); # 传递数据(把选择项目保存下来) $t{NO} = 'select_' . $t{id}; my %row = ( NO => $t{NO} ); push(@loop0, \%row); } # 零件表名 $t{ptable} = sprintf("%06d",$t{tid}); $t{ptable} = 'a' . $t{ptable}; @loop = (); $t{NO1} = 0; @{ $t{lists} } = (); for $n ( sort {$a<=>$b} keys %{ $t{select} } ) { $t{id} = $t{select}{$n}; push(@{ $t{lists} },$t{id}); # 把对应数据从TABLE中取出 @{ $t{ps} } = $self->dbh->selectrow_array("SELECT * FROM $t{ptable} where id = $t{id}"); # 分配到各个参数 my $row_ref = (); # $t{NO1}++; $t{QTY} = 'qty_' . $t{id}; # 给零件数量变量取名 $$row_ref{QTY} = $t{QTY}; $$row_ref{NO1} = $t{NO1}; $$row_ref{name} = $t{ps}[1]; $$row_ref{code} = $t{ps}[2]; $$row_ref{group_id} = $t{ps}[3]; $$row_ref{dwg_id} = $t{ps}[4]; $$row_ref{Nuid} = $t{ps}[5]; $$row_ref{weight} = $t{ps}[6]; $$row_ref{price1} = $t{ps}[7]; $$row_ref{memo} = $t{ps}[15]; push(@loop, $row_ref); } $t{plists} = join('=',@{ $t{lists} }); # HTML输出 $t{html} = $t{q}->param("tmpl"); $t{html} = $t{html} . '.htm'; $t{template} = $self->load_tmpl("$t{html}") || die "error loading tmpl"; $t{template}->param(enq1_id => $t{enq1_id}); $t{template}->param(ptable => $t{ptable}); $t{template}->param(plists => $t{plists}); $t{template}->param(tname => $t{tname}); $t{template}->param(tid => $t{tid}); $t{template}->param(NE1 => $t{NE1}); $t{template}->param(THIS_LOOP => \@loop); $t{template}->param(LOOP0 => \@loop0); $t{template}->param(LOOP1 => \@loop1); return $t{template}->output; } 1;

mscparts30.htm

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>输入零件数量</TITLE> </HEAD> <BODY bgcolor="#FFFFFF"> <center> <h2>输入零件数量</h2></center> mode:mscparts30 <form action="" method="post"> <input type="submit" value="返回零件排序"><p> <!-- 这个传送很巧妙,把排序前的选择操作保存下来了 --> <TMPL_LOOP NAME="LOOP0"> <input type="hidden" name="<TMPL_VAR NAME="NO">" value="1"> <TMPL_VAR NAME="NO"><br> </TMPL_LOOP> <input type="hidden" name="tmpl" value="mscparts20"> <input type="hidden" name="tname" value="<TMPL_VAR NAME="tname">"> <input type="hidden" name="enq1_id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="tid" value="<TMPL_VAR NAME="tid">"> <input type="hidden" name="plists" value="<TMPL_VAR NAME="plists">"> <input type="hidden" name="NE1" value="<TMPL_VAR NAME="NE1">"> <input type="hidden" name="rm" value="modeshowparts20"> </form> enq1_id=><TMPL_VAR NAME="enq1_id">,Equipment Type=><TMPL_VAR NAME="tname">,表格名=><TMPL_VAR NAME="ptable">,NE1=><TMPL_VAR NAME="NE1"><br> plists=><TMPL_VAR NAME="plists"> <hr color="#003366"> <form action="" method="post"> <input type="submit" value="输入数量点击去结束"> <table border=1 cellpadding=5> <tr bgcolor="#3399FF" align="center"> <th>ITEM</th> <th>Name</th> <th>Code</th> <th>QTY</th> <th>group_id</th> <th>dwg_id</th> <th>Nuid</th> <th>weight</th> <th>price</th> <th>memo</th> </tr> <TMPL_LOOP NAME="this_loop"> <tr bgcolor="lightcyan" align="left"> <td><TMPL_VAR NAME="NO1"></td> <td><TMPL_VAR NAME="name"></td> <td><TMPL_VAR NAME="code"></td> <td><TMPL_VAR NAME="QTY">,<input type="text" name="<TMPL_VAR NAME="QTY">" value=""></td> <td><TMPL_VAR NAME="group_id"></td> <td><TMPL_VAR NAME="dwg_id"></td> <td><TMPL_VAR NAME="Nuid"></td> <td><TMPL_VAR NAME="weight"></td> <td><TMPL_VAR NAME="price1"></td> <td><TMPL_VAR NAME="memo"></td> </tr> </TMPL_LOOP> </table> <input type="hidden" name="tmpl" value="mscparts40"> <input type="hidden" name="ptable" value="<TMPL_VAR NAME="ptable">"> <input type="hidden" name="tname" value="<TMPL_VAR NAME="tname">"> <input type="hidden" name="tid" value="<TMPL_VAR NAME="tid">"> <input type="hidden" name="plists" value="<TMPL_VAR NAME="plists">"> <input type="hidden" name="enq1_id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="NE1" value="<TMPL_VAR NAME="NE1">"> <TMPL_LOOP NAME="LOOP1"> <input type="hidden" name="<TMPL_VAR NAME="NO">" value="<TMPL_VAR NAME="NO1">"> <TMPL_VAR NAME="NO">=><TMPL_VAR NAME="NO1"><br> </TMPL_LOOP> <input type="hidden" name="rm" value="modeshowparts40"> </form> <hr color="#003366"> </BODY> </HTML>

输入零件确认(mscshowparts40.pl)

sub mscshowparts40 { my $self = shift; my(%t,$n,@rec,@loop,@loop0); # Get CGI query object $t{q} = $self->query(); # 取出数据 $t{tname} = $t{q}->param("tname"); $t{tid} = $t{q}->param("tid"); $t{enq1_id} = $t{q}->param("enq1_id"); $t{plists} = $t{q}->param("plists"); $t{NE1} = $t{q}->param("NE1"); # 零件表名 $t{ptable} = sprintf("%06d",$t{tid}); $t{ptable} = 'a' . $t{ptable}; @{ $t{lists} } = split(/=/,$t{plists}); @loop0 = (); @loop = (); $t{NO1} = 0; for $n ( 0 .. $#{ $t{lists} } ) { $t{id} = $t{lists}[$n]; $t{NO} = 'qty_' . $t{id}; $t{qty1} = $t{q}->param($t{NO}); if ( $t{qty1} == 0 ) { # 如果忘记输入数量,就赋予10亿,然后再删除 $t{qty1} = 10000000000; } # 把对应数据从TABLE中取出 @{ $t{ps} } = $self->dbh->selectrow_array("SELECT * FROM $t{ptable} where id = $t{id}"); # 分配到各个参数 my $row_ref = (); # $t{NO1}++; $$row_ref{qty} = $t{qty1}; $$row_ref{NO1} = $t{NO1}; $$row_ref{name} = $t{ps}[1]; $$row_ref{code} = $t{ps}[2]; $$row_ref{group_id} = $t{ps}[3]; $$row_ref{dwg_id} = $t{ps}[4]; $$row_ref{Nuid} = $t{ps}[5]; $$row_ref{weight} = $t{ps}[6]; $$row_ref{price1} = $t{ps}[7]; $$row_ref{memo} = $t{ps}[15]; push(@loop, $row_ref); # 传递数据(把排序项目保存下来) $t{NO} = 'order_' . $t{id}; $t{order} = $t{q}->param($t{NO}); my %row = ( NO => $t{NO}, NO1 => $t{order} ); push(@loop0, \%row); } # 把数据写到enq1上去 # 先取出partsid和QTY ($t{ps},$t{Qs}) = $self->dbh->selectrow_array("SELECT partsid,QTY FROM enq1 WHERE id = $t{enq1_id}"); @{ $t{pss} } = split(/==/,$t{ps}); @{ $t{Qss} } = split(/==/,$t{Qs}); $t{N1} = $t{NE1} - 1; for $n ( 0 .. $#{ $t{pss} } ) { if ( $n == $t{N1} ) { $t{partsid} = $t{pss}[$n]; $t{QTY1s} = $t{Qss}[$n]; $t{NEn} = $n; } } for $n ( 0 .. $#{ $t{lists} } ) { $t{id} = $t{lists}[$n]; $t{NO} = 'qty_' . $t{id}; $t{qty1} = $t{q}->param($t{NO}); if ( $t{qty1} == 0 ) { # 如果忘记输入数量,就赋予10亿,然后再删除 $t{qty1} = 10000000000; } if ( $t{partsid} eq 'C' ) { # 处理没有零件的情况 $t{partsid} = $t{id}; $t{QTY1s} = $t{qty1}; } else { $t{partsid} .= '=' . $t{id}; $t{QTY1s} .= '=' . $t{qty1}; } } # UPDATE $t{pss}[$t{NEn}] = $t{partsid}; # 零件编号的更新 $t{new1} = join("==",@{ $t{pss} }); $t{sql1} = 'UPDATE enq1 set partsid = "'; $t{sql1} .= $t{new1} . '" where id = ' . $t{enq1_id}; $t{DO1} = $self->dbh->do($t{sql1}); $t{Qss}[$t{NEn}] = $t{QTY1s}; # 零件数量的更新 $t{new1} = join("==",@{ $t{Qss} }); $t{sql2} = 'UPDATE enq1 set QTY = "'; $t{sql2} .= $t{new1} . '" where id = ' . $t{enq1_id}; $t{DO2} = $self->dbh->do($t{sql2}); # HTML输出 $t{html} = $t{q}->param("tmpl"); $t{html} = $t{html} . '.htm'; $t{template} = $self->load_tmpl("$t{html}") || die "error loading tmpl"; $t{template}->param(enq1_id => $t{enq1_id}); $t{template}->param(ptable => $t{ptable}); $t{template}->param(plists => $t{plists}); $t{template}->param(tname => $t{tname}); $t{template}->param(tid => $t{tid}); $t{template}->param(NE1 => $t{NE1}); $t{template}->param(sql1 => $t{sql1}); $t{template}->param(DO1 => $t{DO1}); $t{template}->param(sql2 => $t{sql2}); $t{template}->param(DO2 => $t{DO2}); $t{template}->param(THIS_LOOP => \@loop); $t{template}->param(LOOP0 => \@loop0); return $t{template}->output; } 1;

mscparts40.htm

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>输入零件确认</TITLE> </HEAD> <BODY bgcolor="#FFFFFF"> <center> <h2>输入零件确认</h2></center> mode:mscparts40 <form action="" method="post"> <input type="submit" value="返回零件输入数量"><p> <!-- 这个传送很巧妙,把排序操作保存下来了 --> <TMPL_LOOP NAME="LOOP0"> <input type="hidden" name="<TMPL_VAR NAME="NO">" value="<TMPL_VAR NAME="NO1">"> <TMPL_VAR NAME="NO">=><TMPL_VAR NAME="NO1"><br> </TMPL_LOOP> <input type="hidden" name="tmpl" value="mscparts30"> <input type="hidden" name="tname" value="<TMPL_VAR NAME="tname">"> <input type="hidden" name="enq1_id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="tid" value="<TMPL_VAR NAME="tid">"> <input type="hidden" name="plists" value="<TMPL_VAR NAME="plists">"> <input type="hidden" name="NE1" value="<TMPL_VAR NAME="NE1">"> <input type="hidden" name="rm" value="modeshowparts30"> </form> enq1_id=><TMPL_VAR NAME="enq1_id">,Equipment Type=><TMPL_VAR NAME="tname">,表格名=><TMPL_VAR NAME="ptable">,NE1=><TMPL_VAR NAME="NE1"><br> plists=><TMPL_VAR NAME="plists"> <hr color="#003366"> <form action="" method="post"> <input type="submit" value="确认后点击结束"> <input type="hidden" name="id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="rm" value="modeenq1_parts"> </form> <table border=1 cellpadding=5> <tr bgcolor="#3399FF" align="center"> <th>ITEM</th> <th>Name</th> <th>Code</th> <th>QTY</th> <th>group_id</th> <th>dwg_id</th> <th>Nuid</th> <th>weight</th> <th>price</th> <th>memo</th> </tr> <TMPL_LOOP NAME="this_loop"> <tr bgcolor="lightcyan" align="left"> <td><TMPL_VAR NAME="NO1"></td> <td><TMPL_VAR NAME="name"></td> <td><TMPL_VAR NAME="code"></td> <td><TMPL_VAR NAME="qty"></td> <td><TMPL_VAR NAME="group_id"></td> <td><TMPL_VAR NAME="dwg_id"></td> <td><TMPL_VAR NAME="Nuid"></td> <td><TMPL_VAR NAME="weight"></td> <td><TMPL_VAR NAME="price1"></td> <td><TMPL_VAR NAME="memo"></td> </tr> </TMPL_LOOP> </table> DO1=><TMPL_VAR NAME="DO1">,sql1=><TMPL_VAR NAME="sql1"><br> DO2=><TMPL_VAR NAME="DO2">,sql1=><TMPL_VAR NAME="sql2"><br> <hr color="#003366"> </BODY> </HTML>
戻る