零件排序完成,輸入數(shù)量準(zhǔn)備(mscshowparts30.pl)
sub mscshowparts30 {
my $self = shift;
my(%t,$n,@rec,@loop,@loop0,@loop1);
# Get CGI query object
$t{q} = $self->query();
# 取出數(shù)據(jù)
$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};
# 傳遞數(shù)據(jù)(把排序項目保存下來)
my %row = (
NO => $t{NO},
NO1 => $t{order}
);
push(@loop1, \%row);
# 傳遞數(shù)據(jù)(把選擇項目保存下來)
$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});
# 把對應(yīng)數(shù)據(jù)從TABLE中取出
@{ $t{ps} } = $self->dbh->selectrow_array("SELECT * FROM $t{ptable} where id = $t{id}");
# 分配到各個參數(shù)
my $row_ref = (); #
$t{NO1}++;
$t{QTY} = 'qty_' . $t{id}; # 給零件數(shù)量變量取名
$$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
輸入零件數(shù)量
輸入零件數(shù)量
mode:mscparts30
enq1_id=>,Equipment Type=>,表格名=>,NE1=>
plists=>
輸入零件確認(rèn)(mscshowparts40.pl)
sub mscshowparts40 {
my $self = shift;
my(%t,$n,@rec,@loop,@loop0);
# Get CGI query object
$t{q} = $self->query();
# 取出數(shù)據(jù)
$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 ) { # 如果忘記輸入數(shù)量,就賦予10億,然后再刪除
$t{qty1} = 10000000000;
}
# 把對應(yīng)數(shù)據(jù)從TABLE中取出
@{ $t{ps} } = $self->dbh->selectrow_array("SELECT * FROM $t{ptable} where id = $t{id}");
# 分配到各個參數(shù)
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);
# 傳遞數(shù)據(jù)(把排序項目保存下來)
$t{NO} = 'order_' . $t{id};
$t{order} = $t{q}->param($t{NO});
my %row = (
NO => $t{NO},
NO1 => $t{order}
);
push(@loop0, \%row);
}
# 把數(shù)據(jù)寫到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 ) { # 如果忘記輸入數(shù)量,就賦予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}; # 零件數(shù)量的更新
$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
輸入零件確認(rèn)
輸入零件確認(rèn)
mode:mscparts40
enq1_id=>,Equipment Type=>,表格名=>,NE1=>
plists=>
ITEM |
Name |
Code |
QTY |
group_id |
dwg_id |
Nuid |
weight |
price |
memo |
|
|
|
|
|
|
|
|
|
|
DO1=>,sql1=>
DO2=>,sql1=>
戻る
蓬安县|
遂川县|
高阳县|
沁阳市|
东光县|
合川市|
嘉鱼县|
兰州市|
慈溪市|
新津县|
疏勒县|
奉节县|
耒阳市|
公安县|
嵊州市|
贵定县|
白玉县|
纳雍县|
谢通门县|
屏东市|
天峻县|
珠海市|
绥中县|
海盐县|
房产|
南岸区|
长岭县|
白水县|
井冈山市|
精河县|
通山县|
札达县|
泗阳县|
连平县|
托克逊县|
阜宁县|
荥阳市|
凭祥市|
马龙县|
镇巴县|
三河市|