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

📄 price_attemper.pas

📁 delphi的一个开发实例
💻 PAS
📖 第 1 页 / 共 4 页
字号:
unit price_attemper;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Grids,  StdCtrls, Buttons, XPMenu;

type
  Tfrm_price_attemper = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    Label1: TLabel;
    Panel4: TPanel;
    Edit1: TLabeledEdit;
    GroupBox1: TGroupBox;
    SpeedButton1: TSpeedButton;
    SpeedButton5: TSpeedButton;
    SpeedButton7: TSpeedButton;
    SpeedButton8: TSpeedButton;
    Edit_FStorage_Name: TLabeledEdit;
    Edit_SStorage_Name: TLabeledEdit;
    Edit7: TLabeledEdit;
    Edit8: TLabeledEdit;
    Edit9: TLabeledEdit;
    Edit10: TLabeledEdit;
    Edit2: TLabeledEdit;
    Panel5: TPanel;
    Panel6: TPanel;
    Panel8: TPanel;
    Label2: TLabel;
    Label3: TLabel;
    XPMenu1: TXPMenu;
    Panel9: TPanel;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    P_check: TPanel;
    P1: TPanel;
    Cmd1: TSpeedButton;
    L1: TLabel;
    P2: TPanel;
    Cmd2: TSpeedButton;
    L2: TLabel;
    P3: TPanel;
    Cmd3: TSpeedButton;
    L3: TLabel;
    P4: TPanel;
    L4: TLabel;
    Cmd4: TSpeedButton;
    P5: TPanel;
    L5: TLabel;
    Cmd5: TSpeedButton;
    Panel10: TPanel;
    Panel11: TPanel;
    Cmd_Delete: TSpeedButton;
    Cmd_Add: TSpeedButton;
    StringGrid1: TStringGrid;
    XPMenu2: TXPMenu;
    Edit4: TLabeledEdit;
    Edit3: TLabeledEdit;
    SpeedButton6: TSpeedButton;
    Edit_SShop_Name: TLabeledEdit;
    Edit_FShop_Name: TLabeledEdit;
    SpeedButton9: TSpeedButton;
    Edit5: TLabeledEdit;
    Edit6: TLabeledEdit;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure Edit1DblClick(Sender: TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure Edit8KeyPress(Sender: TObject; var Key: Char);
    procedure SpeedButton7Click(Sender: TObject);
    procedure Edit8DblClick(Sender: TObject);
    procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    procedure StringGrid1DblClick(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton5Click(Sender: TObject);
    procedure SpeedButton9Click(Sender: TObject);
    procedure SpeedButton6Click(Sender: TObject);
    procedure SpeedButton8Click(Sender: TObject);
    procedure Cmd_AddClick(Sender: TObject);
    procedure Cmd_DeleteClick(Sender: TObject);
    procedure Cmd1Click(Sender: TObject);
    procedure Cmd2Click(Sender: TObject);
    procedure Cmd3Click(Sender: TObject);
    procedure Cmd4Click(Sender: TObject);
    procedure Cmd5Click(Sender: TObject);
  private
    { Private declarations }
  public
     procedure Stock_States_Total;
    { Public declarations }
  end;

var
  frm_price_attemper: Tfrm_price_attemper;
  Total_Count,iColcount,icount,i,k:integer;
  tt,yy,temppos:integer;
  Pcol,Prow:integer;
  ss,tempstr:String;
  Check_Flag:string;
  Flag_Str:Boolean; //捕获错误标志位
implementation

uses func, Public_Don, Data, Goods_Check, Storage_Select, ChildShop_Select,
  Login_Man;

{$R *.dfm}
//自定义库存统计过程
procedure Tfrm_Price_attemper.Stock_States_Total;
var
    Total_amount,Residue_amount:String;//库存总数量,剩余数量
    exceed_Amount,Go_Amount:String;//出库,入库数量
    exceed_Float,Go_Float:String;//出库,入库总数量
    i:Integer;
begin
    Flag_Str:=True;
    try
        for i:=1 to StringGrid1.RowCount-1 do
        begin
            with frm_data.ClientDataSet4 do
            begin
                Close;
                CommandText:='';
                CommandText:='Select * from [Stock_states] where Storage_NO='''+Trim(Edit3.Text)+''' and Shop_No='''+Trim(Edit5.Text)+''' and Goods_No='''+Trim(StringGrid1.Cells[1,i])+'''';
                try
                    Open;
                    if frm_data.ClientDataSet4.RecordCount>0 then //如果库存存在该商品
                    begin
                        Total_amount:=frm_data.ClientDataSet4.FieldByName('Stock_amount').AsVariant;  //统计总的数量
                        exceed_Float:=frm_data.ClientDataSet4.FieldByName('Out_amount').AsVariant;  //统计总的出库数量
                        exceed_Amount:=FloatToStr(StrToFloat(exceed_Float)+StrToFloat(StringGrid1.Cells[5,i]));//统计本次后总的出库数量

                        Residue_amount:=FloatToStr(StrToFloat(Total_amount)-StrToFloat(StringGrid1.Cells[5,i])); //出库后的总数量
                        if StrToFloat(Residue_amount)<0 then
                        begin
                            Application.MessageBox('错误操作!该仓库该【商品数量】小于你所需要配送的【数量】,请确认!',Pchar(Application.Title),Mb_ICONwarning);
                            Flag_Str:=False;
                            Exit;
                        end
                        else
                        begin
                            with frm_data.ClientDataSet4 do
                            begin
                                Close;
                                CommandText:='';
                                CommandText:='Update [Stock_states] set Out_amount='''+Trim(exceed_Amount)+''' where Storage_NO='''+Trim(Edit3.Text)+''' and Shop_No='''+Trim(Edit5.Text)+''' and Goods_No='''+Trim(StringGrid1.Cells[1,i])+'''';
                                try
                                    ExecUte;
                                    try
                                        with frm_data.ClientDataSet4 do
                                        begin
                                            Close;
                                            CommandText:='';
                                            CommandText:='Select * from [Stock_states] where Storage_NO='''+Trim(Edit4.Text)+''' and Shop_No='''+Trim(Edit6.Text)+''' and Goods_No='''+Trim(StringGrid1.Cells[1,i])+'''';
                                            try
                                                Open;
                                                if frm_data.ClientDataSet4.RecordCount>0 then  //如果收货仓库存在同种商品
                                                begin
                                                    Go_Float:=frm_data.ClientDataSet4.FieldByName('IN_amount').AsVariant;  //统计总的入库数量
                                                    Go_Amount:=FloatToStr(StrToFloat(Go_Float)+StrToFloat(StringGrid1.Cells[5,i]));//统计本次后总的入库数量
                                                    try
                                                        with frm_data.ClientDataSet4 do
                                                        begin
                                                            Close;
                                                            CommandText:='';
                                                            CommandText:='Update [Stock_states] set IN_amount='''+Trim(Go_Amount)+''' where Storage_NO='''+Trim(Edit4.Text)+''' and Shop_No='''+Trim(Edit6.Text)+''' and Goods_No='''+Trim(StringGrid1.Cells[1,i])+'''';
                                                            try
                                                                Execute;
                                                            except
                                                                Flag_Str:=False;
                                                                Application.MessageBox('系统错误!在打开【库存状况表】时修改【收货仓库库存】时出现了错误,请确认!',Pchar(Application.Title),Mb_ICONwarning);
                                                                Exit;
                                                            end;
                                                        end;
                                                    except
                                                        Flag_Str:=False;
                                                        Application.MessageBox('系统错误!请确认!',Pchar(Application.Title),Mb_ICONwarning);
                                                        Exit;
                                                    end;
                                                end;
                                                if frm_data.ClientDataSet4.RecordCount<=0 then  //如果收货仓库不存在同种商品
                                                begin
                                                    Go_Amount:=FloatToStr(StrToFloat(StringGrid1.Cells[5,i]));//统计本次后总的入库数量
                                                    try
                                                        with frm_data.ClientDataSet4 do
                                                        begin
                                                            Close;
                                                            CommandText:='';
                                                            CommandText:='Update [Stock_states] set IN_amount='''+Trim(Go_Amount)+''' where Storage_NO='''+Trim(Edit4.Text)+''' and Shop_No='''+Trim(Edit6.Text)+''' and Goods_No='''+Trim(StringGrid1.Cells[1,i])+'''';
                                                            try
                                                                Execute;
                                                            except
                                                                Flag_Str:=False;
                                                                Application.MessageBox('系统错误!在打开【库存状况表】时修改【收货仓库库存】时出现了错误,请确认!',Pchar(Application.Title),Mb_ICONwarning);
                                                                Exit;
                                                            end;
                                                        end;
                                                    except
                                                        Flag_Str:=False;
                                                        Application.MessageBox('系统错误!请确认!',Pchar(Application.Title),Mb_ICONwarning);
                                                        Exit;
                                                    end;
                                                end;
                                            except
                                                Flag_Str:=False;
                                                Application.MessageBox('系统错误!在打开【库存状况表】时出现了连接不上的错误,请确认!',Pchar(Application.Title),Mb_ICONwarning);
                                                Exit;
                                            end;
                                        end;
                                    except
                                        Flag_Str:=False;
                                        Application.MessageBox('系统错误!在打开【库存状况表】时修改【发货仓库库存】时出现了错误,请确认!',Pchar(Application.Title),Mb_ICONwarning);
                                        Exit;
                                    end;
                                except
                                    Flag_Str:=False;
                                    Application.MessageBox('系统错误!在打开【库存状况表】时出现了错误,请确认!',Pchar(Application.Title),Mb_ICONwarning);
                                    Exit;
                                end;
                            end;
                        end;
                    end;
                except
                    Flag_Str:=False;
                    Application.MessageBox('系统错误!在打开数据库时出现了数据库连接不上,请确认!',Pchar(Application.Title),Mb_ICONwarning);
                    Exit;
                end;
            end;
        end;
    except
        Flag_Str:=False;
        Application.MessageBox('修改仓库库存时循环操作出错!请确认!',Pchar(Application.Title),Mb_ICONwarning);
        Exit;
    end;
end;

procedure Tfrm_price_attemper.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
    frm_data.ClientDataSet_Add.Active:=False;
    frm_data.ClientDataSet_Add.Close;
    frm_data.ClientDataSet4.Active:=False;
    frm_data.ClientDataSet4.Close;
    Action:=Cafree;
end;

procedure Tfrm_price_attemper.FormShow(Sender: TObject);
begin
    frm_price_attemper.Left:=170 * longint(Screen.Width) div 1024;
    frm_price_attemper.Top:=40 * longint(Screen.Height) div 768;
    frm_price_attemper.Width:=850 * longint(Screen.Width) div 1024;
    frm_price_attemper.Height:=690 * longint(Screen.Height) div 768;
    if Public_Do='Storage_price_attemper' then
    begin
        P_check.Visible:=False;
        iColcount:=StringGrid1.ColCount-1; //需要的填充数据的网络表格的列数
        StringGrid1.RowCount:=2;  StringGrid1.ColCount:=28;
        Total_Count:=StringGrid1.RowCount;
        StringGrid1.ColWidths[0]:=40;   StringGrid1.ColWidths[1]:=150;  StringGrid1.ColWidths[2]:=150;
        StringGrid1.ColWidths[3]:=100;  StringGrid1.ColWidths[4]:=60;  StringGrid1.ColWidths[5]:=80;
        StringGrid1.ColWidths[6]:=150;   StringGrid1.ColWidths[7]:=80;   StringGrid1.ColWidths[8]:=100;
        StringGrid1.ColWidths[9]:=50;   StringGrid1.ColWidths[10]:=100; StringGrid1.ColWidths[11]:=100;
        StringGrid1.ColWidths[12]:=50;  StringGrid1.ColWidths[13]:=150; StringGrid1.ColWidths[14]:=150;
        StringGrid1.ColWidths[15]:=100; StringGrid1.ColWidths[16]:=100; StringGrid1.ColWidths[17]:=150;
        StringGrid1.ColWidths[18]:=50;  StringGrid1.ColWidths[19]:=80;  StringGrid1.ColWidths[20]:=100;
        StringGrid1.ColWidths[21]:=50;  StringGrid1.ColWidths[22]:=100; StringGrid1.ColWidths[23]:=100;
        StringGrid1.ColWidths[24]:=50;  StringGrid1.ColWidths[25]:=150;
        StringGrid1.Cells[0,0]:='行号';             StringGrid1.Cells[1,0]:='商品编号';
        StringGrid1.Cells[2,0]:='商品名称';         StringGrid1.Cells[3,0]:='批号';
        StringGrid1.Cells[4,0]:='基本单位';         StringGrid1.Cells[5,0]:='数量';
        StringGrid1.Cells[6,0]:='调拨说明';         StringGrid1.Cells[7,0]:='单价';
        StringGrid1.Cells[8,0]:='金额';             StringGrid1.Cells[9,0]:='折扣';
        StringGrid1.Cells[10,0]:='折后单价';        StringGrid1.Cells[11,0]:='合计金额';
        StringGrid1.Cells[12,0]:='税率';            StringGrid1.Cells[13,0]:='含税单价';
        StringGrid1.Cells[14,0]:='税后合计';        StringGrid1.Cells[15,0]:='质量状况';
        StringGrid1.Cells[16,0]:='类别名称';        StringGrid1.Cells[17,0]:='品牌名称';
        StringGrid1.Cells[18,0]:='品种名称';        StringGrid1.Cells[19,0]:='规格型号';
        StringGrid1.Cells[20,0]:='球面度数';        StringGrid1.Cells[21,0]:='柱面度数';

⌨️ 快捷键说明

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