📄 goods_requirement.pas
字号:
unit Goods_Requirement;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Buttons, Grids, FR_DSet,
FR_DBSet, DBGrids, DB;
type
Tfrm_Goods_Requirement = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
SpeedButton2: TSpeedButton;
SpeedButton4: TSpeedButton;
Panel3: TPanel;
Edit1: TLabeledEdit;
GroupBox1: TGroupBox;
Cmd_Select_Storage: TSpeedButton;
Cmd_Select_Login: TSpeedButton;
Cmd_Select_JSR: TSpeedButton;
Cmd_Select_Shop: TSpeedButton;
Edit_Storage_Name: TLabeledEdit;
Edit5: TLabeledEdit;
Edit6: TLabeledEdit;
Edit7: TLabeledEdit;
Edit8: TLabeledEdit;
Edit3: TLabeledEdit;
Edit_Shop_Name: TLabeledEdit;
Edit4: TLabeledEdit;
Edit2: TLabeledEdit;
Panel7: TPanel;
spbprint: TSpeedButton;
Panel6: TPanel;
StringGrid1: TStringGrid;
Panel10: TPanel;
Cmd_Delete: TSpeedButton;
Cmd_Add: TSpeedButton;
edtgoodsremark: TLabeledEdit;
Label1: TLabel;
procedure Cmd_Select_ShopClick(Sender: TObject);
procedure Cmd_Select_StorageClick(Sender: TObject);
procedure Cmd_Select_JSRClick(Sender: TObject);
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Cmd_DeleteClick(Sender: TObject);
procedure Cmd_AddClick(Sender: TObject);
procedure Edit1DblClick(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure StringGrid1DblClick(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure Cmd_Select_LoginClick(Sender: TObject);
procedure Edit6KeyPress(Sender: TObject; var Key: Char);
procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure StringGrid1KeyPress(Sender: TObject; var Key: Char);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton10Click(Sender: TObject);
procedure spbprintClick(Sender: TObject);
procedure edtgoodsremarkChange(Sender: TObject);
private
{ Private declarations }
Pcol,Prow:integer;
fl:string; //判断是否草稿操作,见程序(FormShow)事件中
procedure init;
procedure DeleteRow(Row:Integer);
public
{ Public declarations }
end;
var
frm_Goods_Requirement: Tfrm_Goods_Requirement;
Total_Count:Integer;
implementation
uses ChildShop_Select, Storage_Select, Login_Man, func, Data,
untdatadm, Public_Don, Main, Business_Draft, UntgoodCodeSelStr,
Goods_Requipment_Search, Unitreportxf, Unt_PubStrGrid;
{$R *.dfm}
procedure tfrm_goods_requirement.init;
var
temp,make:string;
begin
InitialStrGrid(stringgrid1,'商品需求');
if Public_Do<>'Goods_Requirement_str' then exit;
temp:='select max(right(stock_no,4)) from goods_requirement where copy_date='+''''+formatdatetime('yyyy''-''mm''-''dd',date)+''''+' and part_no='+''''+trim(Handle_Part)+'''';
make:='SQ-'+trim(Handle_Part)+trim(handle_no); //5-11 编码中用部门编号
edit2.Text:=setcode(temp,make);
edit1.Text:=formatdatetime('yyyy''-''mm''-''dd',date);
edit6.Text:=trim(Handle_Man);
end;
procedure Tfrm_Goods_Requirement.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_Goods_Requirement.Cmd_Select_ShopClick(Sender: TObject);
begin
ChildShop_Str:='';
ChildShop_Result_NO:='';
ChildShop_Result_Name:='';
ChildShop_Str:='Goods_Requirement_str';
frm_ChildShop_Select:=Tfrm_ChildShop_Select.Create(self);
frm_ChildShop_Select.ShowModal;
Edit4.Text:=ChildShop_Result_NO;
Edit_Shop_Name.Text:=ChildShop_Result_Name;
frm_ChildShop_Select.Free;
end;
procedure Tfrm_Goods_Requirement.Cmd_Select_StorageClick(Sender: TObject);
begin
Check_Storage:='';
Check_Storage_Result:='';
Check_Storage:='Goods_Requirement_str';
frm_Storage_Select:=Tfrm_Storage_Select.Create(self);
frm_Storage_Select.ShowModal;
Edit_Storage_Name.Text:=Trim(Check_Storage_Result);
Edit3.Text:=Trim(Check_Storage_Result_NO);
frm_Storage_Select.Free;
end;
procedure Tfrm_Goods_Requirement.Cmd_Select_JSRClick(Sender: TObject);
begin
Employe_Check:='';
Employe_Check:='Goods_Requirement_str';
Employe_Check_Result:='';
frm_Login_Man:=Tfrm_Login_Man.Create(self);
frm_Login_Man.Caption:='经手人选择';
frm_Login_Man.ShowModal;
Edit5.Text:=Employe_Check_Result;
frm_Login_Man.Free;
end;
procedure Tfrm_Goods_Requirement.StringGrid1DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
s:string;
r:TRect;
begin
//ydy add 设置显示颜色
with Sender as Tstringgrid do
begin
if gdSelected in State then
Canvas.Brush.Color:= clTeal; //clBlue; //clyellow;//clRed;
Canvas.TextRect(Rect,Rect.Left,Rect.Top,' '+Cells[ACol,ARow]);
if gdFocused in State then
Canvas.DrawFocusRect(Rect);
end;
//不但水平居中,还垂直居中
with Sender as Tstringgrid do
begin
Canvas.FillRect(Rect);
s:=Cells[ACol,ARow];
r:=Rect;
DrawText(Canvas.Handle,PChar(s),Length(s),r,DT_CENTER or DT_SINGLELINE or DT_VCENTER);
end;
end;
procedure Tfrm_Goods_Requirement.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
DMMAIN.CDSquery2.Close;
dmmain.CDSquery2.Data:=null;
dmmain.cdsprintmaster.Close;
dmmain.cdsprintmaster.Data:=null;
Action:=Cafree;
end;
procedure Tfrm_Goods_Requirement.FormCreate(Sender: TObject);
var
FWidth:integer;
begin
Scaled:=TRUE;
end;
procedure Tfrm_Goods_Requirement.FormShow(Sender: TObject);
var
i:integer;
tempstr:widestring;
begin
init;
if Public_Do='Goods_Requirement_str' then
begin
fl:='';
StringGrid1.RowCount:=2;
end;
if (Public_Do='Requirement_0001') then
begin
// tempstr:='Select a.*,b.*,c.* from Goods_Requirement as a ,Goods_Requirement_detail as b, goods_code as c where c.goods_no=b.goods_no and a.Contract_No=b.Contract_No and a.Contract_No='+''''+trim(List_No)+'''';
fl:='edit';
edit2.ReadOnly:=true; //wy 草稿中不能修改单据编号,否则要乱套
tempstr:='Select a.*,b.*,c.* from Goods_Requirement as a, Goods_Requirement_detail as b, Goods_code as c where a.stock_no=b.stock_no and b.goods_no=c.goods_no and a.Stock_NO='+''''+trim(List_No)+'''';
dmmain.CDSquery2.Data:=null;
dmmain.CDSquery2.Close;
//dmmain.cdsprintmaster.Close;
//dmmain.cdsprintmaster.Data:=null;
try
dmmain.CDSquery2.Data:=adisp.resultrecord(tempstr);
dmmain.CDSquery2.Open;
stringgrid1.RowCount:= dmmain.CDSquery2.RecordCount+1;
except
end;
if not dmmain.CDSquery2.IsEmpty then //返回记录集为空时在往下走要报错,Wy
begin
//
edit1.Text:=ForMatDateTime('yyyy''-''mm''-''dd',dmmain.CDSquery2.FieldValues['Copy_Date']);
edit2.Text:=dmmain.CDSquery2.FieldValues['Stock_NO'];
edit3.Text:=dmmain.CDSquery2.FieldValues['Storage_NO'];
Edit_Storage_Name.Text:=dmmain.CDSquery2.FieldValues['Shop_NO'];
edit5.Text:=dmmain.CDSquery2.FieldValues['Transactor'];
edit6.Text:=dmmain.CDSquery2.FieldValues['Proposer'];
edit7.Text:=dmmain.CDSquery2.FieldValues['Condense'];
edit8.Text:=dmmain.CDSquery2.FieldValues['R_Remark'];
//******************
for i:=1 to dmmain.CDSquery2.RecordCount do //wy edit;
begin
StringGrid1.Cells[0,i]:=IntTostr(i); //表示第0列第i行的名称
StringGrid1.Cells[1,i]:=trim(dmmain.CDSquery2.FieldByName('Goods_NO').AsString);
StringGrid1.Cells[2,i]:=trim(dmmain.CDSquery2.FieldByName('Goods_Name').AsString);
StringGrid1.Cells[3,i]:=trim(dmmain.CDSquery2.fieldbyname('R_Amount').AsString);
StringGrid1.Cells[4,i]:=trim(dmmain.CDSquery2.FieldByName('Base_unit').AsString);
StringGrid1.Cells[5,i]:=trim(dmmain.CDSquery2.FieldByName('Norms_Type').AsString);
StringGrid1.Cells[6,i]:=trim(dmmain.CDSquery2.FieldByName('type').AsString);
StringGrid1.Cells[7,i]:=trim(dmmain.CDSquery2.FieldByName('brand').AsString);
StringGrid1.Cells[8,i]:=trim(dmmain.CDSquery2.FieldByName('breed').AsString);
StringGrid1.Cells[9,i]:=trim(dmmain.CDSquery2.FieldByName('Color').AsString);
StringGrid1.Cells[10,i]:=trim(dmmain.CDSquery2.FieldByName('ball').AsString);
StringGrid1.Cells[11,i]:=trim(dmmain.CDSquery2.FieldByName('poll').AsString);
StringGrid1.Cells[12,i]:=trim(dmmain.CDSquery2.FieldByName('provider').AsString);
StringGrid1.Cells[13,i]:=trim(dmmain.CDSquery2.FieldByName('barcode').AsString);
StringGrid1.Cells[14,i]:=trim(dmmain.CDSquery2.FieldByName('brand').AsString);
StringGrid1.Cells[15,i]:=trim(dmmain.CDSquery2.FieldByName('Remark').AsString);
dmmain.CDSquery2.Next;
end;
dmmain.cdsprintmaster.Close;
dmmain.cdsprintmaster.Data:=null;
dmmain.cdsprintmaster.Data:=dmmain.CDSquery2.data; //将数据转入打印
dmmain.cdsprintmaster.Open;
dmmain.CDSquery2.Close;
dmmain.CDSquery2.Data:=null;
spbprint.Enabled:=true;
end else
begin
application.MessageBox('此需求单已不存在,请核对后更正!',pchar(application.Title),mb_iconinformation);
end;
end;
end;
procedure Tfrm_Goods_Requirement.Cmd_DeleteClick(Sender: TObject);
var
i:shortint;
begin
{ if StringGrid1.col<>0 then
begin
StringGrid1.Rows[StringGrid1.Row].Clear; //删除选中行的所有列 ,用右键弹出菜单
DeleteRow(StringGrid1.Row);
end;
for i:=1 to StringGrid1.RowCount do
StringGrid1.cells[0,i]:=inttostr(i);}
deletegridrows(stringgrid1,prow);
end;
procedure Tfrm_Goods_Requirement.Cmd_AddClick(Sender: TObject);
var
i:integer;
begin
StringGrid1.RowCount:=StringGrid1.RowCount+1;
Total_Count:=StringGrid1.RowCount;
for i:=1 to StringGrid1.RowCount-1 do
begin
StringGrid1.Cells[0,i]:=IntTostr(i); //表示第0列第i行
end;
end;
procedure Tfrm_Goods_Requirement.Edit1DblClick(Sender: TObject);
begin
Edit1.Text:=ForMatDateTime('yyyy''-''mm''-''dd',now);
end;
procedure Tfrm_Goods_Requirement.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if Key=#13 then
begin
Edit1.Text:=ForMatDateTime('yyyy''-''mm''-''dd',now);
end;
end;
procedure Tfrm_Goods_Requirement.StringGrid1DblClick(Sender: TObject);
var
SqlText:string;
sqlsub:widestring;
i:integer;
begin
if pcol in [1,2] then
begin
fmgoodCodeSelStr:= TfmgoodCodeSelStr.Create(self);
try
fmgoodcodeselStr.show_mode:='10';
fmgoodcodeselStr.ShowModal;
finally
fmgoodcodeselStr.Free;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -