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

📄 storage_damage.pas

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

interface

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

type
  Tfrm_Storage_damage = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    Cmd_Cancel: TSpeedButton;
    Panel3: TPanel;
    Label1: TLabel;
    Panel4: TPanel;
    Edit1: TLabeledEdit;
    GroupBox1: TGroupBox;
    Cmd_Storage: TSpeedButton;
    Cmd_ZD: TSpeedButton;
    Cmd_Childshop: TSpeedButton;
    Cmd_Ren: TSpeedButton;
    Edit_Storage_Name: TLabeledEdit;
    Edit4: TLabeledEdit;
    Edit5: TLabeledEdit;
    Edit6: TLabeledEdit;
    Edit7: TLabeledEdit;
    Edit8: TLabeledEdit;
    Edit2: TLabeledEdit;
    Panel5: TPanel;
    Panel6: TPanel;
    Panel8: TPanel;
    Label2: TLabel;
    Label3: TLabel;
    XPMenu1: TXPMenu;
    Panel7: TPanel;
    Panel9: TPanel;
    Cmd_Delete: TSpeedButton;
    Cmd_Add: TSpeedButton;
    StringGrid1: TStringGrid;
    Edit3: TEdit;
    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;
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Cmd_CancelClick(Sender: TObject);
    procedure Cmd_StorageClick(Sender: TObject);
    procedure Cmd_ChildshopClick(Sender: TObject);
    procedure Edit1DblClick(Sender: TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure Edit6KeyPress(Sender: TObject; var Key: Char);
    procedure Edit6DblClick(Sender: TObject);
    procedure Cmd_AddClick(Sender: TObject);
    procedure Cmd_DeleteClick(Sender: TObject);
    procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    procedure StringGrid1DblClick(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 }
    procedure Stock_States_Total; //统计库存过程
  public
    { Public declarations }
  end;

var
  frm_Storage_damage: Tfrm_Storage_damage;
  iColcount,Total_Count:Integer;
  ss,tempstr:string;
  Pcol,Prow:integer;
implementation

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

{$R *.dfm}

//自定义库存统计过程
procedure Tfrm_Storage_damage.Stock_States_Total;
var
    Total_amount,Total_money:String;
    i,j:Integer;
begin
    try
        for i:=1 to StringGrid1.RowCount-1 do
        begin
            with frm_data.ClientDataSet_Add do
            begin
                Close;
                CommandText:='';
                CommandText:='Select * from [V_Stock_States_View] where Storage_NO='''+Trim(Edit5.Text)+''' and Goods_NO='''+Trim(StringGrid1.Cells[1,i])+'''';
                try
                    open;
                    //如果该仓库存在同种商品
                    if frm_data.ClientDataSet_Add.RecordCount>0 then
                    begin
                        Total_amount:=frm_data.ClientDataSet_Add.FieldByName('Out_amount').AsVariant;  //统计总的数量
                        Total_money :=frm_data.ClientDataSet_Add.FieldByName('Stock_money').AsVariant;   //统计总的金额
                        Total_amount:=FloatToStr(StrToFloat(Total_amount)+StrToFloat(StringGrid1.Cells[5,i]));
                        Total_money :=FloatToStr(StrToFloat(Total_money)-StrToFloat(StringGrid1.Cells[12,i]));
                        with frm_Data.ClientDataSet_Add do
                        begin
                            Close;
                            CommandText:='';
                            CommandText:='Update [Stock_States] set Out_amount='''+Trim(Total_amount)+''',Stock_money='''+Trim(Total_money)+''' where Goods_No='''+Trim(StringGrid1.Cells[1,i])+''' and Storage_NO='''+Trim(Edit5.Text)+'''';
                            try
                                Execute;
                            except
                                Application.MessageBox('修改[库存]的数量和金额时出现了错误,请确认!',pchar(application.Title),mb_iconwarning);
                                Exit;
                            end;
                        end;
                    end;
                except
                    Application.MessageBox('打开[采购视图]时出现了错误,请确认!',pchar(application.Title),mb_iconwarning);
                    Exit;
                end;
            end;
        end;
        try
            //生成报损出库单
            with frm_data.ClientDataSet_Add do
            begin
                Close;
                CommandText:='';
                CommandText:='Insert Into [Out_strip](Copy_Date,Out_No,Gatrher_monad,Transactor,Proposer,Storage_NO,Shop_NO,Condense,Remark,Business_No,Out_Type) values ('''+Trim(Edit1.Text)+''','''+Trim(Edit2.Text)+''',''报损收货单位'','''+Trim(Edit4.Text)+''','''+Trim(Edit6.Text)+''','''+Trim(Edit3.Text)+''','''+Trim(Edit5.Text)+''',''报损出库'','''+Trim(Edit8.Text)+''',''报损帐户'',''报损出库'')';
                try
                    ExecUte;
                    try
                        for j:=1 to Total_Count do
                        begin
                            with frm_data.ClientDataSet_Add do
                            begin
                                Close;
                                CommandText:='';
                                CommandText:='Insert Into [Out_strip_Detail](Out_No,Goods_NO,Pass_NO,price,amount,money,Out_Remark) values ('''+Trim(Edit1.Text)+''','''+Trim(StringGrid1.Cells[1,j])+''','''+Trim(StringGrid1.Cells[3,j])+''','''+Trim(StringGrid1.Cells[4,j])+''','''+Trim(StringGrid1.Cells[5,j])+''','''+Trim(StringGrid1.Cells[6,j])+''','''+Trim(StringGrid1.Cells[19,j])+''')';
                                try
                                    ExecUte;
                                except
                                    Application.MessageBox('系统在生成[库存报损出库单明细]时出现了错误,请确认!',pchar(application.Title),mb_iconwarning);
                                    Exit;
                                end;
                            end;
                        end;
                    except
                        Application.MessageBox('系统在生成[库存报损出库单明细]循环时出现了错误,请确认!',pchar(application.Title),mb_iconwarning);
                        Exit;
                    end;
                except
                    Application.MessageBox('系统在生成[库存报损出库单]时出现了错误,请确认!',pchar(application.Title),mb_iconwarning);
                    Exit;
                end;
            end;
        except
            Application.MessageBox('系统在生成[库存报损出库单]时出现了错误,请确认!',pchar(application.Title),mb_iconwarning);
            Exit;
        end;
    except
        Application.MessageBox('保存库存数据时系统出现了错误,请确认!',pchar(application.Title),mb_iconwarning);
        Exit;
    end;
end;
//*******************************************


procedure Tfrm_Storage_damage.FormShow(Sender: TObject);
var
    i,icount,k:integer;
    tt,yy,temppos:integer;
begin
    frm_Storage_damage.Left:=170 * longint(Screen.Width) div 1024;
    frm_Storage_damage.Top:=40 * longint(Screen.Height) div 768;
    frm_Storage_damage.Width:=860 * longint(Screen.Width) div 1024;
    frm_Storage_damage.Height:=715 * longint(Screen.Height) div 768;
    iColcount:=StringGrid1.ColCount-1; //需要的填充数据的网络表格的列数
    StringGrid1.RowCount:=2;  StringGrid1.ColCount:=27;
    Total_Count:=StringGrid1.RowCount;

    StringGrid1.ColWidths[0]:=40;   StringGrid1.ColWidths[1]:=150;  StringGrid1.ColWidths[2]:=100;
    StringGrid1.ColWidths[3]:=80;   StringGrid1.ColWidths[4]:=80;   StringGrid1.ColWidths[5]:=100;
    StringGrid1.ColWidths[6]:=50;   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]:='商品条玛';        StringGrid1.Cells[22,0]:='组册商品';     StringGrid1.Cells[23,0]:='生产厂家';
    StringGrid1.Cells[24,0]:='基本单位';        StringGrid1.Cells[25,0]:='有效日期(月)'; StringGrid1.Cells[26,0]:='备注说明';

    if Public_Do='damage_0001' then
    begin
        P_check.Visible:=False;
    end;
    //草稿单据查看
    if ((Public_Do='Business_Storage_damage') and (SH_Level<>0)) then
    begin
        iColcount:=StringGrid1.ColCount-1; //需要的填充数据的网络表格的列数
        StringGrid1.RowCount:=2;  StringGrid1.ColCount:=20;
        Total_Count:=StringGrid1.RowCount;
        StringGrid1.ColWidths[0]:=40;   StringGrid1.ColWidths[1]:=150;  StringGrid1.ColWidths[2]:=100;
        StringGrid1.ColWidths[3]:=80;   StringGrid1.ColWidths[4]:=80;   StringGrid1.ColWidths[5]:=100;
        StringGrid1.ColWidths[6]:=50;   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.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]:='备注说明';
        P_check.Visible:=true;
        if Trim(ExamineMan1)<>'' then
        begin
            tempstr:=ExamineMan1;
            tt:=0;
            while pos(',',tempstr)>0 do //取得逗号的位置
            begin
                temppos:=pos(',',tempstr); //取得逗号的位置

⌨️ 快捷键说明

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