📄 bas_customer_d.pas
字号:
''''+Edt_CustomerClass1.text+''','+
''''+Edt_CustomerClass2.text+''','+
''''+Edt_CustomerClass3.text+''','+
''''+Edt_CustomerClass4.text+''','+
''''+Edt_CustomerClass5.text+''')');
ExecSQL;
end
end
else
begin
with AdoQry_Tmp do
begin
Close;
SQL.clear;
sql.Add('update customer set '+
'customerCode='''+Edt_CustomerCode.text+''','+
'customerName='''+Edt_CustomerName.text+''','+
'customershortName='''+Edt_CustomershortName.text+''','+
'AreaCode='+quotedstr(Trim(edt_AreaCode.text))+','+
'customerShipModeCode='+quotedstr(Trim(edt_ShipModeCode.text))+','+
'customercurrencyCode='+quotedstr(Trim(edt_CurrencyCode.text))+','+
'customerPayTermCode='+quotedstr(Trim(edt_PayTermCode.text))+','+
'customerSaleTypeCode='+quotedstr(Trim(edt_SaleTypeCode.text))+','+
'customerSaleDeptCode='+quotedstr(Trim(edt_DeptCode.text))+','+
'customerSaleEmployeeCode='+quotedstr(Trim(edt_EmployeeCode.text))+','+
'SalePricecontrl='+inttostr(cmb_Ctrl.Itemindex)+','+
'customercreditCtrl='+inttostr(Cmbbx_CustomercreditCtrl.Itemindex)+','+
'customercredit='+Edt_Customercredit.text+','+
'customerAddress='''+Edt_CustomerAddress.text+''','+
'customeremail='''+Edt_Customeremail.text+''','+
'customertel='''+Edt_Customertel.text+''','+
'customerfax='''+Edt_Customerfax.text+''','+
'customerbank='''+Edt_Customerbank.text+''','+
'customerbankaccno='''+Edt_Customerbankaccno.text+''','+
'customertaxrate_Percent='+Edt_Customertaxrate_Percent.text+','+
'customertaxno= '''+Edt_Customertaxno.text+''','+
'customercontact='''+Edt_Customercontact.text+''','+
'customerowner='''+Edt_Customerowner.text+''','+
'customerceo='''+Edt_Customerceo.text+''','+
'DisableShip='+inttostr(cmbbx_DisableShip.Itemindex)+','+
'SalInvoiceCancelmode='+inttostr(cmb_Cancelmode.Itemindex+1)+','+
// 'customercreatetime='''+formatdatetime('yyyy.mm.dd hh:mm:ss',now)+''','+
'customermodifytime='''+formatdatetime('yyyy.mm.dd hh:mm:ss',now)+''','+
sInvoiceArKmCode+','
+'GenerallyInvoiceArKmCode=Case When LTrim(RTrim('''+Trim(ExtEdt_GenerallyInvoiceArKmCode.Text)+'''))='''' Then Null Else '''+Trim(ExtEdt_GenerallyInvoiceArKmCode.Text)+''' end ,'
+' SepcialInvoiceArKmCode=Case When LTrim(RTrim('''+Trim(ExtEdt_SepcialInvoiceArKmCode.Text)+'''))='''' Then Null Else '''+Trim(ExtEdt_SepcialInvoiceArKmCode.Text)+''' end ,'
+UPSSaleCoStkMCode+','
+' OtherSaleCoStkmCode=Case When LTrim(RTrim('''+Trim(ExtEdt_OtherSaleCoStkmCode.Text)+'''))='''' Then Null Else '''+Trim(ExtEdt_OtherSaleCoStkmCode.Text)+''' end ,'
+'customerremArk='''+Edt_CustomerremArk.text+''','+
'customerClass1='''+Edt_CustomerClass1.text+''','+
'customerClass2='''+Edt_CustomerClass2.text+''','+
'customerClass3='''+Edt_CustomerClass3.text+''','+
'customerClass4='''+Edt_CustomerClass4.text+''','+
'customerClass5='''+Edt_CustomerClass5.text+''''+
' where customerCode='''+AdoQry_Maintain.fieldbyname('customerCode').asstring+'''');
ExecSQL;
end
end;
//给AdoQry_Item各字段赋值
with AdoQry_Maintain do
begin
fieldbyname('customerCode').asstring:=Edt_CustomerCode.text;
fieldbyname('customerName').asstring:=Edt_CustomerName.text;
fieldbyname('customershortName').asstring:=Edt_CustomershortName.text;
fieldbyname('AreaCode').asstring:=Edt_AreaCode.text;
fieldbyname('AreaName').asstring:=Edt_AreaName.text;
fieldbyname('customerShipModeCode').asstring:=Edt_ShipModeCode.text;
fieldbyname('ShipModeName').asstring:=Edt_ShipModeName.text;
fieldbyname('customercurrencyCode').asstring:=Edt_CurrencyCode.text;
fieldbyname('currencyName').asstring:=Edt_CurrencyName.text;
fieldbyname('customerPayTermCode').asstring:=Edt_PayTermCode.text;
fieldbyname('PayTermName').asstring:=Edt_PayTermName.text;
fieldbyname('customerSaleTypeCode').asstring:=Edt_SaleTypeCode.text;
fieldbyname('SaleTypeName').asstring:=Edt_SaleTypeName.text;
fieldbyname('customerSaleDeptCode').asstring:=Edt_DeptCode.text;
fieldbyname('DeptName').asstring:=Edt_DeptName.text;
fieldbyname('customerSaleEmployeeCode').asstring:=Edt_EmployeeCode.text;
fieldbyname('EmployeeName').asstring:=Edt_EmployeeName.text;
fieldbyname('SalePricecontrl').asinteger:=cmb_Ctrl.ItemIndex;
fieldbyname('customercreditCtrl').asinteger:=Cmbbx_CustomercreditCtrl.ItemIndex;
fieldbyname('customercredit').asinteger:=strtoint(Edt_Customercredit.text);
fieldbyname('customerAddress').asstring:=Edt_CustomerAddress.text;
fieldbyname('customeremail').asstring:=Edt_Customeremail.text;
fieldbyname('customertel').asstring:=Edt_Customertel.text;
fieldbyname('customerfax').asstring:=Edt_Customerfax.text;
fieldbyname('customerbank').asstring:=Edt_Customerbank.text;
fieldbyname('customerbankaccno').asstring:=Edt_Customerbankaccno.text;
fieldbyname('customertaxrate_Percent').asinteger:=strtoint(Edt_Customertaxrate_Percent.text);
fieldbyname('customertaxno').asstring:=Edt_Customertaxno.text;
fieldbyname('customercontact').asstring:=Edt_Customercontact.text;
fieldbyname('customerowner').asstring:=Edt_Customerowner.text;
fieldbyname('customerceo').asstring:=Edt_Customerceo.text;
fieldbyname('customercreatetime').asdatetime:=now;
fieldbyname('customermodifytime').asdatetime:=now;
fieldbyname('DisableShip').asinteger:=cmbbx_DisableShip.Itemindex;
fieldbyname('SalInvoiceCancelmode').asinteger:=cmb_Cancelmode.ItemIndex+1;
fieldbyname('InvoiceArKmCode').asstring:=Extedt_InvoiceArKmCodeName.Text;
fieldbyname('KmName').asstring:= Edt_InvoiceArKmName.Text;
fieldbyname('GenerallyInvoiceArKmCode').asstring:=Trim(Extedt_GenerallyInvoiceArKmCode.Text);
fieldbyname('GenerallyInvoiceArKmName').asstring:=Edt_GInvoiceArKmName.Text;
fieldbyname('SepcialInvoiceArKmCode').asstring:=Trim(Extedt_SepcialInvoiceArKmCode.Text);
fieldbyname('SepcialInvoiceArKmName').asstring:=Edt_SInvoiceArKmName.Text;
fieldbyname('SaleCoStkMCode').asstring:=ExtEDT_SaleCoStkMCode.Text;
fieldbyname('SaleCoStkmName').asstring:=ExtEdt_SaleCoStkMName.Text;
fieldbyname('OtherSaleCoStkmCode').asstring:=ExtEDT_OtherSaleCoStkmCode.Text;
fieldbyname('OtherSaleCoStkmName').asstring:=ExtEdt_OtherSaleCoStkmName.Text;
fieldbyname('customerremArk').asstring:=Edt_CustomerremArk.text;
fieldbyname('customerClass1').asstring:=Edt_CustomerClass1.text;
fieldbyname('customerClass2').asstring:=Edt_CustomerClass2.text;
fieldbyname('customerClass3').asstring:=Edt_CustomerClass3.text;
fieldbyname('customerClass4').asstring:=Edt_CustomerClass4.text;
fieldbyname('customerClass5').asstring:=Edt_CustomerClass5.text;
Post;
end;
end;
procedure TFrm_Bas_Customer_D.initSysParamName;
var
M,fieldCounts,i,j:Integer;
ItemClass:string;
begin
M:=0;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select SysParamValueC from SysParam where left(SysParamCode,13)=''customerClass'' ');
open;
while not eof do
begin
if fieldbyname('SysParamValueC').asstring<>'' then
begin
inc(M);
case M of
1:
begin
lbl_ParamName1.Visible:=True;
// lbl_ParamName1.Left :=26;
// lbl_ParamName1.Top :=348;
lbl_ParamName1.Caption :=Trim(fieldbyname('SysParamValueC').asstring)+':';
lbl_ParamName1.Left :=124-length(lbl_ParamName1.Caption)*7;
Edt_CustomerClass1.Text:=AdoQry_Maintain.fieldbyname('customerClass1').asstring;
Edt_CustomerClass1.Visible:=True;
end;
2:
begin
lbl_ParamName2.Visible:=True;
// lbl_ParamName2.Left :=321;
// lbl_ParamName2.Top :=348;
lbl_ParamName2.Caption :=Trim(fieldbyname('SysParamValueC').asstring)+':';
lbl_ParamName2.Left :=423-length(lbl_ParamName2.Caption)*7;
Edt_CustomerClass2.Text:=AdoQry_Maintain.fieldbyname('customerClass2').asstring;
Edt_CustomerClass2.Visible:=True;
end;
3:
begin
lbl_ParamName3.Visible:=True;
// lbl_ParamName3.Left :=26;
// lbl_ParamName3.top :=377;
lbl_ParamName3.Caption :=Trim(fieldbyname('SysParamValueC').asstring)+':';
lbl_ParamName3.Left :=124-length(lbl_ParamName3.Caption)*7;
Edt_CustomerClass3.Visible:=True;
Edt_CustomerClass3.Text:=AdoQry_Maintain.fieldbyname('customerClass3').asstring;
end;
4:
begin
lbl_ParamName4.Visible:=True;
// lbl_ParamName4.Left :=321;
// lbl_ParamName4.top :=377;
lbl_ParamName4.Caption :=Trim(fieldbyname('SysParamValueC').asstring)+':';
lbl_ParamName4.Left :=423-length(lbl_ParamName4.Caption)*7;
Edt_CustomerClass4.Text:=AdoQry_Maintain.fieldbyname('customerClass4').asstring;
Edt_CustomerClass4.Visible:=True;
end;
5:
begin
lbl_ParamName5.Visible:=True;
// lbl_ParamName5.Left :=26;
// lbl_ParamName5.top :=408;
lbl_ParamName5.Caption :=Trim(fieldbyname('SysParamValueC').asstring)+':';
lbl_ParamName5.Left :=124-length(lbl_ParamName5.Caption)*7;
Edt_CustomerClass5.Text:=AdoQry_Maintain.fieldbyname('customerClass5').asstring;
Edt_CustomerClass5.Visible:=True;
end;
end ;
end
else
//防止中间有一个为空的,如果有,则后面的都不理会
break;
next;
end;
end;
end;
procedure TFrm_Bas_Customer_D.Edt_CustomerCodeExit(Sender: TObject);
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
exit;
if not blankcheck(edt_CustomerCode.text,'客户代码') then
begin
TWinControl(Sender).SetFocus;
Abort;
end;
if not BlankInStrCheck(edt_CustomerCode.text,'客户代码') then
begin
TWinControl(Sender).SetFocus;
Abort;
end;
if(Add)or((not Add)and
(TEdit(Sender).Text<>AdoQry_Maintain.fieldbyname('customerCode').AsString))then
with AdoQry_Tmp do
begin
Close;
SQL.clear;
SQL.Add('Select customerCode From customer Where customerCode='''+TEdit(Sender).Text+'''');
Open;
if not eof then
begin
DispInfo('客户代码重复',1);
TWinControl(Sender).SetFocus;
Abort;
end;
end;
end;
procedure TFrm_Bas_Customer_D.Edt_CustomerNameExit(Sender: TObject);
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
exit;
if not blankcheck(edt_CustomerName.text,'客户代码') then
begin
TWinControl(Sender).SetFocus;
Abort;
end;
if pos('''',Edt_CustomerName.text)>0 then
begin
DispInfo('客户名称中含有非法字符,例如单引号!',1);
TWinControl(Sender).SetFocus;
Abort
end;
end;
procedure TFrm_Bas_Customer_D.Edt_CustomercreditExit(Sender: TObject);
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
exit;
if Trim(Edt_Customercredit.text)='' then
Edt_Customercredit.text:='0';
floatcheck(sender);
if Cmbbx_CustomercreditCtrl.text='是' then
begin
if strtofloat(Edt_Customercredit.text)<0 then
begin
DispInfo('请输入正确的信用额!',1);
Edt_Customercredit.text:='0';
TWinControl(Sender).SetFocus;
Abort;
end;
end;
end;
function TFrm_Bas_Customer_D.checknumber(tmp_Checkstring:string):boolean;
var
M:integer;
begin
Result:=True;
for M:=1 to length(tmp_Checkstring) do
begin
// if (ord(tmp_Checkstring[M])<48) or (ord(tmp_Checkstring[M])>57) then
if not (tmp_Checkstring[M] in ['0'..'9']) then
begin
Result:=False;
DispInfo('请输入数字!',1);
break;
end;
end;
end;
procedure TFrm_Bas_Customer_D.Edt_Customertaxrate_PercentExit(
Sender: TObject);
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
exit;
floatcheck(sender);
If strtofloat(Edt_Customertaxrate_Percent.text)>100 then
begin
DispInfo('税率不能大于100!',1);
TWinControl(Sender).SetFocus;
Abort;
end;
end;
procedure TFrm_Bas_Customer_D.FormCreate(Sender: TObject);
begin
inherited;
if Add then
SetFocus_Control:=Edt_CustomerCode//新增时聚焦的控件
else setfocus_Control:=edt_CustomerName;
end;
procedure TFrm_Bas_Customer_D.Cmbbx_CustomercreditCtrlExit(
Sender: TObject);
begin
inherited;
if Cmbbx_CustomercreditCtrl.text='否' then
begin
Edt_Customercredit.Text:='0';
Edt_Customercredit.ReadOnly:=True;
end
else
begin
Edt_Customercredit.ReadOnly:=False;
end;
end;
procedure TFrm_Bas_Customer_D.Edt_CustomerremArkExit(Sender: TObject);
begin
inherited;
if pos('''',edt_CustomerremArk.text)>0 then
begin
DispInfo('物料备注中含有非法字符,例如单引号!',1);
TWinControl(Sender).SetFocus;
Abort
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -