输入零件确认(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
输入零件确认
输入零件确认
mode:mscparts40
enq1_id=>,Equipment Type=>,表格名=>,NE1=>
plists=>
ITEM |
Name |
Code |
QTY |
group_id |
dwg_id |
Nuid |
weight |
price |
memo |
|
|
|
|
|
|
|
|
|
|
DO1=>,sql1=>
DO2=>,sql1=>
戻る