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

📄 umanage_fad.pas

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

interface

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

type
  Tfrm_Umanage_Fad = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    Cmd_Cancel: TSpeedButton;
    Panel3: TPanel;
    Label1: TLabel;
    Panel4: TPanel;
    Edit1: TLabeledEdit;
    GroupBox1: TGroupBox;
    SpeedButton1: TSpeedButton;
    SpeedButton5: TSpeedButton;
    SpeedButton7: TSpeedButton;
    SpeedButton8: TSpeedButton;
    SpeedButton9: TSpeedButton;
    Edit3: TLabeledEdit;
    Edit_Storage_Name: TLabeledEdit;
    Edit5: TLabeledEdit;
    Edit6: TLabeledEdit;
    Edit7: TLabeledEdit;
    Edit8: TLabeledEdit;
    Edit9: TLabeledEdit;
    Edit2: TLabeledEdit;
    Panel5: TPanel;
    Panel6: TPanel;
    Panel8: TPanel;
    Label2: TLabel;
    Label3: TLabel;
    Panel7: TPanel;
    SpeedButton6: TSpeedButton;
    SpeedButton10: TSpeedButton;
    Edit10: TLabeledEdit;
    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;
    XPMenu1: TXPMenu;
    Panel9: TPanel;
    Panel10: TPanel;
    Cmd_Delete: TSpeedButton;
    Cmd_Add: TSpeedButton;
    StringGrid1: TStringGrid;
    Edit4: TLabeledEdit;
    Edit11: TLabeledEdit;
    SpeedButton4: TSpeedButton;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure Cmd_CancelClick(Sender: TObject);
    procedure Edit1DblClick(Sender: TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure Edit7KeyPress(Sender: TObject; var Key: Char);
    procedure Edit7DblClick(Sender: TObject);
    procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    procedure StringGrid1DblClick(Sender: TObject);
    procedure SpeedButton5Click(Sender: TObject);
    procedure SpeedButton9Click(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 }
    procedure Stock_States_Total;
    procedure DeleteRow(Row:Integer);
  public
    { Public declarations }
  end;

var
  frm_Umanage_Fad: Tfrm_Umanage_Fad;
  iColcount,Total_Count:Integer;
  i,Pcol,Prow:integer;
  Insert_Sql:String;
  ss,tempstr:string;
implementation

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

{$R *.dfm}

procedure Tfrm_Umanage_Fad.DeleteRow(Row:Integer);
var
    i : integer;
begin
    //最后一列直接删除
    if (Row = StringGrid1.RowCount-1) and (row >1) then
        StringGrid1.RowCount := StringGrid1.RowCount - 1;
    //自动上移
    if (Row < StringGrid1.RowCount) and (Row > StringGrid1.FixedRows-1) then
    begin
        if Row < StringGrid1.RowCount - 1 then
        begin
            for i := Row to StringGrid1.RowCount-1 do
            StringGrid1.Rows[i] := StringGrid1.Rows[i+1];
            StringGrid1.RowCount :=StringGrid1.RowCount - 1;
        end;
    end;
end;

//自定义库存统计过程
procedure Tfrm_Umanage_Fad.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,Out_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)+''','''+Trim(Edit10.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_Umanage_Fad.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
    Action:=Cafree;
end;

procedure Tfrm_Umanage_Fad.FormShow(Sender: TObject);
var
    icount,k:integer;
    tt,yy,temppos:integer;
begin
    frm_Umanage_Fad.Left:=170 * longint(Screen.Width) div 1024;
    frm_Umanage_Fad.Top:=40 * longint(Screen.Height) div 768;
    frm_Umanage_Fad.Height:=715;
    frm_Umanage_Fad.Width:=860;
    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]:=150;
    StringGrid1.ColWidths[3]:=100;  StringGrid1.ColWidths[4]:=100;  StringGrid1.ColWidths[5]:=150;
    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='Umanage_0001' then
    begin
        P_check.Visible:=False;
    end;
    //草稿单据查看
    if ((Public_Do='Business_Storage_Out') and (SH_Level<>0)) then
    begin
        P_check.Visible:=true;
        if Trim(ExamineMan1)<>'' then
        begin
            tempstr:=ExamineMan1;
            tt:=0;
            while pos(',',tempstr)>0 do //取得逗号的位置
            begin
                temppos:=pos(',',tempstr); //取得逗号的位置
                ss:=copy(tempstr,1,temppos-1);
                tempstr:=copy(tempstr,temppos+1,length(tempstr)-temppos);
                if ss=Handle_Man then
                begin
                    P1.Visible:=True; L1.Caption:=LevelName1+':'+ss;
                    if ee1='' then
                    begin
                        L1.Caption:=LevelName1+':'+ss;
                        Flag1:=1;
                    end;
                    if ee1<>'' then
                    begin

⌨️ 快捷键说明

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