📄 goods_write.pas
字号:
unit Goods_Write;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Grids, StdCtrls, Buttons, XPMenu;
type
Tfrm_Goods_Write = 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;
Edit4: TLabeledEdit;
Edit_Storage_Name: TLabeledEdit;
Edit6: TLabeledEdit;
Edit7: TLabeledEdit;
Edit8: TLabeledEdit;
Edit9: TLabeledEdit;
Edit10: TLabeledEdit;
Edit2: TLabeledEdit;
Edit3: TLabeledEdit;
Panel5: TPanel;
Panel6: TPanel;
Panel9: TPanel;
Panel10: TPanel;
Cmd_Delete: TSpeedButton;
Cmd_Add: TSpeedButton;
StringGrid1: TStringGrid;
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;
Cmd_HT: TSpeedButton;
Edit5: TLabeledEdit;
procedure Cmd_CancelClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Cmd_AddClick(Sender: TObject);
procedure Cmd_DeleteClick(Sender: TObject);
procedure StringGrid1DblClick(Sender: TObject);
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure Edit1DblClick(Sender: TObject);
procedure Edit8DblClick(Sender: TObject);
procedure Edit8KeyPress(Sender: TObject; var Key: Char);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Cmd1Click(Sender: TObject);
procedure Cmd2Click(Sender: TObject);
procedure Cmd3Click(Sender: TObject);
procedure Cmd4Click(Sender: TObject);
procedure Cmd5Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure Cmd_HTClick(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton9Click(Sender: TObject);
procedure SpeedButton8Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_Goods_Write: Tfrm_Goods_Write;
iColcount,Total_Count:integer;
Pcol,Prow:integer;
ss,tempstr:string;
implementation
uses func, Goods_Select, Goods_Check, Data, Public_Don, Supply_Monad,
Contract_Check, Storage_Select, Login_Man, ChildShop_Select;
{$R *.dfm}
procedure Tfrm_Goods_Write.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;
if Public_Do='Stock_0008' then
begin
//直接过帐
if Public_Do_Result='01' then
begin
try
with frm_data.ClientDataSet2 do
begin
Close;
CommandText:='';
Commandtext:='Select * from [V_Stock_Write_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_Write] Contract_NO='''+Trim(Edit3.Text)+''',Gather_Name='''+Trim(Edit4.Text)+''',Storage_NO='''+Trim(Edit5.Text)+''',Transactor='''+Trim(Edit6.Text)+''',Shop_NO='''+Trim(Edit7.Text)+''',remark='''+Trim(Edit10.Text)+''',Condense='''+Trim(Edit9.Text)+''' where Stock_No='''+Trim(Edit2.Text)+'''';
try
Execute;
for i:=1 to Total_Count-1 do
begin
with frm_data.ClientDataSet_Add do
begin
Close;
frm_data.ClientDataSet_Add.CommandText:='';
CommandText:='update [Stock_Write_detail] set Write_Amount='''+Trim(StringGrid1.Cells[3,i])+''',Write_Remark='''+Trim(StringGrid1.Cells[24,i])+''' where Stock_NO='''+Trim(Edit2.Text)+'''and Goods_NO='''+Trim(StringGrid1.Cells[1,i])+'''';
try
Execute;
except
Application.MessageBox('保存[来货登记明细]数据时,连接服务器数据库错误,请尝试重新连接,请确认!',Pchar(Application.Title),MB_ICONwarning);
Exit;
end;
end;
end;
with frm_data.ClientDataSet_Add do
begin
Close;
Commandtext:='';
Commandtext:='Update [Receipt] set Flag_sign=''单据'' where Receipt_No='''+Trim(Edit2.Text)+'''';
try
Execute;
Application.MessageBox('恭喜你![来货登记]单据过帐操作成功,请确认!',Pchar(Application.Title),MB_ICONwarning);
except
Application.MessageBox('保存[来货登记审核表]数据时,连接服务器数据库错误,请尝试重新连接,请确认!',Pchar(Application.Title),MB_ICONwarning);
Exit;
end;
end;
except
Application.MessageBox('保存[来货登记]数据时,连接服务器数据库错误,请尝试重新连接,请确认!',Pchar(Application.Title),MB_ICONwarning);
Exit;
end;
end;
end;
end
else
begin
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;
end;
//保存为草稿
if Public_Do_Result='02' then
begin
try
if Trim(Edit1.Text)='' then
begin
Application.MessageBox('操作错误,【录单日期】不能为空!,请确认!',pchar(application.Title),mb_iconwarning);
Edit1.SetFocus;
Exit;
end;
if Trim(Edit2.Text)='' then
begin
Application.MessageBox('操作错误,【单据编号】不能为空!,请确认!',pchar(application.Title),mb_iconwarning);
Edit2.SetFocus;
Exit;
end;
if Trim(Edit4.Text)='' then
begin
Application.MessageBox('操作错误,【供货单位】不能为空!,请确认!',pchar(application.Title),mb_iconwarning);
Edit4.SetFocus;
Exit;
end;
if Trim(Edit5.Text)='' then
begin
Application.MessageBox('操作错误,【验货仓库】不能为空!,请确认!',pchar(application.Title),mb_iconwarning);
Edit5.SetFocus;
Exit;
end;
if Trim(Edit6.Text)='' then
begin
Application.MessageBox('操作错误,【经手人】不能为空!,请确认!',pchar(application.Title),mb_iconwarning);
Edit6.SetFocus;
Exit;
end;
if Trim(Edit8.Text)='' then
begin
Application.MessageBox('操作错误,【制单人】不能为空!,请确认!',pchar(application.Title),mb_iconwarning);
Edit8.SetFocus;
Exit;
end;
for i:=1 to Total_Count-1 do
begin
if StringGrid1.Cells[3,i]='' then
begin
Application.MessageBox('操作错误,【来货数量】不能为空!,请确认!',pchar(application.Title),mb_iconwarning);
Exit;
end;
if StringGrid1.Cells[1,i]='' then
begin
Application.MessageBox('操作错误,【商品编号】不能为空!,请确认!',pchar(application.Title),mb_iconwarning);
Exit;
end;
end;
try
with frm_data.ClientDataSet_Add do
begin
Close;
CommandText:='';
CommandText:='SELECT * FROM [Stock_Write] where Copy_Date='''+Trim(Edit1.Text)+''' and Stock_NO='''+Trim(Edit2.Text)+''' and Gather_Name='''+Trim(Edit4.Text)+''' and Storage_No='''+Trim(Edit5.Text)+'''';
try
Open;
if frm_data.ClientDataSet_Add.RecordCount>0 then
begin
Application.MessageBox('该【来货登记】操作已经存在了,请确认!',pchar(application.Title),mb_iconwarning);
Exit;
end
else
begin
with frm_data.ClientDataSet_Add do
begin
Close;
CommandText:='';
CommandText:='INSERT INTO [Stock_Write](Copy_Date,Stock_NO,Contract_NO,Gather_Name,Storage_NO,Transactor,Shop_NO,Proposer,Condense,Remark) values ('''+Trim(Edit1.Text)+''','''+Trim(Edit2.Text)+''','''+Trim(Edit3.Text)+''','''+Trim(Edit4.Text)+''','''+Trim(Edit5.Text)+''','''+Trim(Edit6.Text)+''','''+Trim(Edit7.Text)+''','''+Trim(Edit8.Text)+''','''+Trim(Edit9.Text)+''','''+Trim(Edit10.Text)+''')';
Try
Execute;
with frm_data.ClientDataSet_Add do
begin
Close;
frm_data.ClientDataSet_Add.CommandText:='';
CommandText:='Insert into [Receipt](Receipt_NO,Receipt_Name,Copy_Date,Proposer,Condense) values ('''+Trim(Edit2.Text)+''',''来货登记单'','''+Trim(Edit1.Text)+''','''+Trim(Edit8.Text)+''','''+Trim(Edit9.Text)+''')';
try
Execute;
for i:=1 to Total_Count-1 do
begin
try
with frm_data.ClientDataSet_Add do
begin
Close;
CommandText:='';
CommandText:='Insert into [Stock_Write_detail](Stock_NO,Goods_N0,Write_Amount,Write_Remark) values ('''+Trim(Edit2.Text)+''','''+Trim(StringGrid1.Cells[1,i])+''','''+Trim(StringGrid1.Cells[3,i])+''','''+Trim(StringGrid1.Cells[24,i])+''')';
try
Execute;
except
Application.MessageBox('系统错误,保存[来货登记明细表]数据时出错!,请确认!',pchar(application.Title),mb_iconwarning);
Exit;
end;
end;
except
Application.MessageBox('系统错误,保存[来货登记明细表]数据循环时出错!,请确认!',pchar(application.Title),mb_iconwarning);
Exit;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -