⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit9.pas

📁 材料管理系统
💻 PAS
📖 第 1 页 / 共 4 页
字号:
        Query2.SQL.Clear;      //更新YearDataCache
        Query2.SQL.Add('Update YearDataCache 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;       //更新YearHaoCai
        Query2.SQL.Add('Update YearHaoCai set chukushu='''+Format('%.2f',[StrToFloat(chukushu)])+''',chukujine='''+
          Format('%.2f',[StrToFloat(chukujine)])+''',jiecunshu='''+Format('%.2f',[StrToFloat(jiecunshu)])+''',jiecunjine='''+
          Format('%.2f',[StrToFloat(jiecunjine)])+''' where nian='+IntToStr(nian)+' and class='''+clclass+
          ''' and cailiaoming='''+ComboBox2.Text+'''');
        Query2.ExecSQL;
      end
      else
      begin
        Application.MessageBox('不存在此材料的任何记录!Unit9,Line:800','系统提示',MB_OK);
        Application.Terminate;
      end;
    end
    else          //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      //有最近一次历史记录
      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;        //更新
        Query2.SQL.Add('Update YearDataCache 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)])+'''');
        Query2.ExecSQL;
        Query2.Close;
        Query2.SQL.Clear;         //插入记录
        Query2.SQL.Add('Insert into YearHaoCai 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)])+''','''+''+''','+IntToStr(nian)+')');
      end
      else         //YearDataCache中也没有记录
      begin
        Application.MessageBox('不存在此材料的任何数据!Unit9,Line:837','系统提示',MB_OK);
        Application.Terminate;
      end;
    end;
  end;
     {yyyy-mm-dd>yyyy-12-24}      //save into (nian+1)
  if DateTimePicker1.Date >(StrToDate(RightArea)-1) then
  begin
    Query1.Close;
    Query1.SQL.Clear;
    Query1.SQL.Add('Select * from YearHaoCai where nian='+IntToStr(nian+1)+' 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;
        Query2.SQL.Clear;      //更新YearDataCache
        Query2.SQL.Add('Update YearDataCache 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;       //更新YearHaoCai
        Query2.SQL.Add('Update YearHaoCai set chukushu='''+Format('%.2f',[StrToFloat(chukushu)])+''',chukujine='''+Format('%.2f',[StrToFloat(chukujine)])+
          ''',jiecunshu='''+Format('%.2f',[StrToFloat(jiecunshu)])+''',jiecunjine='''+Format('%.2f',[StrToFloat(jiecunjine)])+''' where nian='+IntToStr(nian+1)+
          ' and class='''+clclass+''' and cailiaoming='''+ComboBox2.Text+'''');
        Query2.ExecSQL;
      end
      else
      begin
        Application.MessageBox('不存在此材料的任何记录!Unit9,Line:885','系统提示',MB_OK);
        Application.Terminate;
      end;
    end
    else          //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      //有最近一次历史记录
      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;        //更新
        Query2.SQL.Add('Update YearDataCache 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)])+'''');
        Query2.ExecSQL;
        Query2.Close;
        Query2.SQL.Clear;         //插入记录
        Query2.SQL.Add('Insert into YearHaoCai 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)])+''','''+''+''','+IntToStr(nian+1)+')');
      end
      else         //YearDataCache中也没有记录
      begin
        Application.MessageBox('不存在此材料的任何数据!Unit9,Line:922','系统提示',MB_OK);
        Application.Terminate;
      end;
    end;
  end;
  //至于yyyy-mm-dd<yyyy-mm-25左区间应该不会发生
  if DateTimePicker1.Date < StrToDate(LeftArea) then
  begin
    Application.MessageBox('左区间发生,Unit9,Line:930','ERROR',MB_OK);
    Application.Terminate;
  end;
  Edit3.Clear;
  Edit4.Clear;
  ComboBox2Click(Frmcailiaochuku);
  end;
  except
    Application.MessageBox('系统错误!','ERROR',MB_OK OR MB_ICONERROR);
  end;
  FreeAndNil(Query1);
  FreeAndNil(Query2);
 {以下是处理完成后的刷新}
if clclass='外延片' then
begin
  with Frmmain.Querywyp do
  try
    Close;
    SQL.Clear;
    SQL.Add('select * from WeekHaoCai where class='''+ clclass +'''');
    Open;
  except
    Application.MessageBox('系统错误','ERROR',MB_OK OR MB_ICONSTOP);
  end;
end;
if clclass='劳保' then
begin
  with Frmmain.Querylb do
  try
    Close;
    SQL.Clear;
    SQL.Add('select * from WeekHaoCai where class='''+ clclass +'''');
    Open;
  except
    Application.MessageBox('系统错误','ERROR',MB_OK OR MB_ICONSTOP);
  end;
end;
if clclass='稀贵金属' then
begin
  with Frmmain.Queryxgjs do
  try
    Close;
    SQL.Clear;
    SQL.Add('select * from WeekHaoCai where class='''+ clclass +'''');
    Open;
  except
    Application.MessageBox('系统错误','ERROR',MB_OK OR MB_ICONSTOP);
  end;
end;
if clclass='化学试剂' then
begin
  with Frmmain.Queryhxsj do
  try
    Close;
    SQL.Clear;
    SQL.Add('select * from WeekHaoCai where class='''+ clclass +'''');
    Open;
  except
    Application.MessageBox('系统错误','ERROR',MB_OK OR MB_ICONSTOP);
  end;
end;
if clclass='低耗' then
begin
  with Frmmain.Querydh do
  try
    Close;
    SQL.Clear;
    SQL.Add('select * from WeekHaoCai where class='''+ clclass +'''');
    Open;
  except
    Application.MessageBox('系统错误','ERROR',MB_OK OR MB_ICONSTOP);
  end;
end;
if clclass='机电' then
begin
  with Frmmain.Queryjd do
  try
    Close;
    SQL.Clear;
    SQL.Add('select * from WeekHaoCai where class='''+ clclass +'''');
    Open;
  except
    Application.MessageBox('系统错误','ERROR',MB_OK OR MB_ICONSTOP);
  end;
end;

end;

//procedure Tfrmcailiaochuku.Edit3Change(Sender: TObject);
//var
//  CountPoint:integer;
//begin
//  CountPoint := CountPoint +1;
//  if CountPoint >2 then
//  begin
//    Application.MessageBox('输入了非法字符!','错误',MB_OK OR MB_ICONERROR);
//    Edit3.Clear;
//    exit;
//  end;
//
//end;

procedure Tfrmcailiaochuku.Edit3Exit(Sender: TObject);
var
  CountPoint:integer;
  i:integer;
begin
  CountPoint := 0;
  for i := 1 to length(trim(Edit3.Text)) do
  begin
    if copy(trim(Edit3.Text),i,1)='.' then
    begin
      CountPoint := CountPoint + 1;
      if CountPoint >=2 then
      begin
        Application.MessageBox('输入了非法字符!','错误',MB_OK OR MB_ICONERROR);
        Edit3.Clear;
      end;
    end;
  end;
end;

procedure Tfrmcailiaochuku.Edit3Change(Sender: TObject);
begin
  if StrToFloatDef(Trim(Edit3.Text),0)<= StrToFloatDef(Trim(Edit5.Text),0) then
    Edit4.Text := FloatToStr(StrToFloatDef(Edit2.Text,0)* StrToFloatDef(Edit3.Text,0))
  else
  begin
    MessageBox(frmcailiaochuku.Handle,'出库数量大于库存数量!','错误',MB_OK OR MB_ICONERROR);
    Edit3.Text := '';
    Exit;
  end;
end;

//procedure Tfrmcailiaochuku.ComboBox1Click(Sender: TObject);
//begin
//
//  showmessage(chukuSQL);
//end;

procedure Tfrmcailiaochuku.ComboBox1Click(Sender: TObject);
begin
  chukuSQL := '';
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -