📄 stock_enter.pas
字号:
unit Stock_Enter;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Grids, StdCtrls, Buttons, XPMenu;
type
Tfrm_Stock_Enter = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
Cmd_Cancel: TSpeedButton;
Panel3: TPanel;
Label1: TLabel;
Cmd_HT: TSpeedButton;
Panel4: TPanel;
Edit1: TLabeledEdit;
GroupBox1: TGroupBox;
SpeedButton1: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
SpeedButton4: TSpeedButton;
Edit4: TLabeledEdit;
Edit_Stock_Name: TLabeledEdit;
Edit6: TLabeledEdit;
Edit7: TLabeledEdit;
Edit8: TLabeledEdit;
Edit9: TLabeledEdit;
Edit10: TLabeledEdit;
Edit11: TLabeledEdit;
Edit5: TEdit;
Edit2: TLabeledEdit;
Edit3: TLabeledEdit;
Panel5: TPanel;
Panel6: 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;
Panel7: TPanel;
SpeedButton6: TSpeedButton;
SpeedButton10: TSpeedButton;
LabeledEdit11: TLabeledEdit;
LabeledEdit12: TLabeledEdit;
LabeledEdit13: TLabeledEdit;
Panel8: TPanel;
Label2: TLabel;
Label3: TLabel;
Panel9: TPanel;
Panel10: TPanel;
Cmd_Delete: TSpeedButton;
Cmd_Add: TSpeedButton;
StringGrid1: TStringGrid;
XPMenu1: TXPMenu;
procedure Cmd_CancelClick(Sender: TObject);
procedure Edit1DblClick(Sender: TObject);
procedure Cmd_HTClick(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton8Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton7Click(Sender: TObject);
procedure StringGrid1DblClick(Sender: TObject);
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer;
const Value: String);
procedure Cmd1Click(Sender: TObject);
procedure Cmd2Click(Sender: TObject);
procedure Cmd3Click(Sender: TObject);
procedure Cmd4Click(Sender: TObject);
procedure Cmd5Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure Cmd_AddClick(Sender: TObject);
procedure Cmd_DeleteClick(Sender: TObject);
private
{ Private declarations }
procedure Stock_States_Total;
procedure StringGrid_Delete;
procedure DeleteRow(Row: Integer);
public
{ Public declarations }
end;
var
frm_Stock_Enter: Tfrm_Stock_Enter;
iColcount,Total_Count:Integer;
Pcol,Prow:integer;
Insert_Sql:String;
ss,tempstr:string;
implementation
uses Data, Public_Don, Main, Contract_Check, Supply_Monad, Storage_Select,
ChildShop_Select, Quality_Check_Select, Stock_Write_Check, Goods_Check,
func;
{$R *.dfm}
procedure Tfrm_Stock_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_Stock_Enter.StringGrid_Delete;
var
i,j:integer;
begin
with StringGrid1 do
begin
for I := 0 to ColCount - 1 do
for J:= 0 to RowCount - 1 do
begin
Cells[I,J] := '';
end;
end;
end;
//*******************************************
//自定义库存统计过程
procedure Tfrm_Stock_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(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('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(Edit5.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_Stock_Enter.Cmd_CancelClick(Sender: TObject);
var
i,j,icol:integer;
Check_Flag:string;
begin
frm_Public_Don:=Tfrm_Public_Don.Create(self);
frm_Public_Don.ShowModal;
Insert_Sql:='Insert into [Stock_Jion_detail](Stock_NO,Goods_NO,Pass_NO,amount,quality) values ';
//直接操作入库界面
if Public_Do='Stock_0003' then
begin
//直接过帐
if Public_Do_Result='01' then
begin
with frm_data.ClientDataSet2 do
begin
Close;
CommandText:='';
Commandtext:='Select * from [V_Stock_Join_View] where Receipt_No='''+Trim(Edit2.Text)+'''';
try
Open;
if frm_data.ClientDataSet2.RecordCount>0 then
begin
Check_Flag:=frm_data.ClientDataSet2.FieldByName('Check_Result').AsString;
if Check_Flag='0' then //单据没有完全审核
begin
Application.MessageBox('单据还没有完全审核,不能过帐',pchar(application.Title),mb_iconwarning);
Exit;
end;
if Check_Flag='1' then //单据完全审核
begin
with frm_data.ClientDataSet_Add do
begin
Close;
CommandText:='';
CommandText:='Update [Stock_Join] set Copy_Date='''+Trim(Edit1.Text)+''',Contract_NO='''+Trim(Edit3.Text)+''',WLDW='''+Trim(Edit4.Text)+''',Storage_Name='''+Trim(Edit5.Text)+''',Transactor='''+Trim(Edit6.Text)+''',Shop_NO='''+Trim(Edit7.Text)+''',remark='''+Trim(Edit9.Text)+''',Resume='''+Trim(Edit10.Text)+''',Quality_Check_ID='''+Trim(Edit11.Text)+''' where Stock_No='''+Trim(Edit2.Text)+'''';
try
Execute;
try
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -