sqbinput.pas
来自「一个仓库管理中的子系统--采购子系统」· PAS 代码 · 共 1,776 行 · 第 1/4 页
PAS
1,776 行
while not eof do
begin
jhyCombo.Items.Add(FieldByName('jhyId').asstring);
next;
end;
close;
end;
with datamodule1.PublicQuery1 do
begin
sql.Clear;
sql.Add('select * From dbo.a_zfsqbjl');
prepare;
open;
zfsqbCombo.Items.Clear;
while not eof do
begin
zfsqbCombo.Items.Add(FieldByname('zfsqbid').asstring);
next;
end;
close;
end;
//自动生成当前录入申请表单的ID号
sqbidpanel.Caption:=GetsqBdid;
if_reused:=sqbidpanel.Caption;//给判断是否重用已经作废的申请表ID的变量if_reused赋值
//初始化窗口中的所有编辑窗口的显示值
InitInputFrm;
//使添加按钮不可用
AppendBtnR.Enabled:=False;
AppendBtnG.Enabled:=false;
NewbtnG.Enabled:=False;
newBtnR.Enabled:=False;
with datamodule1.PublicQuery1 do
begin
sql.Clear;
sql.Add('select * From dbo.a_cgsqzb');
prepare;
open;
zdCount.Caption:=IntToStr(RecordCount);
close;
end;
//修改状态条
with statusbar1.Panels.Items[1] do
begin
Text:='请您输入新的申请表中的记录!';
end;
end;
//判断用户输入的产品编号是否正确
procedure TsqinputForm.cpbhComboExit(Sender: TObject);
var cpkind:string;
begin
{if length(Cpbhedit.Text)<11 then
begin
messagedlg('您输入的产品编号不符合规范,请重新输入或不填!',mtInformation,[mbOK],0);
exit;
end;}
if cpbhedit.Text<>'' then
begin
cpkind:=copy(cpbhedit.Text,1,2);
with datamodule1.publicquery1 do
begin
close;
sql.clear;
sql.add('select gysmc from dbo.e_fczfzb');
sql.add('where gysid like '+''''+cpkind+'%'+'''');
open;
first;
sccjCombo.Items.Clear;
while not eof do
begin
sccjCombo.Items.Add(FieldByName('gysmc').asstring);
next;
end;
close;
end;
end;
end;
procedure TsqinputForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
with datamodule1 do
begin
cgsqzbTable.close;
cgsqxbTable.close;
hzglTable.close;
publicquery1.close;
end;
end;
Function TsqinputForm.ShowMeDate(Date709str:string):string;
var ShowDatestr:string;
begin
ShowDatestr:=Copy(Date709str,1,4);
ShowDatestr:=ShowDatestr+'-';
ShowDatestr:=ShowDatestr+Copy(Date709str,5,2);
ShowDatestr:=ShowDatestr+'-';
ShowDatestr:=ShowDatestr+Copy(Date709str,7,2);
result:=ShowDatestr;
end;
Function TsqInputForm.GetDate709(datestr:string):string;
var date709str:string;
begin
date709str:=Copy(datestr,1,4);
date709str:=date709str+Copy(datestr,6,2);
date709str:=date709str+Copy(datestr,9,2);
result:=date709str;
end;
Procedure TsqInputForm.CheckDateEdit(datestr:string);
var checkstr:string;
begin
Checkstr:=copy(datestr,3,1);
if Checkstr<>'-' then
begin
Checkstr:=Copy(datestr,5,1);
if Checkstr<>'-' then
messageDlg('您输入的日期格式不正确,正确的格式为'+#13+
'例如:2001-01-01',mtInformation,[mbOK],0)
else
begin
Checkstr:=copy(datestr,8,1);
if Checkstr<>'-' then
messageDlg('您输入的日期格式不正确,正确的格式为'+#13+
'例如:2001-01-01',mtInformation,[mbOK],0)
end;
end
else
begin
Checkstr:=copy(datestr,6,1);
if Checkstr<>'-' then
messageDlg('您输入的日期格式不正确,正确的格式为'+#13+
'例如:2001-01-01',mtInformation,[mbOK],0);
end;
end;
procedure TsqinputForm.sqrqDateCloseUp(Sender: TObject);
begin
sqrqedit.Text:=ShowMeDate(DateTo709str(sqrqDate.Date));
end;
procedure TsqinputForm.bzrqDateCloseUp(Sender: TObject);
begin
bzrqedit.Text:=ShowMeDate(DateTo709str(bzrqDate.Date));
end;
procedure TsqinputForm.xqrqDateCloseUp(Sender: TObject);
begin
xqrqedit.Text:=ShowMeDate(DateTo709str(xqrqDate.Date));
end;
procedure TsqinputForm.shrqDateCloseUp(Sender: TObject);
begin
shrqedit.Text:=ShowMeDate(DateTo709str(shrqDate.Date));
end;
procedure TsqinputForm.pzrqDateCloseUp(Sender: TObject);
begin
pzrqedit.Text:=ShowMeDate(DateTo709str(pzrqDate.Date));
end;
procedure TsqinputForm.sqrqEditExit(Sender: TObject);
begin
CheckDateEdit(sqrqedit.Text);
end;
procedure TsqinputForm.bzrqEditExit(Sender: TObject);
begin
CheckDateEdit(bzrqedit.Text);
end;
procedure TsqinputForm.xqrqEditExit(Sender: TObject);
begin
CheckDateEdit(xqrqedit.Text);
end;
procedure TsqinputForm.shrqEditExit(Sender: TObject);
begin
CheckDateEdit(shrqedit.Text);
end;
procedure TsqinputForm.pzrqEditExit(Sender: TObject);
begin
CheckDateEdit(pzrqedit.Text);
end;
procedure TsqinputForm.AppendBtnGClick(Sender: TObject);
begin
with datamodule1 do
begin
cgsqxbTable.open;
cgsqxbTable.append;
end;
AppendBtnG.Enabled:=False;
PostBtnG.Enabled:=True;
newbtnG.Enabled:=False;
AppendBtnR.Enabled:=False;
PostBtnR.Enabled:=True;
newBtnR.Enabled:=False;
initstringGrid;
end;
procedure TsqinputForm.PostBtnGClick(Sender: TObject);
var I,J,count:integer;
begin
count:=0;
if sqdwCombo.Text='' then //申请单位不为空
begin
messageDlg('您没有输入申请单位名,请您输入申请单位!',mtInformation,[mbOK],0);
exit;
end;
if sqrqEdit.Text=showmeDate(dateTo709str(Date)) then
if messageDlg('您是否确定使用当前系统日期?如果不是'+#13+
'请按下CANCEL 按钮,然后修改日期!',mtInformation,[mbOK,mbCANCEL],0)=mrCancel then
exit;
For I:=1 to stringGrid1.RowCount-1 do //不能有相同的产品编号出现在同一张申请单中
with stringGrid1 do
if (cells[1,I]='') and (Cells[2,I]='') and (Cells[3,I]='') and (cells[4,I]='') and (Cells[5,I]='') and (Cells[6,I]='0.0') then
begin
if I=1 then
begin
showmessage('您没有输入任何记录到申请表!');
exit;
end;
break;
end
else
count:=count+1;
if count>0 then
for I:=1 to count do
if length(stringGrid1.Cells[2,I])<>11 then
begin
showmessage('请输入十一位的产品编号!');
exit;
end;
if count>0 then
for I:=1 to Count do
begin
with datamodule1.PublicQuery1 do
begin
close;
sql.Clear;
sql.Add('select * From dbo.a_cgsqxb');
sql.Add('where sqbid='+''''+sqbidpanel.caption+''''+' and cpbh='+''''+stringgrid1.cells[2,I]+'''');
prepare;
open;
if recordCount<>0 then
begin
showmessage('您不能在同一张申请表中输入两个产品编号相同的记录,请合并记录!');
close;
exit;
end;
end;
end;
if count>1 then
For I:=1 to count-1 do
For J:=I+1 to count do
if stringGrid1.cells[2,I]=stringGrid1.cells[2,J] then
begin
showmessage('您不能在同一张申请表中输入两个产品编号相同的记录,请合并记录!');
exit;
end;
For I:=1 to stringGrid1.RowCount-1 do
begin
with stringGrid1 do
begin
with stringGrid1 do
if (cells[1,I]='') and (Cells[2,I]='') and (Cells[3,I]='') and (cells[4,I]='') and (Cells[5,I]='') and (Cells[6,I]='0.0') then
break
else
if (Cells[1,I]='') then
begin
showMessage('请您输入第'+inttostr(I)+'记录的计划员!');
exit;
end
else
if (Cells[2,I]='') or (Cells[3,I]='') or (cells[4,I]='') or (Cells[5,I]='') or (Cells[6,I]='0.0') then
begin
showmessage('您没有输入第'+inttostr(I)+'记录中的产品名称、型号规格、要申报的数量和计量单位!');
exit;
end;
end;
end;
if beforepostsqzb=0 then
if not postTosqzb then
exit;
if not postFromGrid then
exit;
showmessage('你录入的所有记录已经成功提交!');
AppendBtnG.Enabled:=True;
postBtnG.Enabled:=false;
newBtnG.Enabled:=True;
AppendBtnR.Enabled:=True;
postBtnR.Enabled:=false;
NewBtnR.Enabled:=True;
end;
procedure TsqinputForm.GjhyComboChange(Sender: TObject);
begin
stringGrid1.cells[1,MyRowCount]:=GjhyCombo.Text;
end;
procedure TsqinputForm.GjldwComboChange(Sender: TObject);
begin
stringGrid1.cells[5,MyRowCount]:=GjldwCombo.Text;
end;
procedure TsqinputForm.GsccjComboChange(Sender: TObject);
begin
stringGrid1.cells[8,MyRowCount]:=GsccjCombo.Text;
end;
procedure TsqinputForm.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
MyRowCount:=Arow;
{if (ACol=3) or (ACol=4) then
with StringGrid1 do
begin
if (GoEditing in Options) then
Options:=Options-[GoEditing];
end
else}
if ACol=1 then
begin
DisplayComponent(GjhyCombo);
GjldwCombo.Visible:=False;
GsccjCombo.Visible:=False;
end
else
if ACol=5 then
begin
DisplayComponent(GjldwComBo);
GjhyCombo.Visible:=False;
GsccjCombo.Visible:=False;
end
else
if ACol=8 then
begin
DisplayComponent(GsccjCombo);
GjhyCombo.Visible:=False;
GjldwCombo.Visible:=False;
end
else
begin
GjhyCombo.Visible:=False;
GjldwCombo.Visible:=False;
GsccjCombo.Visible:=False;
with StringGrid1 do
begin
if not (GoEditing in Options) then
Options:=Options+[GoEditing];
end;
end;
end;
procedure TsqinputForm.StringGrid1DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState); //初始化StringGrid控件
begin
with Sender as TStringGrid do
begin
if gdFocused in State then
begin
if ACol=1 then
begin
GjhyCombo.SetBounds(
Rect.Left+StringGrid1.left+1,
Rect.Top+StringGrid1.Top+1,
Rect.Right-Rect.Left+1,
StringGrid1.DefaultRowHeight);
Canvas.DrawFocusRect(Rect);
end;
if ACol=5 then
begin
GjldwCombo.SetBounds(
Rect.Left+StringGrid1.left+1,
Rect.Top+StringGrid1.Top+1,
Rect.Right-Rect.Left+1,
StringGrid1.DefaultRowHeight);
Canvas.DrawFocusRect(Rect);
end;
if ACol=8 then
begin
GsccjCombo.SetBounds(
Rect.Left+StringGrid1.left+1,
Rect.Top+StringGrid1.Top+1,
Rect.Right-Rect.Left+1,
StringGrid1.DefaultRowHeight);
Canvas.DrawFocusRect(Rect);
end;
end;
end;
end;
procedure TsqinputForm.NewBtnGClick(Sender: TObject);
begin
if MessageDlg('您是否已经完成了本申请表中所有记录的录入工作?'+#13+
'如果是的请按下 OK 按钮,如果没有完成请按下CANCEL'+#13+
'按钮接续录入本申请表中的记录!',mtInformation,[mbOK,mbCANCEL],0)=mrCancel then
exit;
with dataModule1.PublicQuery1 do
begin
Close;
sql.Clear;
sql.Add('select * from dbo.a_cgsqzb');
sql.Add('where sqbid='+''''+sqbidPanel.Caption+'''');
open;
if RecordCount=0 then
begin
showMessage('您还没有开始当前这张表的录入,请先开始当前这张表的录入!');
exit;
end;
close;
end;
if datamodule1.cgsqxbTable.State=dsInsert then
begin
showmessage('您现在还处在记录录入状态,请继续输入记录!');
exit;
end;
{For I:=1 to stringGrid1.RowCount-1 do //不能有相同的产品编号出现在同一张申请单中
For J:=1 to stringGrid1.RowCount-1 do
if stringGrid1.cells[2,I]=stringGrid1.cells[2,J] then
begin
showmessage('您不能在同一张申请表中输入两个产品编号相同的记录,请合并记录!');
close;
exit;
end;
For I:=1 to stringGrid1.RowCount-1 do
begin
with stringGrid1 do
begin
if (cells[1,I]='') and (Cells[2,I]='') and (Cells[3,I]='') and (cells[4,I]='') and (Cells[5,I]='') and (Cells[6,I]='0.0') then
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?