📄 unit9.pas
字号:
{出库}
unit Unit9;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls,ADODB,DateUtils;
type
Tfrmcailiaochuku = class(TForm)
Label1: TLabel;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit2: TEdit;
Label5: TLabel;
Label6: TLabel;
Edit4: TEdit;
Label7: TLabel;
DateTimePicker1: TDateTimePicker;
Button1: TButton;
Button2: TButton;
Label8: TLabel;
Edit5: TEdit;
Edit3: TEdit;
Edit1: TEdit;
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ComboBox2DropDown(Sender: TObject);
procedure ComboBox2Click(Sender: TObject);
procedure Edit3KeyPress(Sender: TObject; var Key: Char);
procedure Button1Click(Sender: TObject);
procedure Edit3Exit(Sender: TObject);
procedure Edit3Change(Sender: TObject);
procedure ComboBox1Click(Sender: TObject);
// procedure ComboBox1Click(Sender: TObject);
// procedure Edit3Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function IsNotNumric(const ScrString:string):boolean;
function IsEmpty(const ScrString:string):boolean;
procedure SetWeekValuesToChuKuSQL( bumenshu,bumenjine,chukushu,chukujine,jiecunshu,jiecunjine:string;zhou,nian:Integer);
procedure InsertRecordToWeekHaoCai(chukushu,chukujine,jiecunshu,jiecunjine:string;zhou,nian:Integer);
end;
var
frmcailiaochuku: Tfrmcailiaochuku;
guigexinghao:string;
implementation
uses Unit2;
{$R *.dfm}
procedure TFrmcailiaochuku.InsertRecordToWeekHaoCai(chukushu,chukujine,jiecunshu,jiecunjine:string;zhou,nian:Integer);
begin
if ComboBox1.Text = '生产部' then
begin
chukuSQL := 'Insert into WeekHaoCai values('''+ComboBox2.Text+''','''+clclass+''','''+Edit1.Text+''','''+Edit2.Text+''','''+
jiecunshu+''','''+jiecunjine+''','''+'0.00'',''0.00'','''+chukushu+''','''+
chukujine+''','''+Edit3.Text+''','''+Edit4.Text+''',''0.00'',''0.00'''+',''0.00'',''0.00'''+
',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00,'''+jiecunshu+''','''+jiecunjine+
''','+IntToStr(zhou)+','+IntToStr(nian)+')';
end;
if ComboBox1.Text = '工程部' then
begin
chukuSQL := 'Insert into WeekHaoCai values('''+ComboBox2.Text+''','''+clclass+''','''+Edit1.Text+''','''+Edit2.Text+''','''+
jiecunshu+''','''+jiecunjine+''','''+'0.00'',''0.00'','''+chukushu+''','''+
chukujine+''','''+'0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+
',''0.00'',''0.00'''+',''0.00'',''0.00'''+','''+Edit3.Text+''','''+Edit4.Text+''',''0.00'',''0.00,'''+
jiecunshu+''','''+jiecunjine+''','+IntToStr(zhou)+','+IntToStr(nian)+')';
end;
if ComboBox1.Text = '器件厂' then
begin
chukuSQL := 'Insert into WeekHaoCai values('''+ComboBox2.Text+''','''+clclass+''','''+Edit1.Text+''','''+Edit2.Text+''','''+
jiecunshu+''','''+jiecunjine+''','''+'0.00'',''0.00'','''+chukushu+''','''+
chukujine+''','''+'0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+
',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+','''+Edit3.Text+''','''+Edit4.Text+''','''+
jiecunshu+''','''+jiecunjine+''','+IntToStr(zhou)+','+IntToStr(nian)+')';
end;
if ComboBox1.Text = '企管部' then
begin
chukuSQL := 'Insert into WeekHaoCai values('''+ComboBox2.Text+''','''+clclass+''','''+Edit1.Text+''','''+Edit2.Text+''','''+
jiecunshu+''','''+jiecunjine+''','''+'0.00'',''0.00'','''+chukushu+''','''+
chukujine+''','''+'0.00'',''0.00'+''','''+Edit3.Text+''','''+Edit4.Text+
''',''0.00'',''0.00'''+''',0.00'',''0.00'''+''',0.00'',''0.00'''+''',0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'','''+jiecunshu+''','''+
jiecunjine+''','+IntToStr(zhou)+','+IntToStr(nian)+')';
end;
if ComboBox1.Text = '总办' then
begin
chukuSQL := 'Insert into WeekHaoCai values('''+ComboBox2.Text+''','''+clclass+''','''+Edit1.Text+''','''+Edit2.Text+''','''+
jiecunshu+''','''+jiecunjine+''','''+'0.00'',''0.00'','''+chukushu+''','''+chukujine+''','''+'0.00'',''0.00'''+',''0.00'',''0.00'''+','''+Edit3.Text+''','''+Edit4.Text+''',''0.00'',''0.00'''+',''0.00'',''0.00'''+
',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'','''+jiecunshu+''','''+jiecunjine+''','+IntToStr(zhou)+','+IntToStr(nian)+')';
end;
if ComboBox1.Text = '财务部' then
begin
chukuSQL := 'Insert into WeekHaoCai values('''+ComboBox2.Text+''','''+clclass+''','''+Edit1.Text+''','''+Edit2.Text+''','''+
jiecunshu+''','''+jiecunjine+''','''+'0.00'',''0.00'','''+chukushu+''','''+chukujine+''','''+'0.00'',0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+','''+Edit3.Text+''','''+Edit4.Text+''',0.00'',''0.00'''+
',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'','''+jiecunshu+''','''+jiecunjine+''','+IntToStr(zhou)+','+IntToStr(nian)+')';
end;
if ComboBox1.Text = '品管部' then
begin
chukuSQL := 'Insert into WeekHaoCai values('''+ComboBox2.Text+''','''+clclass+''','''+Edit1.Text+''','''+Edit2.Text+''','''+
jiecunshu+''','''+jiecunjine+''','''+'0.00'',''0.00'','''+chukushu+''','''+chukujine+''','''+'0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+','''+Edit3.Text+''','''+Edit4.Text+
''',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'','''+jiecunshu+''','''+jiecunjine+''','+IntToStr(zhou)+','+IntToStr(nian)+')';
end;
if ComboBox1.Text = '业务部' then
begin
chukuSQL := 'Insert into WeekHaoCai values('''+ComboBox2.Text+''','''+clclass+''','''+Edit1.Text+''','''+Edit2.Text+''','''+
jiecunshu+''','''+jiecunjine+''','''+'0.00'',''0.00'','''+chukushu+''','''+chukujine+''','''+'0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+
',''0.00'',''0.00'''+','''+Edit3.Text+''','''+Edit4.Text+''',''0.00'',''0.00'''+',''0.00'',''0.00'','''+jiecunshu+''','''+jiecunjine+''','+IntToStr(zhou)+','+IntToStr(nian)+')';
end;
if ComboBox1.Text = '销管中心' then
begin
chukuSQL := 'Insert into WeekHaoCai values('''+ComboBox2.Text+''','''+clclass+''','''+Edit1.Text+''','''+Edit2.Text+''','''+
jiecunshu+''','''+jiecunjine+''','''+'0.00'',''0.00'','''+chukushu+''','''+chukujine+''','''+'0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'''+
','''+Edit3.Text+''','''+Edit4.Text+''',''0.00'',''0.00'''+',''0.00'',''0.00'''+',''0.00'',''0.00'','''+jiecunshu+''','''+jiecunjine+''','+IntToStr(zhou)+','+IntToStr(nian)+')';
end;
end;
procedure TFrmcailiaochuku.SetWeekValuesToChuKuSQL( bumenshu,bumenjine,chukushu,chukujine,jiecunshu,jiecunjine:string;zhou,nian:Integer);
begin
if ComboBox1.Text = '生产部' then
begin
bumenshu := FloatToStr(StrToFloat(bumenshu)+StrToFloat(Edit3.Text));
bumenjine := FloatToStr(StrToFloat(bumenjine)+StrToFloat(Edit4.Text));
chukuSQL := 'Update WeekHaoCai set chukushuliang='''+chukushu+''',chukujine='''+chukujine+
''',scbshuliang='''+bumenshu+''',scbjine='''+bumenjine+''',jiecunshuliang='''+jiecunshu+''',jiecunjine='''+jiecunjine+
''' where nian='+IntToStr(nian)+' and zhou='+IntToStr(zhou)+' and class='''+clclass+''' and cailiaoming='''+
ComboBox2.Text+'''';
end;
if ComboBox1.Text = '工程部' then
begin
bumenshu := FloatToStr(StrToFloat(bumenshu)+StrToFloat(Edit3.Text));
bumenjine := FloatToStr(StrToFloat(bumenjine)+StrToFloat(Edit4.Text));
chukuSQL := 'Update WeekHaoCai set chukushuliang='''+chukushu+''',chukujine='''+chukujine+
''',gcbshuliang='''+bumenshu+''',gcbjine='''+bumenjine+''',jiecunshuliang='''+jiecunshu+''',jiecunjine='''+jiecunjine+
''' where nian='+IntToStr(nian)+' and zhou='+IntToStr(zhou)+' and class='''+clclass+''' and cailiaoming='''+
ComboBox2.Text+'''';
end;
if ComboBox1.Text = '器件厂' then
begin
bumenshu := FloatToStr(StrToFloat(bumenshu)+StrToFloat(Edit3.Text));
bumenjine := FloatToStr(StrToFloat(bumenjine)+StrToFloat(Edit4.Text));
chukuSQL := 'Update WeekHaoCai set chukushuliang='''+chukushu+''',chukujine='''+chukujine+
''',qjcshuliang='''+bumenshu+''',qjcjine='''+bumenjine+''',jiecunshuliang='''+jiecunshu+''',jiecunjine='''+jiecunjine+
''' where nian='+IntToStr(nian)+' and zhou='+IntToStr(zhou)+' and class='''+clclass+''' and cailiaoming='''+
ComboBox2.Text+'''';
end;
if ComboBox1.Text = '企管部' then
begin
bumenshu := FloatToStr(StrToFloat(bumenshu)+StrToFloat(Edit3.Text));
bumenjine := FloatToStr(StrToFloat(bumenjine)+StrToFloat(Edit4.Text));
chukuSQL := 'Update WeekHaoCai set chukushuliang='''+chukushu+''',chukujine='''+chukujine+
''',qgbshuliang='''+bumenshu+''',qgbjine='''+bumenjine+''',jiecunshuliang='''+jiecunshu+''',jiecunjine='''+jiecunjine+
''' where nian='+IntToStr(nian)+' and zhou='+IntToStr(zhou)+' and class='''+clclass+''' and cailiaoming='''+
ComboBox2.Text+'''';
end;
if ComboBox1.Text = '总办' then
begin
bumenshu := FloatToStr(StrToFloat(bumenshu)+StrToFloat(Edit3.Text));
bumenjine := FloatToStr(StrToFloat(bumenjine)+StrToFloat(Edit4.Text));
chukuSQL := 'Update WeekHaoCai set chukushuliang='''+chukushu+''',chukujine='''+chukujine+
''',zbshuliang='''+bumenshu+''',zbjine='''+bumenjine+''',jiecunshuliang='''+jiecunshu+''',jiecunjine='''+jiecunjine+
''' where nian='+IntToStr(nian)+' and zhou='+IntToStr(zhou)+' and class='''+clclass+''' and cailiaoming='''+
ComboBox2.Text+'''';
end;
if ComboBox1.Text = '财务部' then
begin
bumenshu := FloatToStr(StrToFloat(bumenshu)+StrToFloat(Edit3.Text));
bumenjine := FloatToStr(StrToFloat(bumenjine)+StrToFloat(Edit4.Text));
chukuSQL := 'Update WeekHaoCai set chukushuliang='''+chukushu+''',chukujine='''+chukujine+
''',cwbshuliang='''+bumenshu+''',cwbjine='''+bumenjine+''',jiecunshuliang='''+jiecunshu+''',jiecunjine='''+jiecunjine+
''' where nian='+IntToStr(nian)+' and zhou='+IntToStr(zhou)+' and class='''+clclass+''' and cailiaoming='''+
ComboBox2.Text+'''';
end;
if ComboBox1.Text = '品管部' then
begin
bumenshu := FloatToStr(StrToFloat(bumenshu)+StrToFloat(Edit3.Text));
bumenjine := FloatToStr(StrToFloat(bumenjine)+StrToFloat(Edit4.Text));
chukuSQL := 'Update WeekHaoCai set chukushuliang='''+chukushu+''',chukujine='''+chukujine+
''',pgbshuliang='''+bumenshu+''',pgbjine='''+bumenjine+''',jiecunshuliang='''+jiecunshu+''',jiecunjine='''+jiecunjine+
''' where nian='+IntToStr(nian)+' and zhou='+IntToStr(zhou)+' and class='''+clclass+''' and cailiaoming='''+
ComboBox2.Text+'''';
end;
if ComboBox1.Text = '业务部' then
begin
bumenshu := FloatToStr(StrToFloat(bumenshu)+StrToFloat(Edit3.Text));
bumenjine := FloatToStr(StrToFloat(bumenjine)+StrToFloat(Edit4.Text));
chukuSQL := 'Update WeekHaoCai set chukushuliang='''+chukushu+''',chukujine='''+chukujine+
''',ywbshuliang='''+bumenshu+''',ywbjine='''+bumenjine+''',jiecunshuliang='''+jiecunshu+''',jiecunjine='''+jiecunjine+
''' where nian='+IntToStr(nian)+' and zhou='+IntToStr(zhou)+' and class='''+clclass+''' and cailiaoming='''+
ComboBox2.Text+'''';
end;
if ComboBox1.Text = '销管中心' then
begin
bumenshu := FloatToStr(StrToFloat(bumenshu)+StrToFloat(Edit3.Text));
bumenjine := FloatToStr(StrToFloat(bumenjine)+StrToFloat(Edit4.Text));
chukuSQL := 'Update WeekHaoCai set chukushuliang='''+chukushu+''',chukujine='''+chukujine+
''',xgzxshuliang='''+bumenshu+''',xgzxjine='''+bumenjine+''',jiecunshuliang='''+jiecunshu+''',jiecunjine='''+jiecunjine+
''' where nian='+IntToStr(nian)+' and zhou='+IntToStr(zhou)+' and class='''+clclass+''' and cailiaoming='''+
ComboBox2.Text+'''';
end;
end;
function TFrmcailiaochuku.IsEmpty(const ScrString:string): boolean;
begin
if Trim(ScrString) = '' then
Result := True
else
Result := False;
end;
function Tfrmcailiaochuku.IsNotNumric(const ScrString:string):boolean;
var
c:string;
i:integer;
BoolResult:Boolean;
cnt:integer;
begin
cnt:=0;
BoolResult := FALSE;
if copy(ScrString,1,1)='.' then
cnt:=1;
for i := 2 to length(Scrstring) do
begin
//c:=PChar(copy(ScrString,i,1))^;
c := Copy(ScrString,i,1);
if c='-' then
begin
BoolResult:=true;
break;
end;
if c = '.' then
begin
cnt:=cnt+1;
if cnt>1 then
begin
boolResult:=true;
break;
end;
end;
// else
// BoolResult:=false;
end;
Result := BoolResult;
end;
procedure Tfrmcailiaochuku.Button2Click(Sender: TObject);
begin
close;
end;
procedure Tfrmcailiaochuku.FormCreate(Sender: TObject);
begin
datetimepicker1.DateTime := date;
end;
procedure Tfrmcailiaochuku.ComboBox2DropDown(Sender: TObject);
var
Query1:TADOQuery;
begin
Edit3.Text := '';
Query1 := TADOQuery.Create(nil);
Query1.ConnectionString := Frmmain.ADOConnection1.ConnectionString;
with Query1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from cailiao where class='''+trim(clclass)+'''');
Open;
end;
Combobox2.Clear;
Combobox2.Items.Clear;
while not Query1.eof do
begin
combobox2.Items.Add(trim(Query1.FieldByName('cailiaoming').AsString));
Query1.Next;
end;
if Combobox2.Items.Count >0 then
Combobox2.ItemIndex := -1;
FreeAndNil(Query1);
end;
procedure Tfrmcailiaochuku.ComboBox2Click(Sender: TObject);
var
Query1:TADOQuery;
kucunshu:string;
rukushu:string;
chukushu:string;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -