📄 unit9.pas
字号:
end;
if ComboBox1.Text = '总办' then
begin
bumenshu := Query1.FieldByName('zbshuliang').AsString;
bumenjine := Query1.FieldByName('zbjine').AsString;
InsertRecordToWeekHaoCai(Format('%.2f',[StrToFloat(chukushu)]),Format('%.2f',[StrToFloat(chukujine)]),
Format('%.2f',[StrToFloat(jiecunshu)]),Format('%.2f',[StrToFloat(jiecunjine)]),zhou,nian);
Query2.SQL.Add(chukuSQL);
end;
if ComboBox1.Text = '财务部' then
begin
bumenshu := Query1.FieldByName('cwbshuliang').AsString;
bumenjine := Query1.FieldByName('cwbjine').AsString;
InsertRecordToWeekHaoCai(Format('%.2f',[StrToFloat(chukushu)]),Format('%.2f',[StrToFloat(chukujine)]),
Format('%.2f',[StrToFloat(jiecunshu)]),Format('%.2f',[StrToFloat(jiecunjine)]),zhou,nian);
Query2.SQL.Add(chukuSQL);
end;
if ComboBox1.Text = '品管部' then
begin
bumenshu := Query1.FieldByName('pgbshuliang').AsString;
bumenjine := Query1.FieldByName('pgbjine').AsString;
InsertRecordToWeekHaoCai(Format('%.2f',[StrToFloat(chukushu)]),Format('%.2f',[StrToFloat(chukujine)]),
Format('%.2f',[StrToFloat(jiecunshu)]),Format('%.2f',[StrToFloat(jiecunjine)]),zhou,nian);
Query2.SQL.Add(chukuSQL);
end;
if ComboBox1.Text = '业务部' then
begin
bumenshu := Query1.FieldByName('ywbshuliang').AsString;
bumenjine := Query1.FieldByName('ywbjine').AsString;
InsertRecordToWeekHaoCai(Format('%.2f',[StrToFloat(chukushu)]),Format('%.2f',[StrToFloat(chukujine)]),
Format('%.2f',[StrToFloat(jiecunshu)]),Format('%.2f',[StrToFloat(jiecunjine)]),zhou,nian);
Query2.SQL.Add(chukuSQL);
end;
if ComboBox1.Text = '销管中心' then
begin
bumenshu := Query1.FieldByName('xgzxshuliang').AsString;
bumenjine := Query1.FieldByName('xgzxjine').AsString;
InsertRecordToWeekHaoCai(Format('%.2f',[StrToFloat(chukushu)]),Format('%.2f',[StrToFloat(chukujine)]),
Format('%.2f',[StrToFloat(jiecunshu)]),Format('%.2f',[StrToFloat(jiecunjine)]),zhou,nian);
Query2.SQL.Add(chukuSQL);
end;
// showmessage('Insert: '+chukuSQL);
// exit;
Query2.ExecSQL;
end;
{\\\\\\以下是记录最后一次个部门出库记录到LastWeekOut中,同周不做叠加\\\\\}
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('Select * from LastWeekOut where class='''+clclass+''' and cailiaoming='''+ComboBox2.Text+
''' and bumenming='''+ComboBox1.Text+'''');
Query2.Prepared;
Query2.Open;
if Not Query2.Eof then
begin
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('Update LastWeekOut set lastchukushu='''+Edit3.Text+''',lastchukujine='''+Edit4.Text+
''' where class='''+clclass+''' and cailiaoming='''+ComboBox2.Text+''' and bumenming='''+ComboBox1.Text+'''');
Query2.ExecSQL;
end
else
begin
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('Insert into LastWeekOut values('''+clclass+''','''+ComboBox2.Text+''','''+
ComboBox1.Text+''','''+Edit3.Text+''','''+Edit4.Text+''')');
Query2.ExecSQL;
end;
if (MonthOfTheYear(DateTimePicker1.Date) <= 1) and (zhou >= 52) then
nian := nian + 1; //恢复上面因为防止周出错而改动的nian 变量
{以下对月进行操作}
Yue := MonthOfTheYear(DateTimePicker1.Date);
LeftArea := IntToStr(nian)+'-'+IntToStr(yue)+'-'+'25';
if yue=12 then
RightArea := IntToStr(nian+1)+'-'+'1'+'-'+'25';
if (yue < 12) then
RightArea := IntToStr(nian)+'-'+IntToStr(yue + 1)+'-'+'25';
{在[yyyy-mm-25,yyyy-mm2-25)只间}
if (DateTimePicker1.Date >= StrToDate(LeftArea)) and (DateTimePicker1.Date < StrToDate(RightArea)) then
begin {能顺利操作周,月已经不存在问题}
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select * from MonthHaoCai where riqi='''+DateToStr(StrToDate(RightArea)-1)+''' and class='''+clclass+
''' and cailiaoming='''+ComboBox2.Text+'''');
Query1.Prepared;
Query1.Open;
if Not Query1.Eof then //MonthHaoCai中已存在本月的记录
begin
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('Select * from MonthDataCache where class='''+clclass+''' and cailiaoming='''+ComboBox2.Text+'''');
Query2.Prepared;
Query2.Open;
if Not Query2.Eof then //从MonthDataCache中取得最近记录
begin
kucunshu := Query2.FieldByName('kucunshu').AsString;
kucunjine := Query2.FieldByName('kucunjine').AsString;
rukushu := Query2.FieldByName('rukushu').AsString;
rukujine := Query2.FieldByName('rukujine').AsString;
chukushu := Query2.FieldByName('chukushu').AsString;
chukujine := Query2.FieldByName('chukujine').AsString;
chukushu := FloatToStr(StrToFloat(chukushu)+StrToFloat(Edit3.Text));
chukujine := FloatToStr(StrToFloat(chukujine)+StrToFloat(Edit4.Text));
jiecunshu := FloatToStr(StrToFloat(kucunshu)+StrToFloat(rukushu)-StrToFloat(chukushu));
jiecunjine := FloatToStr(StrToFloat(kucunjine)+StrToFloat(rukujine)-StrToFloat(chukujine));
Query2.Close;
Query2.SQL.Clear; //更新MonthDataCache
Query2.SQL.Add('Update MonthDataCache set chukushu='''+Format('%.2f',[StrToFloat(chukushu)])+''',chukujine='''+
Format('%.2f',[StrToFloat(chukujine)])+ ''' where class='''+clclass+''' and cailiaoming='''+ComboBox2.Text+'''');
Query2.ExecSQL;
Query2.Close;
Query2.SQL.Clear; //更新MonthHaoCai
Query2.SQL.Add('Update MonthHaoCai set chukushu='''+Format('%.2f',[StrToFloat(chukushu)])+''',chukujine='''+
Format('%.2f',[StrToFloat(chukujine)])+''',jiecunshu='''+Format('%.2f',[StrToFloat(jiecunshu)])+''',jiecunjine='''+
Format('%.2f',[StrToFloat(jiecunjine)])+''' where riqi='''+DateToStr(StrToDate(RightArea)-1)+
''' and class='''+clclass+''' and cailiaoming='''+ComboBox2.Text+'''');
Query2.ExecSQL;
end
else //MonthDataCache中无记录
Application.Terminate;
end
else //MonthHaoCai中不存在本月的记录
begin
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('Select * from MonthDataCache where class='''+clclass+''' and cailiaoming='''+
ComboBox2.Text+'''');
Query2.Prepared;
Query2.Open;
if Not Query2.Eof then //MonthDataCache存在最近一次历史记录
begin
kucunshu := Query2.FieldByName('kucunshu').AsString;
kucunjine := Query2.FieldByName('kucunjine').AsString;
rukushu := Query2.FieldByName('rukushu').AsString;
rukujine := Query2.FieldByName('rukujine').AsString;
chukushu := Query2.FieldByName('chukushu').AsString;
chukujine := Query2.FieldByName('chukujine').AsString;
kucunshu := FloatToStr(StrToFloat(kucunshu)+StrToFloat(rukushu)-StrToFloat(chukushu));
kucunjine := FloatToStr(StrToFloat(kucunjine)+StrToFloat(rukujine)-StrToFloat(chukujine));
jiecunshu := FloatToStr(StrToFloat(kucunshu)-StrToFloat(Edit3.Text)); //新的月记录 入库为0
jiecunjine := FloatToStr(StrToFloat(kucunjine)-StrToFloat(Edit4.Text));
Query2.Close;
Query2.SQL.Clear; //更新MonthDataCache
Query2.SQL.Add('Update MonthDataCache set kucunshu='''+Format('%.2f',[StrToFloat(kucunshu)])+''',kucunjine='''+
Format('%.2f',[StrToFloat(kucunjine)])+''',rukushu=''0.00'',rukujine=''0.00'''+',chukushu='''+Format('%.2f',[StrToFloat(Edit3.Text)])+
''',chukujine='+Format('%.2f',[StrToFloat(Edit4.Text)])+ ''' where class='''+
clclass+''' and cailiaoming='''+ComboBox2.Text+'''');
Query2.ExecSQL;
Query2.Close;
Query2.SQL.Clear; //MonthHaoCai中插入一条新记录
Query2.SQL.Add('Insert into MonthHaoCai values('''+ComboBox2.Text+''','''+clclass+''','''+guigexinghao+
''','''+Edit1.Text+''','''+Format('%.2f',[StrToFloat(Edit2.Text)])+''','''+Format('%.2f',[StrToFloat(kucunshu)])+
''','''+Format('%.2f',[StrToFloat(kucunjine)])+''','''+'0.00'',''0.00'','''+Format('%.2f',[StrToFloat(Edit3.Text)])+''','''+
Format('%.2f',[StrToFloat(Edit4.Text)])+''','''+Format('%.2f',[StrToFloat(jiecunshu)])+''','''+Format('%.2f',[StrToFloat(jiecunjine)])+
''','''+''+''','''+DateToStr(StrToDate(RightArea)-1)+''')');
Query2.ExecSQL;
end
else
begin
Application.MessageBox('无此材料的任何数据!Unit9,Line:659','系统提示',MB_OK);
Application.Terminate;
end;
end;
end;
{在(yyyy-mm-dd,yyyy-mm2-25)区间情况,左半区间}
if DateTimePicker1.Date < StrToDate(LeftArea) then
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('select * from MonthHaoCai where riqi='''+DateToStr(StrToDate(LeftArea)-1)+
''' and class='''+ clclass+''' and cailiaoming='''+ComboBox2.Text+'''');
Query1.Prepared;
Query1.Open;
if Not Query1.Eof then //MonthHaoCai中存在记录
begin
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('Select * from MonthDataCache where class='''+clclass+''' and cailiaoming='''+
ComboBox2.Text+'''');
Query2.Prepared;
Query2.Open;
if Not Query2.Eof then // MonthDataCache有
begin
rukushu := Query2.FieldByName('rukushu').AsString;
rukujine := Query2.FieldByName('rukujine').AsString;
kucunshu := Query2.FieldByName('kucunshu').AsString;
kucunjine := Query2.FieldByName('kucunjine').AsString;
chukushu := Query2.FieldByName('chukushu').AsString;
chukujine := Query2.FieldByName('chukujine').AsString;
chukushu := FloatToStr(StrToFloat(chukushu)+StrToFloat(Edit3.Text));
chukujine := FloatToStr(StrToFloat(chukujine)+StrToFloat(Edit4.Text));
jiecunshu := FloatToStr(StrToFloat(kucunshu)+StrToFloat(rukushu)-StrToFloat(chukushu));
jiecunjine := FloatToStr(StrToFloat(kucunjine)+StrToFloat(rukujine)-StrToFloat(chukujine));
Query2.Close;
Query2.SQL.Clear; //更新MonthDataCache
Query2.SQL.Add('Update MonthDataCache set chukushu='''+Format('%.2f',[StrToFloat(chukushu)])+
''',chukujine='''+Format('%.2f',[StrToFloat(chukujine)])+''' where class='''+clclass+
''' and cailiaoming='''+ComboBox2.Text+'''');
Query2.ExecSQL;
Query2.Close;
Query2.SQL.Clear; //更新MonthHaoCai
Query2.SQL.Add('Update MonthHaoCai set chukushu='''+Format('%.2f',[StrToFloat(chukushu)])+''',chukujine='''+
Format('%.2f',[StrToFloat(chukujine)])+ ''',jiecunshu='''+Format('%.2f',[StrToFloat(jiecunshu)])+''',jiecunjine='''+
Format('%.2f',[StrToFloat(jiecunjine)])+''' where riqi='''+DateToStr(StrToDate(LeftArea)-1)+
''' and class='''+clclass+''' and cailiaoming='''+ComboBox2.Text+'''');
Query2.ExecSQL;
end
else //无
begin
Application.MessageBox('无此材料任何数据!Unit9,Line:707','系统提示',MB_OK);
Application.Terminate;
end;
end
else //MonthHaoCai不存在记录
begin
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('Select * from MonthDataCache where class='''+clclass+''' and cailiaoming='''+
ComboBox2.Text+'''');
Query2.Prepared;
Query2.Open;
if Not Query2.Eof then //MonthDataCache 存在最近一次历史记录
begin
kucunshu := Query2.FieldByName('kucunshu').AsString;
kucunjine := Query2.FieldByName('kucunjine').AsString;
rukushu := Query2.FieldByName('rukushu').AsString;
rukujine := Query2.FieldByName('rukujine').AsString;
chukushu := Query2.FieldByName('chukushu').AsString;
chukujine := Query2.FieldByName('chukujine').AsString;
kucunshu := FloatToStr(StrToFloat(kucunshu)+StrToFloat(rukushu)-StrToFloat(chukushu));
kucunjine := FloatToStr(StrToFloat(kucunjine)+StrToFloat(rukujine)-StrToFloat(chukujine));
jiecunshu := FloatToStr(StrToFloat(kucunshu)-StrToFloat(Edit3.Text));
jiecunjine := FloatToStr(StrToFloat(kucunjine)-StrToFloat(Edit4.Text));
Query2.Close;
Query2.SQL.Clear; //更新 MonthDataCache
Query2.SQL.Add('Update MonthDataCache set kucunshu='''+Format('%.2f',[StrToFloat(kucunshu)])+''',kucunjine='''+Format('%.2f',[StrToFloat(kucunjine)])+
''',rukushu=''0.00'',rukujine=''0.00'','+'chukushu='''+Format('%.2f',[StrToFloat(Edit3.Text)])+''',chukujine='''+Format('%.2f',[StrToFloat(Edit4.Text)])+
''' where class='''+clclass+''' and cailiaoming='''+ ComboBox2.Text+'''');
Query2.ExecSQL;
Query2.Close;
Query2.SQL.Clear; //MonthHaoCai插入一条新记录
Query2.SQL.Add('Insert into MonthHaoCai values('''+ComboBox2.Text+''','''+clclass+''','''+guigexinghao+''','''+
Edit1.Text+''','''+Format('%.2f',[StrToFloat(Edit2.Text)])+''','''+Format('%.2f',[StrToFloat(kucunshu)])+''','''+
Format('%.2f',[StrToFloat(kucunjine)])+''',''0.00'',''0.00'','''+Format('%.2f',[StrToFloat(Edit3.Text)])+''','''+
Format('%.2f',[StrToFloat(Edit4.Text)])+''','''+Format('%.2f',[StrToFloat(jiecunshu)])+''','''+
Format('%.2f',[StrToFloat(jiecunjine)])+''','''+''+''','''+DateToStr(StrToDate(LeftArea)-1)+''')');
Query2.ExecSQL;
end
else
begin
Application.MessageBox('不存在此材料的任何数据!Unit9,Line:745','系统提示',MB_OK);
Application.Terminate;
end;
end;
end;
if DateTimePicker1.Date > StrToDate(RightArea) then
begin
Application.MessageBox('应该不会出现这个对话框!Unit9,Line:752','???',MB_OK OR MB_ICONSTOP);
Application.Terminate;
end;
{以下是对年报表操作}
LeftArea := IntToStr(nian-1)+'-'+'12'+'-'+'25';
RightArea := IntToStr(nian)+'-'+'12'+'-'+'25';
if (DateTimePicker1.Date >= StrToDate(LeftArea))and (DateTimePicker1.Date < StrToDate(RightArea)) then
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select * from YearHaoCai where nian='+IntToStr(nian)+' and class='''+
clclass+''' and cailiaoming='''+ComboBox2.Text+'''');
Query1.Prepared;
Query1.Open;
if Not Query1.Eof then //YearHaoCai中有记录
begin
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('Select * from YearDataCache where class='''+clclass+''' and cailiaoming='''+
ComboBox2.Text+'''');
Query2.Prepared;
Query2.Open;
if Not Query2.Eof then //YearDataCache存在材料的记录
begin
kucunshu := Query2.FieldByName('kucunshu').AsString;
kucunjine := Query2.FieldByName('kucunjine').AsString;
rukushu := Query2.FieldByName('rukushu').AsString;
rukujine := Query2.FieldByName('rukujine').AsString;
chukushu := Query2.FieldByName('chukushu').AsString;
chukujine := Query2.FieldByName('chukujine').AsString;
chukushu := FloatToStr(StrToFloat(chukushu)+StrToFloat(Edit3.Text));
chukujine := FloatToStr(StrToFloat(chukujine)+StrToFloat(Edit4.Text));
jiecunshu := FloatToStr(StrToFloat(kucunshu)+StrToFloat(rukushu)-StrToFloat(chukushu));
jiecunjine := FloatToStr(StrToFloat(kucunjine)+StrToFloat(rukujine)-StrToFloat(chukujine));
Query2.Close;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -