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

📄 saleterminal.~pas

📁 是一款针对啤酒行业的销售进销存管理系统,包括基本的进货,销售,库存
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
   m_code,m_rule,m_capa,m_city:string;
   i:integer;
   strSum:double;
begin
      ///查找库存数量///
     m_code:=listview1.Selected.SubItems.Strings[0];
     m_rule:=listview1.Selected.SubItems.Strings[2];
     m_capa:= listview1.Selected.SubItems.Strings[3];
     m_city:=trim(combobox2.Text);
     strsql:='SELECT *  FROM  storeTable  where code="'+m_code+'" and  rule="'+m_rule+'" and  capacity="'+m_capa+'"';
     m_storeNum:=getFieldValueOfInt(query1,strsql,'storenum');
     dbgrid.Cells[dbgrid.Col+0,dbgrid.row]:=listview1.Selected.SubItems.Strings[0];
     dbgrid.Cells[dbgrid.Col+1,dbgrid.row]:=listview1.Selected.SubItems.Strings[1];
     dbgrid.Cells[dbgrid.Col+2,dbgrid.row]:=listview1.Selected.SubItems.Strings[2];
     dbgrid.Cells[dbgrid.Col+3,dbgrid.row]:=listview1.Selected.SubItems.Strings[3];
     dbgrid.Cells[dbgrid.Col+4,dbgrid.row]:=listview1.Selected.SubItems.Strings[4];
     dbgrid.Cells[dbgrid.Col+5,dbgrid.row]:=listview1.Selected.SubItems.Strings[6];
     Dbgrid.Cells[dbgrid.Col+6,dbgrid.Row]:='1';///数量箱//listview1.Selected.SubItems.Strings[6];
     Dbgrid.Cells[dbgrid.Col+7,dbgrid.Row]:='0';///数量瓶
     dbgrid.Cells[dbgrid.Col+8,dbgrid.Row]:=IntTostr(strToint(Dbgrid.Cells[dbgrid.Col+6,dbgrid.Row])*strToInt(Dbgrid.Cells[dbgrid.Col+5,dbgrid.Row]));
     dbgrid.Cells[dbgrid.Col+9,dbgrid.Row]:=IntToStr(m_storeNum-strToInt(Dbgrid.Cells[dbgrid.Col+6,dbgrid.Row]));
     dbgrid.col:=dbgrid.Col+6;
     dbgrid.Cells[13,dbgrid.Row]:='0';
     dbgrid.Cells[14,dbgrid.Row]:='0';
     strSum:=0;
       ////计算总金额/////
          for i:=1 to dbgrid.rowcount-2 do
          begin
              strSum:=strSum+strToFloat(dbgrid.Cells[10,i]);
          end;
          edit2.Text:=FloatTostr(strSum);
     listview1.Visible:=false;
end;

procedure Tsale_Terminal.DBgridKeyPress(Sender: TObject; var Key: Char);
var
   strSum:double;
   i:integer;
   storeNum1:integer;
   storeSql:string;
begin
       strSum:=0;
    if key=#13 then
    begin
     if dbgrid.col=8 then
       begin
          ///按回车键时使金额,库存数变化////
          dbgrid.Cells[10,dbgrid.row]:=IntTostr(strToint(Dbgrid.Cells[8,dbgrid.Row])*strToInt(Dbgrid.Cells[7,dbgrid.Row]));
          dbgrid.Cells[11,dbgrid.row]:=IntToStr(m_storenum-strToInt(dbgrid.Cells[8,dbgrid.row]));
          ////计算总金额/////
          for i:=1 to dbgrid.rowcount-2 do
          begin
              strSum:=strSum+strToFloat(dbgrid.Cells[10,i]);
          end;
          edit2.Text:=FloatTostr(strSum);
       end;
       if dbgrid.col=10 then
       begin
          ///检查库存数量是否充足////////
          storeSql:='SELECT * FROM  storeTable  where  code="'+dbgrid.cells[2,dbgrid.row]+'"  and  rule="'+dbgrid.cells[4,dbgrid.row]+'"  and  capacity="'+dbgrid.cells[5,dbgrid.row]+'"  and  city="'+trim(combobox2.text)+'"';
          storeNum1:=getFieldValueOfInt(query1,storesql,'storenum');
          if strToInt(dbgrid.Cells[8,dbgrid.row])>storeNum1 then
          begin
             ShowMessage('库存不足,请重新输入...');
             exit;
          end;
          ///按回车键时使金额,库存数变化////
          dbgrid.Cells[10,dbgrid.row]:=IntTostr(strToint(Dbgrid.Cells[8,dbgrid.Row])*strToInt(Dbgrid.Cells[9,dbgrid.Row]));
          dbgrid.Cells[11,dbgrid.row]:=IntToStr(m_storenum-strToInt(dbgrid.Cells[9,dbgrid.row]));
          ////计算总金额/////
          for i:=1 to dbgrid.rowcount-2 do
          begin
              strSum:=strSum+strToFloat(dbgrid.Cells[10,i]);
          end;
          edit2.Text:=FloatTostr(strSum);
       end;
       
       if DBgrid.col=13 then
       begin
          ///检查库存数量是否充足////////
          storeSql:='SELECT * FROM  storeTable  where  code="'+dbgrid.cells[2,dbgrid.row]+'"  and  rule="'+dbgrid.cells[4,dbgrid.row]+'"  and  capacity="'+dbgrid.cells[5,dbgrid.row]+'"  and  city="'+trim(combobox2.text)+'"';
          storeNum1:=getFieldValueOfInt(query1,storesql,'storenum');
          if strToInt(dbgrid.Cells[8,dbgrid.row])>storeNum1 then
          begin
             ShowMessage('库存不足,请重新输入...');
             exit;
          end;
          dbgrid.Cells[11,dbgrid.row]:=FloatToStr(strToFloat(dbgrid.Cells[11,dbgrid.row])-strToFloat(dbgrid.Cells[13,dbgrid.row]))
       end;
    end;
end;

procedure Tsale_Terminal.ComboBox3Click(Sender: TObject);
begin
     dbgrid.Cells[12,dbgrid.Row]:=trim(combobox3.Text);
      combobox3.Visible:=false;
end;

procedure Tsale_Terminal.PicButton1Click(Sender: TObject);
var
  strSql,strInsert,strInsert1:string;
  i:integer;
  storeSql:string;
  strUpdate:string;
  storeNum1:double;
  storeNumP1,storeNumP2:double;
begin
     strSql:='SELECT *  FROM  sale_TraderTable  where  salecode="'+trim(edit1.Text)+'"';
   if messagedlg('确定是否存盘?',mtconfirmation,[mbyes,mbno],0)=mryes then
   begin
      if (isRunSql(query1,strSql)) then
      begin
         ShowMessage('此单据的记录已经存在!');
      end
      else
         begin
              ////处理saleTable表中的记录
               strInsert:='INSERT INTO sale_TraderTable(salecode,saleDate,salesum,checker,other,city) VALUES("'+trim(edit1.text)+'","'+DateTostr(JHdate.Date)+'",'+trim(edit2.Text)+',"'+trim(combobox1.Text)+'","'+trim(edit3.Text)+'","'+trim(combobox2.Text)+'")';
               //ShowMessage(strInsert);
               RunNonSql(query1,strInsert);
               ///处理outTable表中的记录
               for i:=1 to dbgrid.rowcount-2 do
               begin
                   if dbgrid.Cells[0,i]<>'' then
                   begin
                      strInsert1:='INSERT INTO out_TraderTable(salecode,traderName,areaName,productCode,productName,rule,capacity,unit,price,Amount,AmountP,saleSum,presentWay,PresentNum,PresentSum) VALUES("'+trim(edit1.Text)+'","'+dbgrid.Cells[0,i]+'","'+dbgrid.Cells[1,i]+'","'+dbgrid.Cells[2,i]+'","'+dbgrid.Cells[3,i]+'","'+dbgrid.Cells[4,i]+'","'+dbgrid.Cells[5,i]+'","'+dbgrid.Cells[6,i]+'",'+dbgrid.Cells[7,i]+','+dbgrid.Cells[8,i]+','+dbgrid.Cells[9,i]+','+dbgrid.Cells[10,i]+',"'+dbgrid.Cells[12,i]+'",'+dbgrid.Cells[13,i]+','+dbgrid.Cells[14,i]+')';
                      //ShowMessage(strInsert1);
                      RunNonSql(query1,strInsert1);
                   end;
               end;///for 结束
               ///处理库存数量///
               ////使库存表变化///
               for i:=1 to dbgrid.rowcount-2 do
               begin
                  storeSql:='SELECT * FROM  storeTable  where  code="'+dbgrid.cells[2,i]+'"  and  rule="'+dbgrid.cells[4,i]+'"  and  capacity="'+dbgrid.cells[5,i]+'"  and  city="'+trim(combobox2.text)+'"';
                  //showmessage(storeSql);
                  if isRunSql(query1,storeSql) then ///如果存在,则累减//
                  begin
                     storeNum1:=getFieldValueOfInt(query1,storesql,'storenum');
                     storeNumP1:=getFieldValueOfInt(query1,storesql,'storeNumP');
                     storeNumP2:=storeNumP1-StrToFloat(dbgrid.cells[9,i]);
                     strUpdate:='UPDATE storeTable  SET  storeNum='+dbgrid.cells[11,i]+',storeNumP='+FloatToStr(storeNumP2)+'    where  code="'+dbgrid.cells[2,i]+'"  and  rule="'+dbgrid.cells[4,i]+'"  and  capacity="'+dbgrid.cells[5,i]+'"  and  city="'+trim(combobox2.text)+'"';
                     RunNonSql(query1,strUpdate);
                  end;
                  //else
                  //Showmessage('库存数量不足或无库存');
               end;
         end;///判断记录是否存在if结束///
         for i:=1 to dbgrid.rowcount-2 do
         begin
           dbgrid.Cells[0,i]:='';
           dbgrid.Cells[1,i]:='';
           dbgrid.Cells[2,i]:='';
           dbgrid.Cells[3,i]:='';
           dbgrid.Cells[4,i]:='';
           dbgrid.Cells[5,i]:='';
           dbgrid.Cells[6,i]:='';
           dbgrid.Cells[7,i]:='';
           dbgrid.Cells[8,i]:='';
           dbgrid.Cells[9,i]:='';
           dbgrid.Cells[10,i]:='';
           dbgrid.Cells[11,i]:='';
           dbgrid.Cells[12,i]:='';
           dbgrid.Cells[13,i]:='';
           dbgrid.Cells[14,i]:='';
        end;
        dbgrid.RowCount:=2; 
        edit1.Text:='XST'+trim(FloatTostr(strToFloat(formatdatetime('yyyymmdd',now)+'0000')+GetrsCount(query1,'sale_TraderTable')+1));
    end;///确定存盘if结束////
end;

procedure Tsale_Terminal.FormShow(Sender: TObject);
var
  i:integer;
begin
      for i:=1 to dbgrid.rowcount-2 do
     begin
         dbgrid.Cells[0,i]:='';
         dbgrid.Cells[1,i]:='';
         dbgrid.Cells[2,i]:='';
         dbgrid.Cells[3,i]:='';
         dbgrid.Cells[4,i]:='';
         dbgrid.Cells[5,i]:='';
         dbgrid.Cells[6,i]:='';
         dbgrid.Cells[7,i]:='';
         dbgrid.Cells[8,i]:='';
         dbgrid.Cells[9,i]:='';
         dbgrid.Cells[10,i]:='';
         dbgrid.Cells[11,i]:='';
         dbgrid.Cells[12,i]:='';
         dbgrid.Cells[13,i]:='';
         dbgrid.Cells[14,i]:='';
     end;
     edit1.Text:='XST'+trim(FloatTostr(strToFloat(formatdatetime('yyyymmdd',now)+'0000')+GetrsCount(query1,'saleTable')+1));
     dbgrid.RowCount:=2;
end;

end.

⌨️ 快捷键说明

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