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

📄 demand_enter.pas

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

interface

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

type
  Tfrm_Demand_Enter = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    Panel3: TPanel;
    Label1: TLabel;
    Panel4: TPanel;
    Edit_Copy_Date: TLabeledEdit;
    GroupBox1: TGroupBox;
    Cmd_DW: TSpeedButton;
    Cmd_CK: TSpeedButton;
    Cmd_ZDR: TSpeedButton;
    Cmd_JSR: TSpeedButton;
    Edit_Give_Name: TLabeledEdit;
    Edit_Storage_Name: TLabeledEdit;
    Edit_Shop_Name: TLabeledEdit;
    Edit_Transactor: TLabeledEdit;
    Edit_Proposer: TLabeledEdit;
    Edit_Condense: TLabeledEdit;
    Edit_Submit_Remark: TLabeledEdit;
    Edit_Submit_adopt_NO: TLabeledEdit;
    Panel5: TPanel;
    Panel6: TPanel;
    XPMenu1: TXPMenu;
    Panel9: TPanel;
    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;
    SpeedButton6: TSpeedButton;
    SpeedButton11: TSpeedButton;
    LabeledEdit11: TLabeledEdit;
    LabeledEdit12: TLabeledEdit;
    LabeledEdit13: TLabeledEdit;
    Panel11: TPanel;
    Label4: TLabel;
    Label5: TLabel;
    Panel7: TPanel;
    Cmd_Delete: TSpeedButton;
    Cmd_Add: TSpeedButton;
    StringGrid1: TStringGrid;
    Edit_Shop_NO: TLabeledEdit;
    Edit_Storage_NO: TLabeledEdit;
    Cmd_DM: TSpeedButton;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure Cmd_DeleteClick(Sender: TObject);
    procedure Cmd_AddClick(Sender: TObject);
    procedure Edit_Copy_DateDblClick(Sender: TObject);
    procedure Edit_Copy_DateKeyPress(Sender: TObject; var Key: Char);
    procedure Cmd_ZDRClick(Sender: TObject);
    procedure Edit_ProposerDblClick(Sender: TObject);
    procedure Edit_ProposerKeyPress(Sender: TObject; var Key: Char);
    procedure Cmd_DWClick(Sender: TObject);
    procedure Cmd_CKClick(Sender: TObject);
    procedure Cmd_DMClick(Sender: TObject);
    procedure Cmd_JSRClick(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 DeleteRow(Row:Integer);
    procedure Stock_States_Total;
  public
    { Public declarations }
  end;

var
  frm_Demand_Enter: Tfrm_Demand_Enter;
  iColcount,Total_Count:Integer;
  ss,
  tempstr:String;
  Pcol,Prow:integer;
implementation

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

{$R *.dfm}

//自定义库存统计过程
procedure Tfrm_Demand_Enter.Stock_States_Total;
var
    Total_amount,Total_money:String;
    i: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(Edit_Storage_NO.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('IN_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 IN_amount='''+Trim(Total_amount)+''',Stock_money='''+Trim(Total_money)+''' where Goods_No='''+Trim(StringGrid1.Cells[1,i])+''' and Storge_NO='''+Trim(Edit_Shop_NO.Text)+'''';
                            try
                                Execute;
                            except
                                Application.MessageBox('修改[库存]的数量和金额时出现了错误,请确认!',pchar(application.Title),mb_iconwarning);
                                Exit;
                            end;
                        end;
                    end;
                    //如果该仓库不存在同种商品
                    if frm_data.ClientDataSet_Add.RecordCount=0 then
                    begin
                        with frm_Data.ClientDataSet_Add do
                        begin
                            Close;
                            CommandText:='';
                            CommandText:='insert into [Stock_States](Goods_NO,IN_amount,Stock_money,Storage_NO,Shop_NO) values ('''+Trim(StringGrid1.Cells[1,i])+''','''+StringGrid1.Cells[5,i]+''','''+StringGrid1.Cells[12,i]+''','''+Trim(Edit5.Text)+''','''+Trim(Edit7.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;
    except
        Application.MessageBox('保存库存数据时系统出现了错误,请确认!',pchar(application.Title),mb_iconwarning);
        Exit;
    end; }
end;

procedure Tfrm_Demand_Enter.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_Demand_Enter.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
    frm_Data.ClientDataSet_Submit_adopt_detail.Active:=false;
    frm_Data.ClientDataSet_Submit_adopt_detail.Close;
    frm_Data.ClientDataSet_Submit_adopt.Active:=false;
    frm_Data.ClientDataSet_Submit_adopt.Close;
    frm_data.ClientDataSet_Receipt.Active:=False;
    frm_data.ClientDataSet_Receipt.Close;
    Action:=Cafree;
end;

procedure Tfrm_Demand_Enter.FormShow(Sender: TObject);
var
    i,icount,k:integer;
    tt,yy,temppos:integer;
begin
    frm_Demand_Enter.Left:=170 * longint(Screen.Width) div 1024;
    frm_Demand_Enter.Top:=40 * longint(Screen.Height) div 768;
    frm_Demand_Enter.Height:=715;
    frm_Demand_Enter.Width:=860;
    iColcount:=StringGrid1.ColCount-1; //需要的填充数据的网络表格的列数
    StringGrid1.RowCount:=2;  StringGrid1.ColCount:=20;
    Total_Count:=StringGrid1.RowCount;
    for i:=1 to StringGrid1.RowCount-1 do
    begin
        StringGrid1.Cells[0,i]:=IntTostr(i); //表示第0列第i行
    end;
    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.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]:='商品说明';


    if Public_Do='Demand_Enter_Str' then
    begin
        P_check.Visible:=False;
    end;
    //草稿单据查看
    if ((Public_Do='Demand_Enter_Business') and (SH_Level<>0)) then
    begin
        P_check.Visible:=true;
        if Trim(ExamineMan1)<>'' then

⌨️ 快捷键说明

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