零件输入的界面和程序
戻る
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
Parts管理
Parts管理
mode:modeparts_start
id=>
ptable=>
显示ptable的内容
ID |
name |
code |
group_id |
dwg_id |
price |
Unit |
memo |
Parts修正 |
|
|
|
|
|
|
|
|
|
追加ptable
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
Parts項目修正
Parts項目修正
mode:modeparts_modify
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;
戻る