數(shù)據(jù)庫零件表管理程序與界面
戻る
顯示所有零件,mscshowparts.pl
sub mscshowparts {
my $self = shift;
my(%t,$template,$n,@rec,@loop);
# Get CGI query object
$t{q} = $self->query();
# 連接數(shù)據(jù)庫
$t{tname} = $t{q}->param("tname");
$t{id} = $t{q}->param("id");
$t{DB} = $t{q}->param("DB");
# HTMLファイルに出力
$t{html} = $t{q}->param("tmpl");
$t{html} = $t{html} . '.htm';
$template = $self->load_tmpl("$t{html}") || die "error loading tmpl";
# 以下處理是關(guān)鍵。因為有兩個地方(ENQ輸入時和DB管理)來訪問。
# 通過這個處理,實現(xiàn)了"從哪兒來,回哪兒去。"
if ( $t{DB} == 1 ) {
$template->param(DB1 => 1);
$template->param(ENQ1 => 0);
} else {
$t{enq1_id} = $t{q}->param("enq1_id");
$template->param(DB1 => 0);
$template->param(ENQ1 => 1);
$template->param(enq1_id => $t{enq1_id});
}
$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 = (); # この初期化はとても重要!
$$row_ref{DB} = $t{DB};
if ( $t{DB} == 0 ) {
$$row_ref{enq1_id} = $t{enq1_id};
}
$$row_ref{tid} = $t{id};
$$row_ref{tname} = $t{tname};
$$row_ref{ptable} = $t{ptable};
$$row_ref{id} = $rec[0];
$$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;
$template->param(DB => $t{DB});
$template->param(ptable => $t{ptable});
$template->param(tname => $t{tname});
$template->param(THIS_LOOP => \@loop);
return $template->output;
}
1;
mscparts1.htm
零件表格管理
零件表格管理
mode:mscparts1
enq1_id=>
Equipment Type=>,表格名=>,DB=>
ID |
Name |
Code |
group_id |
dwg_id |
Nuid |
weight |
price |
memo |
修正釦 |
|
|
|
|
|
|
|
|
|
|
顯示一個零件(mscshowpartsone.pl)
sub mscshowpartsone {
my $self = shift;
my(%t,@arr,@arr1,$n);
# Get CGI query object
$t{q} = $self->query();
$t{DB} = $t{q}->param("DB");
$t{html} = $t{q}->param("tmpl");
$t{html} = $t{html} . '.htm';
$t{template} = $self->load_tmpl("$t{html}") || die "error loading tmpl";
$t{tid} = $t{q}->param("tid");
$t{tname} = $t{q}->param("tname");
$t{ptable} = $t{q}->param("ptable");
$t{id} = $t{q}->param("id");
$t{items} = $t{q}->param("items");
@arr = split(/,/,$t{items});
$t{items} = $arr[0];
for $n ( 1 .. $#arr ) {
$t{items} = $t{items} . ',' . $arr[$n];
}
@arr1 = ();
@arr1 = $self->dbh->selectrow_array("SELECT $t{items} FROM $t{ptable} WHERE id = $t{id}");
for $n ( 0 .. $#arr ) {
$t{name} = $arr[$n];
$t{value} = $arr1[$n];
$t{template}->param($t{name} => $t{value});
}
if ( $t{DB} == 0 ) {
$t{enq1_id} = $t{q}->param("enq1_id");
$t{template}->param(enq1_id => $t{enq1_id});
$t{template}->param(ENQ1 => 1);
}
$t{template}->param(DB => $t{DB});
$t{template}->param(tid => $t{tid});
$t{template}->param(tname => $t{tname});
$t{template}->param(ptable => $t{ptable});
return $t{template}->output;
}
1;
mscparts2.htm
零件表格項目的修改
零件表格項目的修改
mode:mscparts2
enq1_id=>
Equipment Type=>,表格名=>,DB=>
更新數(shù)據(jù)(mscpartsupdate.pl)
sub mscpartsupdate {
my $self = shift;
my(%t,$items,@arr,@arr1,$n);
# Get CGI query object
$t{q} = $self->query();
$t{DB} = $t{q}->param("DB");
$t{html} = $t{q}->param("tmpl");
$t{html} = $t{html} . '.htm';
$t{template} = $self->load_tmpl("$t{html}") || die "error loading tmpl";
$t{tid} = $t{q}->param("tid");
$t{tname} = $t{q}->param("tname");
$t{ptable} = $t{q}->param("ptable");
$t{id} = $t{q}->param("id");
$items = $t{q}->param("items");
@arr = split(/,/,$items);
@arr1 = ();
for $n ( 0 .. $#arr ) {
$t{name} = $arr[$n];
$t{one} = $t{q}->param($t{name});
push(@arr1,$t{one});
}
$t{sql} = "UPDATE $t{ptable} SET ";
for $n ( 1 .. ($#arr1-1) ) {
$t{sql} .= $arr[$n] . '="' . $arr1[$n] . '",';
}
$t{sql} .= $arr[$#arr1] . '="' . $arr1[$#arr1] . '" ';
$t{sql} .= "where id =" . $t{id};
$t{update} = $self->dbh->do("$t{sql}");
for $n ( 0 .. $#arr ) {
$t{name} = $arr[$n];
$t{value} = $arr1[$n];
$t{template}->param($t{name} => $t{value});
}
$t{template}->param(DO => $t{update});
$t{template}->param(sql => $t{sql});
$t{template}->param(DB => $t{DB});
if ( $t{DB} == 0 ) {
$t{enq1_id} = $t{q}->param("enq1_id");
$t{template}->param(enq1_id => $t{enq1_id});
$t{template}->param(ENQ1 => 1);
}
$t{template}->param(tid => $t{tid});
$t{template}->param(tname => $t{tname});
$t{template}->param(ptable => $t{ptable});
return $t{template}->output;
}
1;
mscparts3.htm
零件表格項目修改的確認
零件表格項目修改的確認
mode:mscparts3
enq1_id=>,
Equipment Type=>,表格名=>,DB=>
ID |
Name |
Code |
group_id |
dwg_id |
Nuid |
weight |
price |
memo |
終了釦 |
|
|
|
|
|
|
|
|
|
|
DO==>
SQL==>
戻る
南郑县|
囊谦县|
湘潭县|
黄平县|
翁牛特旗|
曲靖市|
黄平县|
张家界市|
孟连|
德惠市|
西平县|
桐庐县|
和硕县|
徐水县|
岐山县|
南投县|
凤台县|
镶黄旗|
长兴县|
甘孜|
富民县|
天全县|
穆棱市|
阳原县|
内黄县|
依兰县|
花莲县|
中宁县|
大英县|
尼勒克县|
丹江口市|
繁峙县|
兴宁市|
三门县|
内丘县|
错那县|
陈巴尔虎旗|
泉州市|
谢通门县|
南靖县|
鸡东县|