📄 stock_pay.pas
字号:
unit Stock_Pay;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Buttons, Grids, XPMenu;
type
Tfrm_Stock_Pay = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
Cmd_Exit: TSpeedButton;
Panel3: TPanel;
Label1: TLabel;
Panel4: TPanel;
Edit1: TLabeledEdit;
GroupBox1: TGroupBox;
SpeedButton1: TSpeedButton;
SpeedButton7: TSpeedButton;
SpeedButton9: TSpeedButton;
Label4: TLabel;
Label5: TLabel;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
Edit8: TLabeledEdit;
Edit9: TLabeledEdit;
Edit10: TLabeledEdit;
Edit11: TLabeledEdit;
Edit12: TLabeledEdit;
Edit6: TComboBox;
Edit7: TComboBox;
GroupBox2: TGroupBox;
LabeledEdit3: TLabeledEdit;
LabeledEdit5: TLabeledEdit;
LabeledEdit7: TLabeledEdit;
LabeledEdit12: TLabeledEdit;
LabeledEdit13: TLabeledEdit;
CheckBox1: TCheckBox;
Edit4: TLabeledEdit;
Edit5: TLabeledEdit;
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;
Panel8: TPanel;
Label2: TLabel;
Label3: TLabel;
Panel7: TPanel;
Panel10: TPanel;
Cmd_Delete: TSpeedButton;
Cmd_Add: TSpeedButton;
StringGrid1: TStringGrid;
XPMenu1: TXPMenu;
procedure Cmd_ExitClick(Sender: TObject);
procedure Edit1DblClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure Cmd_AddClick(Sender: TObject);
procedure Cmd1Click(Sender: TObject);
procedure Cmd2Click(Sender: TObject);
procedure Cmd3Click(Sender: TObject);
procedure Cmd4Click(Sender: TObject);
procedure Cmd5Click(Sender: TObject);
procedure Cmd_DeleteClick(Sender: TObject);
private
{ Private declarations }
procedure DeleteRow(Row:Integer);
public
{ Public declarations }
end;
var
frm_Stock_Pay: Tfrm_Stock_Pay;
iColcount,Total_Count:Integer;
Pcol,Prow:integer;
ss,tempstr:string;
implementation
uses Public_Don, Data, func;
{$R *.dfm}
procedure Tfrm_Stock_Pay.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_Pay.Cmd_ExitClick(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_0005' then
begin
if Public_Do_Result='01' then //保存单据
begin
with frm_data.ClientDataSet2 do
begin
try
Close;
CommandText:='';
Commandtext:='Select * from [V_Stock_Pay_View] where Receipt_No='''+Trim(Edit2.Text)+'''';
Open;
if frm_data.ClientDataSet2.RecordCount>0 then
begin
Check_Flag:=frm_data.ClientDataSet2.FieldValues['Check_Result'];
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_Pay] set Contract_NO='''+Trim(Edit3.Text)+''',Bill_NO='''+Trim(Edit4.Text)+''',Join_NO='''+Trim(Edit5.Text)+''',Pay_Type='''+Trim(Edit6.Text)+''',Balance_Modal='''+Trim(Edit7.Text)+''',Gather_Name='''+Trim(Edit8.Text)+''',Transactor='''+Trim(Edit9.Text)+''',Condense='''+Trim(Edit11.Text)+''' where Stock_No='''+Trim(List_No)+'''';
Execute;
for i:=1 to Total_Count-1 do
begin
try
begin
with frm_data.ClientDataSet_Add do
begin
Close;
frm_data.ClientDataSet_Add.CommandText:='';
CommandText:='update [Stock_Pay_detail] set Account_NO='''+Trim(StringGrid1.Cells[1,i])+''',Account_Name='''+Trim(StringGrid1.Cells[2,i])+''',Account_Money='''+Trim(StringGrid1.Cells[3,i])+''',Account_Remark='''+Trim(StringGrid1.Cells[4,i])+''' where Stock_NO='''+Trim(List_NO)+''' and Goods_NO='''+Trim(StringGrid1.Cells[1,i])+'''';
Execute;
end;
end;
except
Application.MessageBox('保存单据明细时失败,请检查连接网络是否正常,请确认!',pchar(application.Title),mb_iconwarning);
Exit;
end;
end;
Application.MessageBox('单据过帐完毕!',pchar(application.Title),mb_iconwarning);
try
with frm_data.ClientDataSet_Add do
begin
Close;
Commandtext:='';
Commandtext:='Update [Receipt] set Flag_sign=''单据'' where Receipt_No='''+Trim(List_NO)+'''';
Execute;
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;
end;
if func.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;
for i:=1 to StringGrid1.ColCount-1 do
begin
for j:=1 to StringGrid1.RowCount-1 do
begin
if StringGrid1.Cells[3,j]='' then
begin
Application.MessageBox('操作错误,【金额】不能为空!,请确认!',pchar(application.Title),mb_iconwarning);
Exit;
end;
end;
end;
with frm_data.ClientDataSet_Add do
begin
Close;
CommandText:='';
Commandtext:='SELECT * FROM [Stock_Pay] where Copy_date='''+Trim(Edit1.Text)+''' and Stock_No='''+Trim(Edit2.Text)+''' and Gather_Name='''+Trim(Edit8.Text)+'''';
Open;
if frm_data.ClientDataSet_Add.RecordCount>0 then
begin
Application.MessageBox('添加失败,该记录已经存在,请确认!',pchar(application.Title),mb_iconwarning);
Exit;
end
else
begin
try
with frm_data.ClientDataSet_Add do
begin
Close;
CommandText:='';
CommandText:='INSERT INTO [Stock_Pay](Copy_Date,Stock_No,Contract_NO,Bill_NO,Join_NO,Pay_Type,Balance_Modal,Gather_Name,Transactor,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)+''','''+TRim(Edit11.Text)+''','''+TRim(Edit12.Text)+''')';
Execute;
try
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(Edit10.Text)+''','''+Trim(Edit11.Text)+''')';
Execute;
except
Application.MessageBox('保存【审核数据】时失败,请检查连接网络是否正常,请确认!',pchar(application.Title),mb_iconwarning);
Exit;
end;
try
begin
for i:=1 to Total_Count-1 do
begin
try
begin
with frm_data.ClientDataSet_Add do
begin
Close;
frm_data.ClientDataSet_Add.CommandText:='';
CommandText:='Insert into [Stock_Pay_detail](Stock_NO,Account_NO,Account_Name,Account_Money,Account_Remark) values ('''+Trim(Edit2.Text)+''','''+Trim(StringGrid1.Cells[1,i])+''','''+Trim(StringGrid1.Cells[2,i])+''','''+Trim(StringGrid1.Cells[3,i])+''','''+Trim(StringGrid1.Cells[4,i])+''')';
Execute;
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;
except
Application.MessageBox('操作失败,请检查连接网络是否正常,请确认!',pchar(application.Title),mb_iconwarning);
Exit;
end;
end;
end;
except
Application.MessageBox('操作失败,请检查连接网络是否正常,请确认!',pchar(application.Title),mb_iconwarning);
Exit;
end;
end;
if func.Public_Do_Result='03' then // 废弃退出
begin
frm_data.ClientDataSet_Add.Active:=False;
frm_data.ClientDataSet_Add.Close;
frm_data.ClientDataSet2.Active:=False;
frm_data.ClientDataSet2.Close;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -