📄 input.pas
字号:
end;
Close;
end;
except
MainForm.PshowMessage('系统错误','保存新数据至数据库时失败!',0);
end;
end;
procedure TInputForm.FormCreate(Sender: TObject);
begin
DataInputStringGrid.Cells[1,0] := '码长';
DataInputStringGrid.Cells[2,0] := '净重';
DataInputStringGrid.Cells[3,0] := '毛重';
SelectPrintStringGrid.Cells[1,0] := '码长';
SelectPrintStringGrid.Cells[2,0] := '净重';
SelectPrintStringGrid.Cells[3,0] := '毛重';
end;
procedure TInputForm.mcEditKeyPress(Sender: TObject; var Key: Char);
var i:integer;
DataCheck :boolean;
begin
if Key=#13 then
begin
DataCheck := true;
for i:=1 to DataInputStringGrid.RowCount-1 do
begin
if DataInputStringGrid.Cells[1,i]='' then
break;
end;
if StrToFloat(mcEdit.Text)>300 then
begin
if not MainForm.PshowMessage('提示','你输入数据太大,可能有误,确定吗?',1) then
begin
DataCheck := false;
mcEdit.SelectAll;
end;
end;
if DataCheck then
begin
if (MzEdit.Text <>'') and (KcEdit.Text<>'') then
begin
DataInputStringGrid.Cells[3,i] :=FloatToStr(StrToFloat(mcEdit.text) * StrToFloat(MzEdit.text));
DataInputStringGrid.Cells[2,i] :=FloatToStr(StrToFloat(mcEdit.text) * StrToFloat(MzEdit.text)-StrToFloat(KcEdit.text));
DataInputStringGrid.Cells[3,i] :=Format('%8.1f',[StrToFloat(DataInputStringGrid.Cells[3,i])]);
DataInputStringGrid.Cells[2,i] :=Format('%8.1f',[StrToFloat(DataInputStringGrid.Cells[2,i])]);
DataInputStringGrid.Cells[1,i] :=mcEdit.Text;
mcEdit.SelectAll;
end else
MainForm.PshowMessage('提示','一定要输入码重与扣除,不能为空,即使为0也要输入!',0);
end;
end;
end;
procedure TInputForm.CfNoteEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_F3 then
begin //修改调出的库存成份
if CfNoteEdit.text<>'' then
begin
CfnrEdit.text := CfnrEdit.text+CfNoteEdit.Text+'% '+CfComboBox.Text+' ';
CfComboBox.SetFocus;
end else
KhpmEdit.SetFocus;
end;
end;
procedure TInputForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (ssCtrl in Shift) and (Key=Word('I')) then
InputSpeedButtonClick(nil);
end;
procedure TInputForm.SaveSpeedButtonClick(Sender: TObject);
var CheckData :boolean;
ErrorMess :string;
SaveClient :integer;
begin
CheckData := true;
ErrorMess := InputCheckData;
if ErrorMess <>'' then
begin
MainForm.PshowMessage('提示',ErrorMess,0);
CheckData := false;
end;
if CheckData then
begin //保存数据
try
//保存主表数据
MDataForm.DataADOConnection.BeginTrans;
with MDataForm.InputMasterADOQuery do
begin
Close;
SQL.Clear;
SQL.Add('Insert Into MasterData Values(:OrderNo, :InDate, :ClientName, '+
':ClientBreed, :BreedName, :ColorNo, :Width, :cf, :gh, :htbh, :dyzb)');
Parameters.ParamByName('OrderNo').Value := OrderNoEdit.Text;
Parameters.ParamByName('InDate').Value := Date;
Parameters.ParamByName('ClientName').Value := ClientNameComboBox.Text;
Parameters.ParamByName('ClientBreed').Value := KhpmEdit.Text;
Parameters.ParamByName('BreedName').Value := CpmcComboBox.Text;
Parameters.ParamByName('ColorNo').Value := ShStyleComboBox.Text +' '+ShEdit.Text;
Parameters.ParamByName('Width').Value := WidthEdit.Text;
Parameters.ParamByName('cf').Value := Trim(CfnrEdit.Text);
Parameters.ParamByName('gh').Value := GhEdit.Text;
Parameters.ParamByName('htbh').Value := HtbhEdit.Text;
Parameters.ParamByName('dyzb').Value := DyzbEdit.Text;
ExecSQL;
end;
//保存从表数据
for SaveClient :=1 to DataInputStringGrid.RowCount-1 do
begin
if DataInputStringGrid.Cells[1,SaveClient]<>'' then
begin
with MDataForm.InputClientADOQuery do
begin
Close;
SQL.Clear;
SQL.Add('Insert Into ClientData Values(:OrderNO, :bh, :mc, :jz, :mz)');
Parameters.ParamByName('OrderNO').Value := OrderNoEdit.Text;
Parameters.ParamByName('bh').Value := StrToInt(DataInputStringGrid.Cells[0,SaveClient]);
Parameters.ParamByName('mc').Value := StrToFloat(DataInputStringGrid.Cells[1,SaveClient]);
Parameters.ParamByName('jz').Value := StrToFloat(DataInputStringGrid.Cells[2,SaveClient]);
Parameters.ParamByName('mz').Value := StrToFloat(DataInputStringGrid.Cells[3,SaveClient]);
ExecSQL;
end;
end;
end;
MDataForm.DataADOConnection.CommitTrans;
MainForm.PshowMessage('提示','数据已经成功保存至数据库!',0);
mcEdit.ReadOnly := true;
except
MDataForm.DataADOConnection.RollbackTrans;
MainForm.PshowMessage('系统错误','保存数据至服务器时失败!'+#13+
'请检查数据的有效性,比如数据输入字母之类。',0);
end;
end;
end;
procedure TInputForm.ClearSpeedButtonClick(Sender: TObject);
var Cleari, Clearj :integer;
begin
if MainForm.PshowMessage('提示','是否确定要清除界面数据?',1) then
begin
for Cleari :=0 to ComponentCount-1 do
begin
if Components[Cleari] is TEdit then
(Components[Cleari] as TEdit).Text :='';
if Components[Cleari] is TComboBox then
(Components[Cleari] as TComboBox).Text :='';
end;
with DataInputStringGrid do
begin
for Cleari :=1 to RowCount-1 do
for Clearj :=0 to ColCount-1 do
Cells[Clearj,Cleari] :='';
end;
with SelectPrintStringGrid do
begin
for Cleari :=1 to RowCount-1 do
for Clearj :=0 to ColCount-1 do
Cells[Clearj,Cleari] :='';
end;
end;
end;
function TInputForm.InputCheckData: string;
var checki :integer;
begin
//检查输入数据的正确性
Result :='';
if OrderNoEdit.Text='' then
begin
Result :='请先按一下输入清单,生成一个清单编号!';
Exit;
end;
if ClientNameComboBox.Text ='' then
begin
Result :='请输入客户名称!';
exit;
end;
if CpmcComboBox.Text='' then
begin
Result :='请输入品种名称,可以按F3功能键!';
exit;
end;
if CfnrEdit.Text='' then
begin
Result :='请输入成份内容!';
exit;
end;
if (ShStyleComboBox.Text='') or (ShEdit.Text='') then
begin
Result :='请输入色号内容!';
Exit;
end;
if WidthEdit.Text='' then
begin
Result :='请输入幅宽!';
Exit;
end;
if GhEdit.Text='' then
begin
Result :='请输入缸号!';
Exit;
end;
if KhpmEdit.Text='' then
begin
Result :='请输入客户名称!';
Exit;
end;
for checki:=1 to DataInputStringGrid.RowCount-1 do
begin
if DataInputStringGrid.Cells[1,checki]='' then
Break;
end;
if Checki<2 then Result :='至少需要输入一条详细记录!';
end;
procedure TInputForm.PrintTotalSpeedButtonClick(Sender: TObject);
begin
//打印清单
if PrintComboBox.Text='出口发货单' then
begin
end;
if PrintComboBox.Text='内销发货单' then
begin
end;
if PrintComboBox.Text='卡片' then
begin
end;
end;
procedure TInputForm.SelectPrintStringGridDblClick(Sender: TObject);
var SelRow, ClearI :integer;
begin
SelRow :=SelectPrintStringGrid.Selection.Top;
with SelectPrintStringGrid do
begin
for ClearI:=0 to ColCount-1 do
Cells[ClearI,SelRow] := '';
end;
end;
procedure TInputForm.DataInputStringGridDblClick(Sender: TObject);
var SelRow, SpaceNo, SendI :integer;
begin
For SpaceNo:=1 to SelectPrintStringGrid.RowCount-1 do
begin
if SelectPrintStringGrid.Cells[0,SpaceNO]='' then
Break;
end;
SelRow :=DataInputStringGrid.Selection.Top;
with SelectPrintStringGrid do
begin
for SendI:=0 to ColCount-1 do
Cells[SendI,SpaceNo] := DataInputStringGrid.Cells[SendI,SelRow];
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -