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

📄 umakesales.pas

📁 是分布式粮库程序,是采用Delphi实现的
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  updatesalequery.ParamByName('salelistid').AsString :=salelistid;
  updatesalequery.ParamByName('saleid').AsString :=edit6.Text ;
  updatesalequery.ParamByName('datetime').AsDateTime :=datetimepicker2.Date;
  updatesalequery.ParamByName('unit_id').AsInteger :=dblookupcombobox2.KeyValue ;
  updatesalequery.ParamByName('reciever').AsString :=edit7.Text ;
  updatesalequery.ParamByName('memo').AsString :=memo1.Text ;
  updatesalequery.ParamByName('manager').AsString :=edit8.Text ;
  updatesalequery.ParamByName('clerk').AsString :=edit9.Text ;
  updatesalequery.ParamByName('operter').AsString :=edit10.Text ;

  updatesaleitemquery.ParamByName('salelistid').AsString :=edit6.text;
  updatesaleitemquery.ParamByName('saleitemlistid').AsString :=saleitemlistid;
  updatesaleitemquery.ParamByName('saleitemid').AsString :=edit6.Text+'_'+edit1.Text;
  updatesaleitemquery.ParamByName('food_type').AsString :=dblookupcombobox1.Text ;
  updatesaleitemquery.ParamByName('quantity').AsFloat :=strtofloat(edit2.Text) ;
  updatesaleitemquery.ParamByName('price').Asfloat :=strtofloat(edit3.Text) ;
  updatesaleitemquery.ParamByName('sitename').AsString :=kudiandblookupcombobox.Text ;
  updatesaleitemquery.ParamByName('depotname').AsString :=changkudblookupcombobox.Text ;
  updatesaleitemquery.ParamByName('foodposition').AsString :=huoweidblookupcombobox.Text ;
  updatesaleitemquery.ParamByName('remain').AsFloat :=strtofloat(edit2.Text);
  updatesaleitemquery.ParamByName('memo').AsString :=memo2.Text;

  try
  updatesalequery.ExecSQL ;
  updatesaleitemquery.ExecSQL ;
  except
  application.MessageBox('修改销售提单时出错!','系统错误',MB_OK+MB_ICONERROR);
  exit;
  end;
  end;

 if newnotice=3 then      //销售单细目输入
  begin
  if edit1.Text <> '' then
  begin
  newsaleitemquery.ParamByName('salelistid').AsString :=salelistid ;
  newsaleitemquery.ParamByName('saleitemid').AsString :=edit6.Text+'_'+edit1.Text ;
  newsaleitemquery.ParamByName('food_type').AsString :=dblookupcombobox1.Text ;
  newsaleitemquery.ParamByName('quantity').AsFloat :=strtofloat(edit2.Text) ;
  newsaleitemquery.ParamByName('price').AsFloat :=strtofloat(edit3.Text) ;
  newsaleitemquery.ParamByName('sitename').AsString :=kudiandblookupcombobox.Text ;
  newsaleitemquery.ParamByName('depotname').AsString :=changkudblookupcombobox.Text ;
  newsaleitemquery.ParamByName('foodposition').AsString :=huoweidblookupcombobox.Text ;
  newsaleitemquery.ParamByName('memo').AsString :=memo2.Text ;
  newsaleitemquery.ParamByName('remain').AsFloat :=strtofloat(edit2.Text);
  newsaleitemquery.ParamByName('status').AsInteger :=0;
  try
  newsaleitemquery.ExecSQL ;
  except
  application.MessageBox('新增销售提单时出错!','系统错误',MB_OK+MB_ICONERROR);
  exit;
  end;
  end;
  end;

 if newnotice=4 then    //销售单细目修改
  begin
  updatesaleitemquery.ParamByName('salelistid').AsString :=salelistid;
  updatesaleitemquery.ParamByName('saleitemlistid').AsString :=saleitemlistid;
  updatesaleitemquery.ParamByName('saleitemid').AsString :=edit6.Text +'_'+ edit1.Text;
  updatesaleitemquery.ParamByName('food_type').AsString :=dblookupcombobox1.Text ;
  updatesaleitemquery.ParamByName('quantity').AsFloat :=strtofloat(edit2.Text) ;
  updatesaleitemquery.ParamByName('price').Asfloat :=strtofloat(edit3.Text) ;
  updatesaleitemquery.ParamByName('sitename').AsString :=kudiandblookupcombobox.Text ;
  updatesaleitemquery.ParamByName('depotname').AsString :=changkudblookupcombobox.Text ;
  updatesaleitemquery.ParamByName('foodposition').AsString :=huoweidblookupcombobox.Text ;
  updatesaleitemquery.ParamByName('memo').AsString :=memo2.Text;
  updatesaleitemquery.ParamByName('remain').AsFloat :=strtofloat(edit2.Text);
  try
  updatesaleitemquery.ExecSQL ;
  except
  application.MessageBox('新增销售提单时出错!','系统错误',MB_OK+MB_ICONERROR);
  exit;
  end;
  end;

  salelistquery.Close;
  salelistquery.Open;
  saleitemlistquery.Close;
  saleitemlistquery.Open;
end;

procedure Tfmakesale.cancelBitBtnClick(Sender: TObject);
begin
  additemflag :=0;
  edit6.Enabled :=false;
  dblookupcombobox2.Enabled :=false;
  datetimepicker2.Enabled :=false;
  edit7.Enabled :=false;
  memo1.Enabled :=false;
  edit8.Enabled :=false;
  edit9.Enabled :=false;
  edit10.Enabled :=false;
  savebitbtn.Enabled :=false;
  cancelbitbtn.Enabled :=false;

  edit1.Enabled :=false;
  dblookupcombobox1.Enabled :=false;
  edit2.Enabled :=false;
  edit3.Enabled :=false;
  kudiandblookupcombobox.Enabled :=false;
  changkudblookupcombobox.Enabled :=false;
  huoweidblookupcombobox.Enabled :=false;
  memo2.Enabled :=false;

    additembitbtn.Enabled:=true;
    deleteitembitbtn.Enabled:=true;
    modifyitembitbtn.Enabled:=true;
    cancelitembitbtn.Enabled :=true;

    if newnotice=1 then
    begin
  edit6.Text :='';
  dblookupcombobox2.KeyValue :=null;
  datetimepicker2.DateTime  :=date;
  edit7.text :='';
  memo1.text :='';
  edit8.text :='';
  edit9.text :='';
  edit10.text :='';

  edit1.text :='';
  dblookupcombobox1.KeyValue :=null;
  edit2.text :='';
  edit3.text :='';
  kudiandblookupcombobox.KeyValue :=null;
  changkudblookupcombobox.KeyValue :=null;
  huoweidblookupcombobox.KeyValue :=null;
  memo2.Text :='';
   end
   else
    if newnotice=2 then
    begin
   salequery.Close;
   salequery.Open;
    end;

    salelistquery.Close;
    salelistquery.Open;
end;


procedure Tfmakesale.saleitemlistqueryAfterScroll(DataSet: TDataSet);
var sitemid:string;
begin
     additemflag :=0;
     
     salelistid:=dataset.fieldbyname('sale_id').AsString ;
     saleitemlistid:=dataset.fieldbyname('saleitem_id').AsString;
     saleitemquery.ParamByName('salelistid').AsString :=salelistid;
     saleitemquery.ParamByName('itemlistid').AsString :=saleitemlistid ;
     saleitemquery.Close;
     saleitemquery.Open;

    sitemid:=saleitemquery.fieldbyname('SALEITEM_ID').AsString;
    edit1.Text :=copy(sitemid ,pos('_',sitemid )+1,length(sitemid));

//    edit1.Text :=saleitemquery.fieldbyname('saleitem_id').AsString ;
     dblookupcombobox1.KeyValue :=saleitemquery.fieldbyname('food_type').AsString ;
     edit2.Text:=floattostr(saleitemquery.fieldbyname('quantity').AsFloat);
     edit3.Text:=floattostr(saleitemquery.fieldbyname('PRICE').AsFloat) ;
     kudiandblookupcombobox.KeyValue:=saleitemquery.fieldbyname('sitename').AsString ;
     changkudblookupcombobox.KeyValue :=saleitemquery.fieldbyname('depotname').AsString ;
     huoweidblookupcombobox.KeyValue :=saleitemquery.fieldbyname('foodposition').AsString ;
     memo2.Text:=saleitemquery.fieldbyname('memo').AsString ;
  //   edit3.Text:=saleitemquery.fieldbyname('price').AsString;

    if edit2.text='' then exit;
    if edit3.Text='' then exit
    else
    edit4.Text :=floattostr(strtofloat(edit2.Text)*strtofloat(edit3.Text));

    changkuquery.ParamByName('unit_id').AsInteger :=dblookupcombobox2.KeyValue ;
    changkuquery.ParamByName('site_name').AsString :=kudiandblookupcombobox.KeyValue ;
    changkuquery.Close;
    changkuquery.Open;
    huoweiquery.ParamByName('unit_id').AsInteger :=dblookupcombobox2.KeyValue ;
    huoweiquery.ParamByName('site_name').AsString :=kudiandblookupcombobox.KeyValue ;
    huoweiquery.ParamByName('depot_name').AsString :=changkudblookupcombobox.KeyValue ;
    huoweiquery.Close;
    huoweiquery.Open;

end;

procedure Tfmakesale.exitBitBtnClick(Sender: TObject);
begin
   close;
end;

procedure Tfmakesale.additemBitBtnClick(Sender: TObject);
begin
   newnotice:=3;
   savebitbtn.Enabled:=true;

 if additemflag=1 then
  begin
     if edit1.Text =''  then
       begin
       application.MessageBox('还没有填写细目编号!','请填写细目',MB_OK+MB_ICONEXCLAMATION);
       edit1.SetFocus;
       exit;
       end;
     if dblookupcombobox1.Text =''  then
       begin
       application.MessageBox('还没有填写货物名称!','请填写细目',MB_OK+MB_ICONEXCLAMATION);
       dblookupcombobox1.SetFocus;
       exit;
       end;
     if edit2.Text =''  then
       begin
       application.MessageBox('还没有填写货物数量!','请填写细目',MB_OK+MB_ICONEXCLAMATION);
       edit2.SetFocus;
       exit;
       end;
     if edit3.Text =''  then
       begin
       application.MessageBox('还没有填写货物单价!','请填写细目',MB_OK+MB_ICONEXCLAMATION);
       edit3.SetFocus;
       exit;
       end;

     newsaleitemquery.ParamByName('salelistid').AsString :=salelistid ;
     newsaleitemquery.ParamByName('saleitemid').AsString :=edit6.Text+'_'+edit1.Text ;
     newsaleitemquery.ParamByName('food_type').AsString :=dblookupcombobox1.Text ;
     newsaleitemquery.ParamByName('quantity').AsFloat :=strtofloat(edit2.Text) ;
     newsaleitemquery.ParamByName('price').AsFloat :=strtofloat(edit3.Text) ;
     newsaleitemquery.ParamByName('sitename').AsString :=kudiandblookupcombobox.Text ;
     newsaleitemquery.ParamByName('depotname').AsString :=changkudblookupcombobox.Text ;
     newsaleitemquery.ParamByName('foodposition').AsString :=huoweidblookupcombobox.Text ;
     newsaleitemquery.ParamByName('memo').AsString :=memo2.Text ;
     newsaleitemquery.ParamByName('remain').AsFloat :=strtofloat(edit2.Text);
     newsaleitemquery.ParamByName('status').AsInteger :=0;
     try
     newsaleitemquery.ExecSQL ;
     except
     application.MessageBox('新建销售提单细目时出错','系统错误',MB_OK+MB_ICONERROR);
     exit;
     end;
     saleitemlistquery.Close;
     saleitemlistquery.Open;
  end;
    edit1.Enabled :=true;
    dblookupcombobox1.Enabled :=true;
    edit2.Enabled :=true;
    edit3.Enabled :=true;
    kudiandblookupcombobox.Enabled :=true;
    memo2.Enabled :=true;

    edit1.Text :='';
    dblookupcombobox1.KeyValue :=null;
    edit2.Text :='';
    edit3.Text :='';
    kudiandblookupcombobox.KeyValue :=null;
    changkudblookupcombobox.KeyValue :=null;
    huoweidblookupcombobox.KeyValue :=null;
    memo2.Text :='';

    additemflag:=1;

end;

procedure Tfmakesale.deleteitemBitBtnClick(Sender: TObject);
begin
   additemflag:=0;
   if saleitemlistquery.IsEmpty then
    begin
    application.MessageBox('销售提单细目表中没有细目可供删除!','删除销售提单细目时出错',MB_OK+MB_ICONEXCLAMATION);
    Exit;
    end;
   if saleitemlistquery.RecordCount=1 then
    begin
    application.MessageBox('不能删除该销售提单的最后一条细目,你可以删除这条销售提单!','删除销售提单细目时出错',MB_OK+MB_ICONEXCLAMATION);
    Exit;
    end;
    
   if MessageDlg('确实要删除这项销售提单细目?',mtInformation,[mbYes,mbNo],0)=mrYes then
      begin
      dtmdl.Database1.StartTransaction;
      DeletesaleitemoneQuery.ParamByName('saleListId').AsString:=saleListId;
      DeletesaleitemoneQuery.ParamByName('ItemlistId').asstring:=saleItemlistId;
      try
      DeletesaleitemoneQuery.ExecSQL;
      except
      dtmdl.Database1.Rollback;
      Application.MessageBox('删除销售提单细目时出错!','系统错误',MB_OK+MB_ICONERROR);
      Exit;
      end;
      dtmdl.Database1.Commit;
      saleitemlistQuery.Close;
      saleitemlistQuery.Open;
   end;
end;

procedure Tfmakesale.modifyitemBitBtnClick(Sender: TObject);
begin
   newnotice:=4;    //修改销售提单细目
   savebitbtn.Enabled:=true;

   if not saleitemlistquery.IsEmpty then
   begin
   edit1.Enabled :=true;
   dblookupcombobox1.Enabled :=true;
   edit2.Enabled :=true;
   edit3.Enabled :=true;
   kudiandblookupcombobox.Enabled :=true;
   changkudblookupcombobox.Enabled :=true;
   huoweidblookupcombobox.Enabled :=true;
   memo2.Enabled :=true;
   end;
end;

procedure Tfmakesale.cancelitemBitBtnClick(Sender: TObject);
begin
   additemflag:=0;

   savebitbtn.Enabled :=false;
   edit1.Enabled :=false;
   dblookupcombobox1.Enabled :=false;
   edit2.Enabled :=false;
   edit3.Enabled :=false;
   kudiandblookupcombobox.Enabled :=false;
   changkudblookupcombobox.Enabled :=false;
   huoweidblookupcombobox.Enabled :=false;
   memo2.Enabled :=false;

   saleitemlistquery.Close;
   saleitemlistquery.Open;
end;

procedure Tfmakesale.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
    if (Key<>'0') and (Key<>'1') and (Key<>'2') and (Key<>'3') and (Key<>'4')and (Key<>'.') and
        (Key<>'5') and (Key<>'6') and (Key<>'7') and (Key<>'8') and (Key<>'9') and (ord(Key)<>8)   then
       Key:=chr(0);
end;

procedure Tfmakesale.Edit3KeyPress(Sender: TObject; var Key: Char);
begin
    if (Key<>'0') and (Key<>'1') and (Key<>'2') and (Key<>'3') and (Key<>'4')and (Key<>'.') and
        (Key<>'5') and (Key<>'6') and (Key<>'7') and (Key<>'8') and (Key<>'9') and (ord(Key)<>8)   then
       Key:=chr(0);
end;

procedure Tfmakesale.Edit2Exit(Sender: TObject);
begin
   if edit2.text='' then exit;
   if edit3.Text='' then exit
   else
     edit4.Text :=floattostr(strtofloat(edit2.Text)*strtofloat(edit3.Text));
end;

procedure Tfmakesale.Edit3Exit(Sender: TObject);
begin
   if edit2.text='' then exit;
   if edit3.Text='' then exit
   else
     edit4.Text :=floattostr(strtofloat(edit2.Text)*strtofloat(edit3.Text));
end;

procedure Tfmakesale.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  ConvertKey(ActiveControl, HANDLE, Key, Shift);
end;

procedure Tfmakesale.DBLookupComboBox2CloseUp(Sender: TObject);
begin
       if  dblookupcombobox2.Text <>'' then
       begin
       kudianquery.ParamByName('unit_id').AsInteger :=dblookupcombobox2.KeyValue ;
       kudianquery.Close;
       kudianquery.Open;
       kudiandblookupcombobox.Enabled :=true;
       changkuquery.Close;
       huoweiquery.Close;
       changkudblookupcombobox.Enabled :=false;
       huoweidblookupcombobox.Enabled :=false;
       end;
end;

procedure Tfmakesale.kudianDBLookupComboBoxCloseUp(Sender: TObject);
begin
       if  kudiandblookupcombobox.Text <>'' then
       begin
       changkuquery.ParamByName('unit_id').AsInteger :=dblookupcombobox2.KeyValue ;
       changkuquery.ParamByName('site_name').AsString :=kudiandblookupcombobox.KeyValue ;
       changkuquery.Close;
       changkuquery.Open;
       changkudblookupcombobox.Enabled :=true;

       huoweiquery.Close;
       huoweidblookupcombobox.Enabled :=false;
       end;
end;

procedure Tfmakesale.changkuDBLookupComboBoxCloseUp(Sender: TObject);
begin
       if  changkudblookupcombobox.Text <>'' then
       begin
       huoweiquery.ParamByName('unit_id').AsInteger :=dblookupcombobox2.KeyValue ;
       huoweiquery.ParamByName('site_name').AsString :=kudiandblookupcombobox.KeyValue ;
       huoweiquery.ParamByName('depot_name').AsString :=changkudblookupcombobox.KeyValue ;
       huoweiquery.Close;
       huoweiquery.Open;
       huoweidblookupcombobox.Enabled :=true;
       end;
end;


procedure Tfmakesale.BitBtnallClick(Sender: TObject);
begin
     salelistquery.Close;
     salelistquery.SQL.Clear ;
     salelistquery.SQL.Add(salelistquerystr);
     salelistquery.SQL.Add(' order by datetime desc' );
     salelistquery.Open;
end;

procedure Tfmakesale.BitBtnnoneClick(Sender: TObject);
begin
     salelistquery.Close;
     salelistquery.SQL.Clear ;
     salelistquery.SQL.Add(salelistquerystr);
     salelistquery.SQL.Add(' where status=0 ');
     salelistquery.SQL.Add(' order by datetime desc' );
     salelistquery.Open;
end;

procedure Tfmakesale.BitBtnfewClick(Sender: TObject);
begin
     salelistquery.Close;
     salelistquery.SQL.Clear ;
     salelistquery.SQL.Add(salelistquerystr);
     salelistquery.SQL.Add(' where status=1 ');
     salelistquery.SQL.Add(' order by datetime desc' );
     salelistquery.Open;
end;

procedure Tfmakesale.BitBtndoneClick(Sender: TObject);
begin
     salelistquery.Close;
     salelistquery.SQL.Clear ;
     salelistquery.SQL.Add(salelistquerystr);
     salelistquery.SQL.Add(' where status=2 ');
     salelistquery.SQL.Add(' order by datetime desc' );
     salelistquery.Open;
end;

end.

⌨️ 快捷键说明

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