📄 stock_contract.pas
字号:
unit Stock_Contract;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Grids, ComCtrls, Mask, StdCtrls, Buttons, XPMenu;
type
Tfrm_Stock_Contract = class(TForm)
Panel1: 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;
Cmd_Print: TSpeedButton;
Cmd_Search: TSpeedButton;
Panel8: TPanel;
Label2: TLabel;
Label3: TLabel;
Panel2: TPanel;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
Panel3: TPanel;
Label1: TLabel;
Panel4: TPanel;
Edit1: TLabeledEdit;
GroupBox1: TGroupBox;
Cmd_DW: TSpeedButton;
Cmd_JSR: TSpeedButton;
Cmd_Up: TSpeedButton;
Cmd_Next: TSpeedButton;
Cmd_DC: TSpeedButton;
SpeedButton11: TSpeedButton;
SpeedButton12: TSpeedButton;
SpeedButton13: TSpeedButton;
Cmd_ZDR: TSpeedButton;
Edit4: TLabeledEdit;
Edit5: TLabeledEdit;
Edit7: TLabeledEdit;
Edit8: TLabeledEdit;
Edit9: TLabeledEdit;
Edit2: TLabeledEdit;
E3: TLabeledEdit;
Edit3: TMaskEdit;
DateTimePicker1: TDateTimePicker;
Panel5: TPanel;
Panel6: TPanel;
Panel7: TPanel;
Panel9: TPanel;
Cmd_Delete: TSpeedButton;
Cmd_Add: TSpeedButton;
StringGrid1: TStringGrid;
XPMenu1: TXPMenu;
procedure SpeedButton4Click(Sender: TObject);
procedure Edit1Click(Sender: TObject);
procedure DateTimePicker1Change(Sender: TObject);
procedure Cmd_DWClick(Sender: TObject);
procedure Cmd_JSRClick(Sender: TObject);
procedure Cmd_ZDRClick(Sender: TObject);
procedure Cmd_UpClick(Sender: TObject);
procedure Cmd_NextClick(Sender: TObject);
procedure Cmd_DCClick(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 Cmd_SearchClick(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Cmd_DeleteClick(Sender: TObject);
procedure Cmd_AddClick(Sender: TObject);
private
{ Private declarations }
procedure DeleteRow(Row:Integer);
public
{ Public declarations }
end;
var
frm_Stock_Contract: Tfrm_Stock_Contract;
iColcount,Total_Count:integer;
Pcol,Prow:integer;
ss,tempstr:string;
implementation
uses Public_Don, Data, Main, Supply_Monad, Login_Man, func,
Stock_Contract_Search, Goods_Check, Goods_Requipment_Search;
{$R *.dfm}
procedure Tfrm_Stock_Contract.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_Contract.SpeedButton4Click(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_0002' then
begin
//保存为草稿单据
if Public_Do_Result='02' then //保存为草稿单据
begin
try
for i:=1 to StringGrid1.ColCount-1 do
begin
for j:=1 to StringGrid1.RowCount-1 do
begin
if StringGrid1.Cells[1,j]='' then
begin
Application.MessageBox('操作错误,【商品编号】不能为空!,请确认!',pchar(application.Title),mb_iconwarning);
Exit;
end;
end;
end;
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(Edit3.Text)='- -' then
begin
Application.MessageBox('操作错误,【到达日期】不能为空!,请确认!',pchar(application.Title),mb_iconwarning);
Edit3.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(Edit7.Text)='' then
begin
Application.MessageBox('操作错误,【制单人】不能为空!,请确认!',pchar(application.Title),mb_iconwarning);
Edit7.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[4,i]='' then
begin
Application.MessageBox('操作错误,【数量】不能为空!,请确认!',pchar(application.Title),mb_iconwarning);
Exit;
end;
if StringGrid1.Cells[5,i]='' then
begin
Application.MessageBox('操作错误,【金额】不能为空!,请确认!',pchar(application.Title),mb_iconwarning);
Exit;
end;
end;
with frm_data.ClientDataSet_Add do
begin
Close;
CommandText:='';
CommandText:='Select * from [Stock_contract] where Copy_Date='''+Trim(Edit1.Text)+''' and Contract_No='''+Trim(Edit2.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_contract] (Copy_Date,Contract_No,Arrive_Date,wldw,transactor,proposer,resume,remark) values ('''+Trim(Edit1.Text)+''','''+Trim(Edit2.Text)+''','''+Trim(Edit3.Text)+''','''+Trim(Edit4.Text)+''','''+Trim(Edit5.Text)+''','''+Trim(Edit7.Text)+''','''+Trim(Edit8.Text)+''','''+Trim(Edit9.Text)+''')';
try
Execute;
with frm_data.ClientDataSet_Add do
begin
Close;
CommandText:='';
CommandText:='Insert into [Receipt](Receipt_NO,Receipt_Name,Copy_Date,Proposer,Condense) values ('''+Trim(Edit2.Text)+''',''采购合同'','''+Trim(Edit1.Text)+''','''+Trim(Edit7.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_contract_detail](Contract_No,Goods_NO,Price,Goods_amount,Money) values ('''+Trim(Edit2.Text)+''','''+Trim(StringGrid1.Cells[1,i])+''','''+Trim(StringGrid1.Cells[3,i])+''','''+Trim(StringGrid1.Cells[4,i])+''','''+Trim(StringGrid1.Cells[5,i])+''')';
try
Execute;
except
Application.MessageBox('系统错误,在保存【采购合同明细表】数据时出错'+#13#10+'请检查远程服务器连接是否正常?请确认!',pchar(application.Title),mb_iconwarning);
Exit;
end;
end;
except
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -