unit U_OrderInPutNew; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxMemo, cxRichEdit, ComCtrls, cxContainer, cxTextEdit, cxMaskEdit, cxButtonEdit, StdCtrls, ToolWin, DBClient, ADODB, ExtCtrls, BtnEdit, cxCalendar, cxGridBandedTableView, cxGridDBBandedTableView, Menus, RM_Common, RM_Class, RM_e_Xls, RM_GridReport, RM_System, RM_Dataset, cxCheckBox, cxGridCustomPopupMenu, cxGridPopupMenu; type TfrmOrderInPutNew = class(TForm) ToolBar1: TToolBar; TBSave: TToolButton; TBClose: TToolButton; ScrollBox1: TScrollBox; Label1: TLabel; Label2: TLabel; Label3: TLabel; OrderNo: TEdit; OrderDate: TDateTimePicker; Label5: TLabel; Label6: TLabel; Label8: TLabel; ADOTemp: TADOQuery; DataSourceZ: TDataSource; Order_SubZ: TClientDataSet; DataSource2: TDataSource; ADOZDY: TADOQuery; CDS_ZDY: TClientDataSet; WFBCodeName: TcxButtonEdit; SCXName: TcxButtonEdit; WJGName: TcxButtonEdit; ADOQuery1: TADOQuery; Label12: TLabel; CustomNoName: TcxButtonEdit; Note: TRichEdit; Label13: TLabel; ArrivalPortName: TcxButtonEdit; Label9: TLabel; WFBKZ: TEdit; Label10: TLabel; WFBHW: TEdit; Label11: TLabel; Label14: TLabel; WFBFK: TEdit; Label15: TLabel; Label16: TLabel; OrdQty: TEdit; OrdUnit: TComboBox; Label17: TLabel; Label19: TLabel; Label20: TLabel; Label21: TLabel; ETADate: TDateTimePicker; Label22: TLabel; ETDDate: TDateTimePicker; Label23: TLabel; ZGDate: TDateTimePicker; Label24: TLabel; BegRKDate: TDateTimePicker; Label25: TLabel; BegSCDate: TDateTimePicker; Day1: TEdit; Label26: TLabel; Label27: TLabel; Label28: TLabel; Day2: TEdit; Label29: TLabel; Label30: TLabel; Label31: TLabel; Day3: TEdit; Label18: TLabel; Label32: TLabel; Label33: TLabel; Label4: TLabel; Label7: TLabel; cxGrid4: TcxGrid; TVDB: TcxGridDBTableView; cxGridDBColumn1: TcxGridDBColumn; cxGridLevel3: TcxGridLevel; VDBColumn1: TcxGridDBColumn; VDBColumn2: TcxGridDBColumn; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; DataSource3: TDataSource; CDS_DB: TClientDataSet; Order_SubF: TClientDataSet; DataSourceF: TDataSource; Order_SubQ: TClientDataSet; DataSourceQ: TDataSource; ScrollBox2: TScrollBox; cxGrid3: TcxGrid; Tv3: TcxGridDBBandedTableView; v3Column1: TcxGridDBBandedColumn; v3Column2: TcxGridDBBandedColumn; v3Column3: TcxGridDBBandedColumn; v3Column4: TcxGridDBBandedColumn; v3Column5: TcxGridDBBandedColumn; cxGridLevel2: TcxGridLevel; cxGrid2: TcxGrid; Tv2: TcxGridDBBandedTableView; v2Column1: TcxGridDBBandedColumn; v2Column2: TcxGridDBBandedColumn; v2Column3: TcxGridDBBandedColumn; v2Column4: TcxGridDBBandedColumn; v2Column5: TcxGridDBBandedColumn; cxGridLevel1: TcxGridLevel; cxGrid1: TcxGrid; Tv1: TcxGridDBBandedTableView; v1Column1: TcxGridDBBandedColumn; v1Column2: TcxGridDBBandedColumn; v1Column3: TcxGridDBBandedColumn; v1Column4: TcxGridDBBandedColumn; v1Column5: TcxGridDBBandedColumn; v1Column6: TcxGridDBBandedColumn; cxGrid1Level1: TcxGridLevel; ToolBar2: TToolBar; ToolButton1: TToolButton; ToolButton2: TToolButton; TBPrint: TToolButton; v1Column7: TcxGridDBBandedColumn; v2Column6: TcxGridDBBandedColumn; v3Column6: TcxGridDBBandedColumn; v1Column8: TcxGridDBBandedColumn; v2Column7: TcxGridDBBandedColumn; v3Column7: TcxGridDBBandedColumn; v1Column9: TcxGridDBBandedColumn; v2Column8: TcxGridDBBandedColumn; v3Column8: TcxGridDBBandedColumn; ADOQueryQG: TADOQuery; RMDB_Main: TRMDBDataSet; RM2: TRMGridReport; RMXLSExport1: TRMXLSExport; Label40: TLabel; cxGrid5: TcxGrid; TvSub: TcxGridDBTableView; cxGridDBColumn2: TcxGridDBColumn; cxGridDBColumn3: TcxGridDBColumn; cxGridDBColumn4: TcxGridDBColumn; cxGridLevel4: TcxGridLevel; PanZDY: TPanel; CXGridZDY: TcxGrid; TVZDY: TcxGridDBTableView; VHelpZDYName: TcxGridDBColumn; CXGridZDYLevel1: TcxGridLevel; Button1: TButton; TvSubColumn1: TcxGridDBColumn; PopupMenu2: TPopupMenu; MenuItem1: TMenuItem; MenuItem2: TMenuItem; DataSource1: TDataSource; CDS_Sub: TClientDataSet; vSubColumn2: TcxGridDBColumn; Label41: TLabel; OrderCode: TEdit; vSubColumn3: TcxGridDBColumn; Panel1: TPanel; cxGrid6: TcxGrid; Tvsel: TcxGridDBTableView; cxGridDBColumn6: TcxGridDBColumn; cxGridDBColumn7: TcxGridDBColumn; cxGridDBColumn8: TcxGridDBColumn; cxGridDBColumn9: TcxGridDBColumn; cxGridLevel5: TcxGridLevel; vselColumn1: TcxGridDBColumn; Panel10: TPanel; Image2: TImage; Button2: TButton; Button3: TButton; DSSel: TDataSource; CDS_Sel: TClientDataSet; ADOCMD: TADOQuery; vSubColumn4: TcxGridDBColumn; PopupMenu3: TPopupMenu; MenuItem3: TMenuItem; MenuItem4: TMenuItem; vSubColumn5: TcxGridDBColumn; vSubColumn6: TcxGridDBColumn; vSubColumn7: TcxGridDBColumn; BZ: TcxButtonEdit; cxGrid7: TcxGrid; TVKCSel: TcxGridDBTableView; v1P_ChnName: TcxGridDBColumn; cxGridDBColumn5: TcxGridDBColumn; v1ShortName: TcxGridDBColumn; v1Quantity: TcxGridDBColumn; v1UnitName: TcxGridDBColumn; cxGridLevel6: TcxGridLevel; TVKCSelColumn1: TcxGridDBColumn; VKCSelColumn1: TcxGridDBColumn; CDS_KCSel: TClientDataSet; DataSource4: TDataSource; VKCSelColumn2: TcxGridDBColumn; vSubColumn9: TcxGridDBColumn; v1Column10: TcxGridDBBandedColumn; N3: TMenuItem; N4: TMenuItem; cxGridPopupMenu1: TcxGridPopupMenu; cxGridPopupMenu2: TcxGridPopupMenu; cxGridPopupMenu3: TcxGridPopupMenu; cxGridPopupMenu4: TcxGridPopupMenu; cxGridPopupMenu5: TcxGridPopupMenu; v2Column9: TcxGridDBBandedColumn; v3Column9: TcxGridDBBandedColumn; PopupMenu4: TPopupMenu; MenuItem7: TMenuItem; MenuItem8: TMenuItem; procedure TBCloseClick(Sender: TObject); procedure TVZDYCellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure Button1Click(Sender: TObject); procedure WFBCodeNameKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure TVZDYKeyPress(Sender: TObject; var Key: Char); procedure FormShow(Sender: TObject); procedure TBSaveClick(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure CustomNoNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure CustomNoNamePropertiesChange(Sender: TObject); procedure ArrivalPortNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure SCXNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure WJGNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure WFBCodeNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure WFBCodeNamePropertiesChange(Sender: TObject); procedure ArrivalPortNamePropertiesChange(Sender: TObject); procedure SCXNamePropertiesChange(Sender: TObject); procedure WJGNamePropertiesChange(Sender: TObject); procedure N1Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure Day1Change(Sender: TObject); procedure OrdQtyKeyPress(Sender: TObject; var Key: Char); procedure Day2Change(Sender: TObject); procedure Day3Change(Sender: TObject); procedure ETADateChange(Sender: TObject); procedure BegRKDateChange(Sender: TObject); procedure Tv1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Tv2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Tv3MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure v1Column2PropertiesEditValueChanged(Sender: TObject); procedure v1Column3PropertiesEditValueChanged(Sender: TObject); procedure v2Column2PropertiesEditValueChanged(Sender: TObject); procedure OrdQtyChange(Sender: TObject); procedure v3Column4PropertiesEditValueChanged(Sender: TObject); procedure TBPrintClick(Sender: TObject); procedure v1Column1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure v2Column1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure v3Column1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure MenuItem1Click(Sender: TObject); procedure MenuItem2Click(Sender: TObject); procedure cxGridDBColumn3PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure vSubColumn2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure cxGridDBColumn2PropertiesEditValueChanged(Sender: TObject); procedure TvSubColumn1PropertiesEditValueChanged(Sender: TObject); procedure Panel10MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure Image2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure vSubColumn4PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure MenuItem3Click(Sender: TObject); procedure MenuItem4Click(Sender: TObject); procedure vSubColumn5PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure BZPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure BZPropertiesChange(Sender: TObject); procedure TBChkOkClick(Sender: TObject); procedure TBChkNoClick(Sender: TObject); procedure Button4Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure N4Click(Sender: TObject); procedure MenuItem7Click(Sender: TObject); procedure MenuItem8Click(Sender: TObject); private MInt,ChkInt,CloInt:Integer; procedure InitData(); procedure ZDYHelp(FButn:TcxButtonEdit;LType:string); function SaveData():Boolean; procedure DelOrderSub(FOrder_Sub:TClientDataSet); procedure SELYCL(SCDS_Sub:TClientDataSet); procedure EditYCL(SCDS_Sub:TClientDataSet); function SaveData10():Boolean; procedure SaveYCL(SCDS_Sub:TClientDataSet); procedure YLUpdate(); procedure UpMainId(); function SaveDataMain():Boolean; function SaveDataSub():Boolean; function SaveDataDB():Boolean; function SaveDataPB():Boolean; procedure SELYCLKC(SCDS_Sub:TClientDataSet); procedure OnlyUpYCLData(); procedure YCLPBIDUPdate(SOrder_SubZ:TClientDataSet); procedure SelAll(SCDS_Sub:TClientDataSet;FSEL:Boolean); { Private declarations } public PState,BState,CopyInt:Integer; FMainId:String; FXS:Integer; { Public declarations } end; var frmOrderInPutNew: TfrmOrderInPutNew; implementation uses U_DataLink,U_ZDYHelp,U_Fun,U_GetPGJBInList; {$R *.dfm} procedure TfrmOrderInPutNew.TBCloseClick(Sender: TObject); begin WriteCxBandedGrid('配料主',Tv1,'无纺布订单'); WriteCxBandedGrid('配料辅',Tv2,'无纺布订单'); WriteCxBandedGrid('配料其它',Tv3,'无纺布订单'); WriteCxGrid('订单子表',TvSub,'无纺布订单'); WriteCxGrid('订单打包',TVDB,'无纺布订单'); {if PState<>3 then begin if Application.MessageBox('是否要保存数据?','提示',32+4)=IDYES then begin CloInt:=1; TBSave.Click; Exit; end; end; } Close; end; procedure TfrmOrderInPutNew.InitData(); var i:Integer; begin with ADOQuery1 do begin Close; SQL.Clear; sql.Add(' exec P_WFBOrder_List :begdate,:endate,:MainId'); if PState>0 then begin ADOQuery1.Parameters.ParamByName('MainId').Value:=Trim(FMainId); ADOQuery1.Parameters.ParamByName('begdate').Value:=''; ADOQuery1.Parameters.ParamByName('endate').Value:=''; end; if PState=0 then begin ADOQuery1.Parameters.ParamByName('MainId').Value:=''; ADOQuery1.Parameters.ParamByName('begdate').Value:=''; ADOQuery1.Parameters.ParamByName('endate').Value:=''; end; Open; end; // SCreateCDS20(ADOQuery1,Order_Sub); //SInitCDSData20(ADOQuery1,Order_Sub); SCSHData(ADOQuery1,ScrollBox1,0); if PState=0 then begin OrderDate.DateTime:=StrToDate(FormatDateTime('yyyy-MM-dd',SGetServerDateTime(ADOTemp))); ETADate.DateTime:=OrderDate.DateTime; ETDDate.DateTime:=OrderDate.DateTime; ZGDate.DateTime:=OrderDate.DateTime; BegRKDate.DateTime:=OrderDate.DateTime; BegSCDate.DateTime:=OrderDate.DateTime; ETADate.Checked:=False; ETDDate.Checked:=False; ZGDate.Checked:=False; BegRKDate.Checked:=False; BegSCDate.Checked:=False; end; if Trim(DParameters1)<>'审核' then begin {BegRKDate.Enabled:=False; Day3.Enabled:=False; BegSCDate.Enabled:=False; //Note.Enabled:=False; cxGrid4.Enabled:=False; {MJKZX.Enabled:=False; MJKZD.Enabled:=False; XJKZX.Enabled:=False; XJKZD.Enabled:=False;} {SCXName.Enabled:=False; WJGName.Enabled:=False; ScrollBox2.Enabled:=False; } end; if PState=4 then begin BegRKDate.Enabled:=True; Day3.Enabled:=True; BegSCDate.Enabled:=True; //Note.Enabled:=False; cxGrid4.Enabled:=True; {MJKZX.Enabled:=True; MJKZD.Enabled:=True; XJKZX.Enabled:=True; XJKZD.Enabled:=True; } SCXName.Enabled:=True; WJGName.Enabled:=True; ScrollBox2.Enabled:=True; end; with ADOQuery1 do begin Close; sql.Clear; SQL.Add('select * from WFB_DB where MainId='''+Trim(FMainId)+''''); Open; end; SCreateCDS20(ADOQuery1,CDS_DB); SInitCDSData20(ADOQuery1,CDS_DB); with ADOQuery1 do begin Close; sql.Clear; SQL.Add('select * from WFBOrder_Sub where MainId='''+Trim(FMainId)+''''); Open; end; SCreateCDS20(ADOQuery1,CDS_Sub); SInitCDSData20(ADOQuery1,CDS_Sub); with ADOQuery1 do begin Close; sql.Clear; SQL.Add('select A.*,Case when A.YLQty-A.YCLYJkc>=0 then A.YLQty-A.YCLYJkc else null end as BZ from WFBYCL_PB A where MainId='''+Trim(FMainId)+''''); sql.Add(' and PBType=''主要'' '); Open; end; SCreateCDS20(ADOQuery1,Order_SubZ); SInitCDSData20(ADOQuery1,Order_SubZ); with ADOQuery1 do begin Close; sql.Clear; SQL.Add('select A.*,Case when A.YLQty-A.YCLYJkc>=0 then A.YLQty-A.YCLYJkc else null end as BZ from WFBYCL_PB A where MainId='''+Trim(FMainId)+''''); sql.Add(' and PBType=''辅助'' '); Open; end; SCreateCDS20(ADOQuery1,Order_SubF); SInitCDSData20(ADOQuery1,Order_SubF); with ADOQuery1 do begin Close; sql.Clear; SQL.Add('select A.*,Case when A.YLQty-A.YCLYJkc>=0 then A.YLQty-A.YCLYJkc else null end as BZ from WFBYCL_PB A where MainId='''+Trim(FMainId)+''''); sql.Add(' and PBType=''其它'' '); Open; end; SCreateCDS20(ADOQuery1,Order_SubQ); SInitCDSData20(ADOQuery1,Order_SubQ); PanZDY.Visible:=False; if PState=4 then begin PState:=0; FMainId:='999999'; //OrderNo.Text:=''; WFBCodeName.Text:=''; WFBCodeName.Hint:=''; PanZDY.Visible:=False; with CDS_DB do begin First; while not Eof do begin Edit; FieldByName('DBID').Value:=''; Post; Next; end; end; with Order_SubZ do begin First; while not Eof do begin Edit; FieldByName('PBID').Value:=''; FieldByName('YLKC').Value:=0; FieldByName('YCLYJKC').Value:=0; FieldByName('BZ').Value:=0; FieldByName('SGQty').Value:=0; Post; Next; end; end; v1Column1.Options.Focusing:=True; with Order_SubF do begin First; while not Eof do begin Edit; FieldByName('PBID').Value:=''; FieldByName('YLKC').Value:=0; FieldByName('YCLYJKC').Value:=0; FieldByName('BZ').Value:=0; FieldByName('SGQty').Value:=0; Post; Next; end; end; v2Column1.Options.Focusing:=True; with Order_SubQ do begin First; while not Eof do begin Edit; FieldByName('PBID').Value:=''; FieldByName('YLKC').Value:=0; FieldByName('YCLYJKC').Value:=0; FieldByName('BZ').Value:=0; FieldByName('SGQty').Value:=0; Post; Next; end; end; v3Column1.Options.Focusing:=True; end; end; procedure TfrmOrderInPutNew.ZDYHelp(FButn:TcxButtonEdit;LType:string); var FType,ZDYName,FText:String; begin PanZDY.Visible:=True; PanZDY.Left:=FButn.Left; PanZDY.Top:=FButn.Top+FButn.Height; with ADOZDY do begin Filtered:=False; Close; SQL.Clear; SQL.Add('select RTrim(ZDYNo) ZDYNo,RTrim(ZDYName) ZDYName from KH_ZDY where Type='''+Trim(LType)+''''); Open; end; FText:=Trim(FButn.Text); if FText<>'' then SDofilter(ADOZDY,' ZDYName like '+QuotedStr('%'+Trim(FText)+'%')) else SDofilter(ADOZDY,''); VHelpZDYName.Summary.GroupFormat:=Trim(FButn.Name); end; procedure TfrmOrderInPutNew.TVZDYCellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); var FName:string; begin if ADOZDY.IsEmpty then Exit; FName:=Trim(VHelpZDYName.Summary.GroupFormat); TcxButtonEdit(FindComponent(FName)).Text:=Trim(ADOZDY.fieldbyname('ZDYName').AsString); TcxButtonEdit(FindComponent(FName)).Hint:=Trim(ADOZDY.fieldbyname('ZDYNO').AsString); PanZDY.Visible:=False; end; procedure TfrmOrderInPutNew.Button1Click(Sender: TObject); begin PanZDY.Visible:=False; end; procedure TfrmOrderInPutNew.WFBCodeNameKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (key=vk_return) or (Key=vk_Down) then begin if ADOZDY.Active then CXGridZDY.SetFocus; end; end; procedure TfrmOrderInPutNew.TVZDYKeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then begin if ADOZDY.IsEmpty then Exit; TcxButtonEdit(FindComponent(VHelpZDYName.Summary.GroupFormat)).Text:=Trim(ADOZDY.fieldbyname('ZDYName').AsString); TcxButtonEdit(FindComponent(VHelpZDYName.Summary.GroupFormat)).Hint:=Trim(ADOZDY.fieldbyname('ZDYNO').AsString); PanZDY.Visible:=False; ADOZDY.Active:=False; end; end; procedure TfrmOrderInPutNew.FormShow(Sender: TObject); var fsj:string; begin {if Trim(DParameters1)='审核' then begin TBSave.Visible:=False; //TBChkOk.Visible:=True; TBChkNo.Visible:=True; end else begin TBSave.Visible:=True; TBChkOk.Visible:=False; TBChkNo.Visible:=False; end; } fsj:=FormatDateTime('yyyy-MM-dd',SGetServerDate(ADOTemp)); if ( (Trim(FMainId)='') or (CopyInt=1)) then begin with ADOTemp do begin Close; sql.Clear; sql.Add('select Count(*) As SL from WFBOrder_Main where OrderDate='''+Trim(fsj)+''''); sql.Add(' and MainId not like ''%FZ'' '); Open; end; if ADOTemp.IsEmpty then begin fsj:=fsj+'-1' end else fsj:=fsj+'-'+Trim(IntToStr(ADOTemp.fieldbyname('SL').AsInteger+1)); OrderCode.Text:=Trim(fsj); end; InitData(); ReadCxBandedGrid('配料主',Tv1,'无纺布订单'); ReadCxBandedGrid('配料辅',Tv2,'无纺布订单'); ReadCxBandedGrid('配料其它',Tv3,'无纺布订单'); ReadCxGrid('订单子表',TvSub,'无纺布订单'); ReadCxGrid('订单打包',TVDB,'无纺布订单'); end; function TfrmOrderInPutNew.SaveDataMain():Boolean; var maxno,FSubId:String; begin try Result:=False; ADOCmd.Connection.BeginTrans; ///保存主表 if Trim(FMainId)='' then begin if GetLSNo(ADOTemp,maxno,'','WFBOrder_Main',2,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('生成流水号异常!','提示',0); exit; end; end else begin maxno:=Trim(FMainId); end; with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from WFBOrder_Main where MainId='''+Trim(FMainId)+''''); Open; end; with ADOCmd do begin if Trim(FMainId)='' then begin Append; end else begin Edit; end; FieldByName('MainId').Value:=Trim(maxno); FieldByName('OrderType').Value:='卷材'; FieldByName('OrderNo').Value:='11'; SSetsaveSql(ADOCmd,'WFBOrder_Main',ScrollBox1,0); if PState=2 then begin FieldByName('Chker').Value:=Trim(DName); FieldByName('ChkTime').Value:=SGetServerDateTime(ADOTemp); if ChkInt=1 then FieldByName('ChkStatus').Value:='审核通过' else if ChkInt=2 then FieldByName('ChkStatus').Value:='审核不通过'; end; if Trim(FMainId)='' then begin FieldByName('Filler').Value:=Trim(DName); end else begin if Trim(FMainId)<>'' then begin FieldByName('Editer').Value:=Trim(DName); FieldByName('EditTime').Value:=SGetServerDateTime(ADOTemp); end; end; Post; end; FMainId:=Trim(maxno); ADOCmd.Connection.CommitTrans; Result:=True; except Result:=False; ADOCmd.Connection.RollbackTrans; Application.MessageBox('保存主表异常!','提示',0); end; end; function TfrmOrderInPutNew.SaveDataSub():Boolean; var maxno,FSubId:String; begin try Result:=False; ADOCmd.Connection.BeginTrans; ///保存详单 with CDS_Sub do begin First; while not Eof do begin if Trim(CDS_Sub.fieldbyname('SubId').AsString)='' then begin if GetLSNo(ADOCmd,maxno,'','WFBOrder_Sub',3,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取子流水号失败!','提示',0); Exit; end; end else begin maxno:=Trim(CDS_Sub.fieldbyname('SubId').AsString); end; with ADOCmd do begin Close; SQL.Clear; sql.Add('select * from WFBOrder_Sub '); sql.Add(' where SubId='''+Trim(maxno)+''''); Open; end; with ADOCmd do begin if Trim(CDS_Sub.fieldbyname('SubId').AsString)='' then Append else Edit; FieldByName('MainId').Value:=Trim(FMainId); FieldByName('SubId').Value:=Trim(maxno); FieldByName('SWFBCode').Value:=Trim(CDS_Sub.fieldbyname('SWFBCode').AsString); SSetSaveDataCDSNew(ADOCmd,TvSub,CDS_Sub,'WFBOrder_Sub',0); Post; end; CDS_Sub.Edit; CDS_Sub.FieldByName('SubId').Value:=Trim(maxno); //CDS_Sub.Post; Next; end; end; ADOCmd.Connection.CommitTrans; Result:=True; except Result:=False; ADOCmd.Connection.RollbackTrans; Application.MessageBox('保存子表失败!','提示',0); end; end; function TfrmOrderInPutNew.SaveDataDB():Boolean; var maxno,FSubId:String; begin try Result:=False; ADOCmd.Connection.BeginTrans; ///保存打包详细 if Trim(CDS_DB.fieldbyname('DBId').AsString)='' then begin if GetLSNo(ADOCmd,maxno,'DB','WFB_DB',3,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取子流水号失败!','提示',0); Exit; end; end else begin maxno:=Trim(CDS_DB.fieldbyname('DBId').AsString); end; with CDS_DB do begin First; while not Eof do begin with ADOCmd do begin Close; SQL.Clear; sql.Add('select * from WFB_DB '); sql.Add(' where DBId='''+Trim(maxno)+''''); Open; end; with ADOCmd do begin if Trim(CDS_DB.fieldbyname('DBId').AsString)='' then Append else Edit; FieldByName('MainId').Value:=Trim(FMainId); FieldByName('DBId').Value:=Trim(maxno); SSetSaveDataCDSNew(ADOCmd,TVDB,CDS_DB,'WFB_DB',0); Post; end; CDS_DB.Edit; CDS_DB.FieldByName('DBId').Value:=Trim(maxno); //CDS_DB.Post; Next; end; end; ADOCmd.Connection.CommitTrans; Result:=True; except Result:=False; ADOCmd.Connection.RollbackTrans; Application.MessageBox('保存打包表失败!','提示',0); end; end; function TfrmOrderInPutNew.SaveDataPB():Boolean; var maxno,FSubId:String; begin try Result:=False; ADOCmd.Connection.BeginTrans; //保存主要原料 if not Order_SubZ.IsEmpty then begin with Order_SubZ do begin First; while not Eof do begin if Trim(Order_SubZ.fieldbyname('PBId').AsString)='' then begin if GetLSNo(ADOCmd,maxno,'PB','WFBYCL_PB',3,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取子流水号失败!','提示',0); Exit; end; end else begin maxno:=Trim(Order_SubZ.fieldbyname('PBId').AsString); end; with ADOCmd do begin Close; SQL.Clear; sql.Add('select * from WFBYCL_PB '); sql.Add(' where PBId='''+Trim(maxno)+''''); Open; end; with ADOCmd do begin if Trim(Order_SubZ.fieldbyname('PBId').AsString)='' then Append else Edit; FieldByName('MainId').Value:=Trim(FMainId); FieldByName('PBId').Value:=Trim(maxno); FieldByName('CRId').Value:=Trim(Order_SubZ.fieldbyname('CRID').AsString); FieldByName('PBType').Value:='主要'; // SSetSaveDataCDSNew(); SSetSaveDataCDSBandNew(ADOCmd,TV1,Order_SubZ,'WFBYCL_PB',0); Post; end; Order_SubZ.Edit; Order_SubZ.FieldByName('PBId').Value:=Trim(maxno); //Order_SubZ.Post; Next; end; end; end; //保存辅助原料 if not Order_SubF.IsEmpty then begin with Order_SubF do begin First; while not Eof do begin if Trim(Order_SubF.fieldbyname('PBId').AsString)='' then begin if GetLSNo(ADOCmd,maxno,'PB','WFBYCL_PB',3,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取子流水号失败!','提示',0); Exit; end; end else begin maxno:=Trim(Order_SubF.fieldbyname('PBId').AsString); end; with ADOCmd do begin Close; SQL.Clear; sql.Add('select * from WFBYCL_PB '); sql.Add(' where PBId='''+Trim(maxno)+''''); Open; end; with ADOCmd do begin if Trim(Order_SubF.fieldbyname('PBId').AsString)='' then Append else Edit; FieldByName('MainId').Value:=Trim(FMainId); FieldByName('PBId').Value:=Trim(maxno); FieldByName('PBType').Value:='辅助'; FieldByName('CRId').Value:=Trim(Order_SubF.fieldbyname('CRID').AsString); // SSetSaveDataCDSNew(); SSetSaveDataCDSBandNew(ADOCmd,TV2,Order_SubF,'WFBYCL_PB',0); Post; end; Order_SubF.Edit; Order_SubF.FieldByName('PBId').Value:=Trim(maxno); Order_SubF.Post; Next; end; end; end; //保存其它原料 if not Order_SubQ.IsEmpty then begin with Order_SubQ do begin First; while not Eof do begin if Trim(Order_SubQ.fieldbyname('PBId').AsString)='' then begin if GetLSNo(ADOCmd,maxno,'PB','WFBYCL_PB',3,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取子流水号失败!','提示',0); Exit; end; end else begin maxno:=Trim(Order_SubQ.fieldbyname('PBId').AsString); end; with ADOCmd do begin Close; SQL.Clear; sql.Add('select * from WFBYCL_PB '); sql.Add(' where PBId='''+Trim(maxno)+''''); Open; end; with ADOCmd do begin if Trim(Order_SubQ.fieldbyname('PBId').AsString)='' then Append else Edit; FieldByName('MainId').Value:=Trim(FMainId); FieldByName('PBId').Value:=Trim(maxno); FieldByName('PBType').Value:='其它'; FieldByName('CRId').Value:=Trim(Order_SubQ.fieldbyname('CRID').AsString); // SSetSaveDataCDSNew(); SSetSaveDataCDSBandNew(ADOCmd,TV3,Order_SubQ,'WFBYCL_PB',0); Post; end; Order_SubQ.Edit; Order_SubQ.FieldByName('PBId').Value:=Trim(maxno); Order_SubQ.Post; Next; end; end; end; ADOCmd.Connection.CommitTrans; Result:=True; except Result:=False; ADOCmd.Connection.RollbackTrans; Application.MessageBox('保存配比表失败!','提示',0); end; end; function TfrmOrderInPutNew.SaveData():Boolean; var maxno,FSubId,FFS:String; wz:Integer; begin try Result:=False; SaveDataMain(); SaveDataSub(); SaveDataDB(); SaveDataPB(); wz:=Pos('F',FMainId); FFS:=Copy(FMainId,wz,4); if ((CopyInt=1) or (FFS='FZ')) then begin UpMainId(); end; CopyInt:=0; Result:=True; except Result:=False; ADOCmd.Connection.RollbackTrans; Application.MessageBox('保存失败!','提示',0); end; end; function TfrmOrderInPutNew.SaveData10():Boolean; var maxno,FSubId:String; begin try Result:=False; SaveDataMain(); SaveDataDB(); SaveDataSub(); Result:=True; except Result:=False; ADOCmd.Connection.RollbackTrans; Application.MessageBox('保存失败!','提示',0); end; end; procedure TfrmOrderInPutNew.TBSaveClick(Sender: TObject); begin OrderDate.SetFocus; if Trim(OrderNo.Text)='' then begin Application.MessageBox('订单编号不能为空!','提示',0); Exit; end; if Trim(OrdUnit.Text)='' then begin Application.MessageBox('数量单位不能为空!','提示',0); Exit; end; {if Trim(WFBCodeName.Hint)='' then begin Application.MessageBox('代号未定义!','提示',0); Exit; end; } if CDS_DB.Locate('BSL',null,[]) then begin Application.MessageBox('包数量不能为空!','提示',0); Exit; end; if CDS_DB.Locate('JSL',null,[]) then begin Application.MessageBox('卷数量不能为空!','提示',0); Exit; end; if CDS_Sub.Locate('SWFBCodeName',null,[]) then begin Application.MessageBox('产品代号不能为空!','提示',0); Exit; end; if Order_SubZ.Locate('YLKC;YCLYJKC;BZ',VarArrayOf([0,0,0]),[]) then begin Application.MessageBox('请指定物料!','提示',0); Exit; end; if Order_SubF.Locate('YLKC;YCLYJKC;BZ',VarArrayOf([0,0,0]),[]) then begin Application.MessageBox('请指定物料!','提示',0); Exit; end; if Order_SubQ.Locate('YLKC;YCLYJKC;BZ',VarArrayOf([0,0,0]),[]) then begin Application.MessageBox('请指定物料!','提示',0); Exit; end; YLUpdate(); if SaveData()=True then begin if ChkInt>0 then begin Application.MessageBox('操作成功!','提示',0); end else Application.MessageBox('保存成功!','提示',0); if CloInt=1 then ModalResult:=1; end; end; procedure TfrmOrderInPutNew.SaveYCL(SCDS_Sub:TClientDataSet); var maxno,maxnosub:string; begin try ADOCmd.Connection.BeginTrans; with frmGetPGJBInList.ClientDataSet2 do begin First; while not Eof do begin if GetLSNo(ADOCmd,maxno,'PB','WFBYCL_PB',4,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取最大号失败!','提示',0); Exit; end; with ADOCmd do begin Close; sql.Clear; sql.Add('select * from WFBYCL_PB where 1<>1'); Open; end; with ADOCmd do begin Append; FieldByName('MainId').Value:=Trim(FMainId); FieldByName('PBId').Value:=Trim(maxno); if MInt=1 then begin FieldByName('PBType').Value:='主要'; end else if MInt=2 then begin FieldByName('PBType').Value:='辅助'; end else if MInt=3 then begin FieldByName('PBType').Value:='其它'; end; FieldByName('YCLCode').Value:=Trim(frmGetPGJBInList.ClientDataSet2.fieldbyname('YCLCode').AsString); FieldByName('YCLName').Value:=Trim(frmGetPGJBInList.ClientDataSet2.fieldbyname('YCLCode').AsString); FieldByName('YCLSpec').Value:=Trim(frmGetPGJBInList.ClientDataSet2.fieldbyname('YCLCode').AsString); FieldByName('YLKC').Value:=Trim(frmGetPGJBInList.ClientDataSet2.fieldbyname('QuantityKC').AsString); FieldByName('YLUnit').Value:=Trim(frmGetPGJBInList.ClientDataSet2.fieldbyname('CRUnit').AsString); FieldByName('CRID').Value:=Trim(frmGetPGJBInList.ClientDataSet2.fieldbyname('CRID').AsString); FieldByName('YCLYJKC').Value:=Trim(frmGetPGJBInList.ClientDataSet2.fieldbyname('YJKC').AsString); Post; end; with SCDS_Sub do begin Edit; FieldByName('MainId').Value:=Trim(FMainId); FieldByName('PBId').Value:=Trim(maxno); Post; end; with Self.CDS_Sel do begin First; while not Eof do begin if GetLSNo(ADOCmd,maxnosub,'PS','WFBYCL_PBSub',4,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取最大号失败!','提示',0); Exit; end; with ADOCmd do begin Close; sql.Clear; sql.Add('select * from WFBYCL_PBSub where 1<>1'); Open; end; with ADOCmd do begin Append; FieldByName('MainId').Value:=Trim(FMainId); FieldByName('SubId').Value:=Trim(CDS_Sel.fieldbyname('SubId').AsString); FieldByName('PBId').Value:=Trim(maxno); FieldByName('PSId').Value:=Trim(maxnosub); Post; end; Next; end; end; Next; end; end; except ADOCmd.Connection.RollbackTrans; Application.MessageBox('增加异常!','提示',0); end; end; procedure TfrmOrderInPutNew.SELYCL(SCDS_Sub:TClientDataSet); var maxno,maxnosub:string; begin try frmGetPGJBInList:=TfrmGetPGJBInList.Create(Application); with frmGetPGJBInList do begin if ShowModal=1 then begin try ADOCmd.Connection.BeginTrans; with ClientDataSet2 do begin First; while not Eof do begin with SCDS_Sub do begin Append; SCDS_Sub.FieldByName('YCLCode').Value:=Trim(ClientDataSet2.fieldbyname('YCLCode').AsString); SCDS_Sub.FieldByName('YCLName').Value:=Trim(ClientDataSet2.fieldbyname('YCLName').AsString); SCDS_Sub.FieldByName('YCLSpec').Value:=Trim(ClientDataSet2.fieldbyname('YCLSpec').AsString); SCDS_Sub.FieldByName('YLKC').Value:=Trim(ClientDataSet2.fieldbyname('QuantityKC').AsString); SCDS_Sub.FieldByName('YLUnit').Value:=Trim(ClientDataSet2.fieldbyname('CRUnit').AsString); SCDS_Sub.FieldByName('CRID').Value:=Trim(ClientDataSet2.fieldbyname('CRID').AsString); SCDS_Sub.FieldByName('YCLYJKC').Value:=Trim(ClientDataSet2.fieldbyname('YJKC').AsString); Post; end; if GetLSNo(ADOCmd,maxno,'PB','WFBYCL_PB',4,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取最大号失败!','提示',0); Exit; end; with ADOCmd do begin Close; sql.Clear; sql.Add('select * from WFBYCL_PB where 1<>1'); Open; end; with ADOCmd do begin Append; FieldByName('MainId').Value:=Trim(FMainId); FieldByName('PBId').Value:=Trim(maxno); if MInt=1 then begin FieldByName('PBType').Value:='主要'; end else if MInt=2 then begin FieldByName('PBType').Value:='辅助'; end else if MInt=3 then begin FieldByName('PBType').Value:='其它'; end; FieldByName('YCLCode').Value:=Trim(frmGetPGJBInList.ClientDataSet2.fieldbyname('YCLCode').AsString); FieldByName('YCLName').Value:=Trim(frmGetPGJBInList.ClientDataSet2.fieldbyname('YCLName').AsString); FieldByName('YCLSpec').Value:=Trim(frmGetPGJBInList.ClientDataSet2.fieldbyname('YCLSpec').AsString); FieldByName('YLKC').Value:=Trim(frmGetPGJBInList.ClientDataSet2.fieldbyname('QuantityKC').AsString); FieldByName('YLUnit').Value:=Trim(frmGetPGJBInList.ClientDataSet2.fieldbyname('CRUnit').AsString); FieldByName('CRID').Value:=Trim(frmGetPGJBInList.ClientDataSet2.fieldbyname('CRID').AsString); FieldByName('YCLYJKC').Value:=Trim(frmGetPGJBInList.ClientDataSet2.fieldbyname('YJKC').AsString); Post; end; with SCDS_Sub do begin Edit; FieldByName('MainId').Value:=Trim(FMainId); FieldByName('PBId').Value:=Trim(maxno); Post; end; with Self.CDS_Sel do begin First; while not Eof do begin if Self.CDS_Sel.FieldByName('SSel').AsBoolean=True then begin if GetLSNo(ADOCmd,maxnosub,'PS','WFBYCL_PBSub',4,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取最大号失败!','提示',0); Exit; end; with ADOCmd do begin Close; sql.Clear; sql.Add('select * from WFBYCL_PBSub where 1<>1'); Open; end; with ADOCmd do begin Append; FieldByName('MainId').Value:=Trim(FMainId); FieldByName('SubId').Value:=Trim(CDS_Sel.fieldbyname('SubId').AsString); FieldByName('PBId').Value:=Trim(maxno); FieldByName('PSId').Value:=Trim(maxnosub); Post; end; end; Next; end; end; Next; end; end; ADOQueryCmd.Connection.CommitTrans; except ADOCmd.Connection.RollbackTrans; Application.MessageBox('增加异常!','提示',0); Exit; end; //Self.SaveYCL(SCDS_Sub); end; end; finally frmGetPGJBInList.Free; end; end; procedure TfrmOrderInPutNew.SELYCLKC(SCDS_Sub:TClientDataSet); var maxno,maxnosub:string; YLPB,YLSH:Double; begin try ADOCmd.Connection.BeginTrans; with CDS_KCSel do begin First; while not Eof do begin if CDS_KCSel.FieldByName('SSel').AsBoolean=True then begin if MInt=1 then begin with ADOTemp do begin Close; SQL.Clear; sql.Add('select Top 1* from WFBYCL_PB where YCLCode='''+Trim(CDS_KCSel.fieldbyname('YCLCode').AsString)+''''); Open; end; if ADOTemp.IsEmpty=False then begin with ADOTemp do begin Close; SQL.Clear; sql.Add('select Top 1* from WFBYCL_PB where YCLCode='''+Trim(CDS_KCSel.fieldbyname('YCLCode').AsString)+''''); SQL.Add('and YLPB>0 order by FillTime desc'); Open; end; if Trim(ADOTemp.fieldbyname('YLPB').AsString)<>'' then YLPB:=ADOTemp.fieldbyname('YLPB').Value else YLPB:=0; if Trim(ADOTemp.fieldbyname('YLSH').AsString)<>'' then YLSH:=ADOTemp.fieldbyname('YLSH').Value else YLSH:=0; end else begin YLPB:=0; YLSH:=0; end; end; with SCDS_Sub do begin Append; SCDS_Sub.FieldByName('YCLCode').Value:=Trim(CDS_KCSel.fieldbyname('YCLCode').AsString); SCDS_Sub.FieldByName('YCLName').Value:=Trim(CDS_KCSel.fieldbyname('YCLName').AsString); SCDS_Sub.FieldByName('YCLSpec').Value:=Trim(CDS_KCSel.fieldbyname('YCLSpec').AsString); SCDS_Sub.FieldByName('YLKC').Value:=Trim(CDS_KCSel.fieldbyname('KCQty').AsString); SCDS_Sub.FieldByName('YLUnit').Value:=Trim(CDS_KCSel.fieldbyname('KCUint').AsString); SCDS_Sub.FieldByName('CRID').Value:=Trim(CDS_KCSel.fieldbyname('CRID').AsString); SCDS_Sub.FieldByName('YCLYJKC').Value:=Trim(CDS_KCSel.fieldbyname('YJKC').AsString); if MInt=1 then begin SCDS_Sub.FieldByName('YLPB').Value:=YLPB; SCDS_Sub.FieldByName('YLSH').Value:=YLSH; end; Post; end; //保存配料主表 if GetLSNo(ADOCmd,maxno,'PB','WFBYCL_PB',4,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取最大号失败!','提示',0); Exit; end; with ADOCmd do begin Close; sql.Clear; sql.Add('select * from WFBYCL_PB where 1<>1'); Open; end; with ADOCmd do begin Append; FieldByName('MainId').Value:=Trim(FMainId); FieldByName('PBId').Value:=Trim(maxno); if MInt=1 then begin FieldByName('PBType').Value:='主要'; end else if MInt=2 then begin FieldByName('PBType').Value:='辅助'; end else if MInt=3 then begin FieldByName('PBType').Value:='其它'; end; FieldByName('YCLCode').Value:=Trim(CDS_KCSel.fieldbyname('YCLCode').AsString); FieldByName('YCLName').Value:=Trim(CDS_KCSel.fieldbyname('YCLName').AsString); FieldByName('YCLSpec').Value:=Trim(CDS_KCSel.fieldbyname('YCLSpec').AsString); FieldByName('YLKC').Value:=Trim(CDS_KCSel.fieldbyname('KCQty').AsString); FieldByName('YLUnit').Value:=Trim(CDS_KCSel.fieldbyname('KCUint').AsString); FieldByName('CRID').Value:=Trim(CDS_KCSel.fieldbyname('CRID').AsString); FieldByName('YCLYJKC').Value:=Trim(CDS_KCSel.fieldbyname('YJKC').AsString); Post; end; with SCDS_Sub do begin Edit; FieldByName('MainId').Value:=Trim(FMainId); FieldByName('PBId').Value:=Trim(maxno); Post; end; //保存配料主表 //保存配料字表 with Self.CDS_Sel do begin First; while not Eof do begin if Self.CDS_Sel.FieldByName('SSel').AsBoolean=True then begin if GetLSNo(ADOCmd,maxnosub,'PS','WFBYCL_PBSub',4,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取最大号失败!','提示',0); Exit; end; with ADOCmd do begin Close; sql.Clear; sql.Add('select * from WFBYCL_PBSub where 1<>1'); Open; end; with ADOCmd do begin Append; FieldByName('MainId').Value:=Trim(FMainId); FieldByName('SubId').Value:=Trim(CDS_Sel.fieldbyname('SubId').AsString); FieldByName('PBId').Value:=Trim(maxno); FieldByName('PSId').Value:=Trim(maxnosub); Post; end; end; Next; end; end; //保存配料字表 if MInt=1 then OnlyUpYCLData(); end; Next; end; end; ADOCmd.Connection.CommitTrans; except ADOCmd.Connection.RollbackTrans; Application.MessageBox('增加异常!','提示',0); Exit; end; end; procedure TfrmOrderInPutNew.EditYCL(SCDS_Sub:TClientDataSet); begin try frmGetPGJBInList:=TfrmGetPGJBInList.Create(Application); with frmGetPGJBInList do begin if ShowModal=1 then begin with ClientDataSet2 do begin //First; // while not Eof do //begin with SCDS_Sub do begin Edit; SCDS_Sub.FieldByName('YCLCode').Value:=Trim(ClientDataSet2.fieldbyname('YCLCode').AsString); SCDS_Sub.FieldByName('YCLName').Value:=Trim(ClientDataSet2.fieldbyname('YCLName').AsString); SCDS_Sub.FieldByName('YCLSpec').Value:=Trim(ClientDataSet2.fieldbyname('YCLSpec').AsString); //SCDS_Sub.FieldByName('GYSName').Value:=Trim(ClientDataSet2.fieldbyname('GYSName').AsString); //SCDS_Sub.FieldByName('GYS').Value:=Trim(ClientDataSet2.fieldbyname('GYS').AsString); SCDS_Sub.FieldByName('YLKC').Value:=Trim(ClientDataSet2.fieldbyname('QuantityKC').AsString); //CDS_Sub.FieldByName('Qty').Value:=Trim(ClientDataSet2.fieldbyname('QtyKC').AsString); SCDS_Sub.FieldByName('YLUnit').Value:=Trim(ClientDataSet2.fieldbyname('CRUnit').AsString); SCDS_Sub.FieldByName('CRID').Value:=Trim(ClientDataSet2.fieldbyname('CRID').AsString); SCDS_Sub.FieldByName('YCLYJKC').Value:=Trim(ClientDataSet2.fieldbyname('YJKC').AsString); if SCDS_Sub.FieldByName('YLQty').Value-ClientDataSet2.fieldbyname('YJKC').Value>=0 then SCDS_Sub.FieldByName('BZ').Value:=SCDS_Sub.FieldByName('YLQty').Value- ClientDataSet2.fieldbyname('YJKC').Value else SCDS_Sub.FieldByName('BZ').Value:=null; //SCDS_Sub.FieldByName('YCLType').Value:=Trim(ClientDataSet2.fieldbyname('YCLType').AsString); //SCDS_Sub.FieldByName('YCLPrice').Value:=Trim(ClientDataSet2.fieldbyname('YCLPrice').AsString); //SCDS_Sub.FieldByName('KCPlace').Value:=Trim(ClientDataSet2.fieldbyname('KCPlace').AsString); //CDS_Sub.FieldByName('DepotShow').Value:=Trim(ClientDataSet2.fieldbyname('DepotShow').AsString); //Post; end; // Next; //end; end; end; end; finally frmGetPGJBInList.Free; end; end; procedure TfrmOrderInPutNew.ToolButton1Click(Sender: TObject); begin if CDS_Sub.IsEmpty=True then begin Application.MessageBox('详单不能为空!','提示',0); Exit; end; OrderDate.SetFocus; if Trim(OrderNo.Text)='' then begin Application.MessageBox('订单编号不能为空!','提示',0); Exit; end; {if Trim(WFBCodeName.Text)='' then begin Application.MessageBox('代号不能为空!','提示',0); Exit; end; if Trim(WFBCodeName.Hint)='' then begin Application.MessageBox('代号未定义!','提示',0); Exit; end; } SaveData10(); Panel1.Visible:=True; with ADOQuery1 do begin Close; sql.Clear; sql.Add('select * from WFBOrder_Sub where MainId='''+Trim(FMainId)+''''); Open; {if MInt=1 then begin SELYCL(Order_SubZ); end else if MInt=2 then begin SELYCL(Order_SubF); end else if MInt=3 then begin SELYCL(Order_SubQ); } end; SCreateCDS20(ADOQuery1,CDS_Sel); SInitCDSData20(ADOQuery1,CDS_Sel); with ADOQuery1 do begin Close; sql.Clear; sql.Add(' exec P_YCLKC_ListKCDD :KCType '); if MInt=1 then begin Parameters.ParamByName('KCType').Value:='主要'; end else if MInt=2 then begin Parameters.ParamByName('KCType').Value:='辅助'; end else if MInt=3 then begin Parameters.ParamByName('KCType').Value:='其它'; end; open; end; SCreateCDS20(ADOQuery1,CDS_KCSel); SInitCDSData20(ADOQuery1,CDS_KCSel); end; procedure TfrmOrderInPutNew.ToolButton2Click(Sender: TObject); begin if MInt=1 then begin DelOrderSub(Order_SubZ); end else if MInt=2 then begin DelOrderSub(Order_SubF); end else if MInt=3 then begin DelOrderSub(Order_SubQ); end; end; procedure TfrmOrderInPutNew.DelOrderSub(FOrder_Sub:TClientDataSet); begin if FOrder_Sub.IsEmpty then Exit; if Trim(FOrder_Sub.fieldbyname('PBID').AsString)<>'' then begin if Application.MessageBox('确定要删除数据吗!','提示',32+4)<>IDYES then Exit; with ADOCmd do begin Close; sql.Clear; sql.Add('delete WFBYCL_PB where PBID='''+Trim(FOrder_Sub.fieldbyname('PBID').AsString)+''''); sql.Add('delete WFBYCL_PBSub where PBID='''+Trim(FOrder_Sub.fieldbyname('PBID').AsString)+''''); ExecSQL; end; end; FOrder_Sub.Delete; end; procedure TfrmOrderInPutNew.CustomNoNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp:=TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag:=Trim('CustomNoName'); flagname:='客户名称'; if ShowModal=1 then begin Self.FXS:=99; CustomNoName.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); CustomNoName.Hint:=Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmOrderInPutNew.CustomNoNamePropertiesChange(Sender: TObject); begin if FXS=99 then begin PanZDY.Visible:=False; FXS:=0; Exit; end; ZDYHelp(CustomNoName,'CustomNoName'); end; procedure TfrmOrderInPutNew.ArrivalPortNamePropertiesButtonClick( Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp:=TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag:=Trim('ArrivalPort'); flagname:='到达港'; if ShowModal=1 then begin Self.FXS:=99; ArrivalPortName.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); ArrivalPortName.Hint:=Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmOrderInPutNew.SCXNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp:=TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag:=Trim('SCXName'); flagname:='生产线'; if ShowModal=1 then begin Self.FXS:=99; SCXName.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); SCXName.Hint:=Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmOrderInPutNew.WJGNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp:=TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag:=Trim('WJGName'); flagname:='网结构'; if ShowModal=1 then begin Self.FXS:=99; WJGName.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); WJGName.Hint:=Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmOrderInPutNew.WFBCodeNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp:=TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag:=Trim(WFBCodeName.Name); flagname:='代号'; if ShowModal=1 then begin Self.FXS:=99; WFBCodeName.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); WFBCodeName.Hint:=Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmOrderInPutNew.WFBCodeNamePropertiesChange(Sender: TObject); begin if FXS=99 then begin PanZDY.Visible:=False; FXS:=0; Exit; end; ZDYHelp(WFBCodeName,Trim(WFBCodeName.Name)); end; procedure TfrmOrderInPutNew.ArrivalPortNamePropertiesChange(Sender: TObject); begin if FXS=99 then begin PanZDY.Visible:=False; FXS:=0; Exit; end; ZDYHelp(ArrivalPortName,'ArrivalPort'); end; procedure TfrmOrderInPutNew.SCXNamePropertiesChange(Sender: TObject); begin if FXS=99 then begin PanZDY.Visible:=False; FXS:=0; Exit; end; ZDYHelp(SCXName,Trim(SCXName.Name)); end; procedure TfrmOrderInPutNew.WJGNamePropertiesChange(Sender: TObject); begin if FXS=99 then begin PanZDY.Visible:=False; FXS:=0; Exit; end; ZDYHelp(WJGName,Trim(WJGName.Name)); end; procedure TfrmOrderInPutNew.N1Click(Sender: TObject); begin with CDS_DB do begin Append; FieldByName('DBUnit').Value:='卷/包'; Post; end; end; procedure TfrmOrderInPutNew.N2Click(Sender: TObject); begin if CDS_DB.IsEmpty then Exit; with ADOCmd do begin Close; sql.Clear; sql.Add('delete WFB_DB where DBID='''+Trim(CDS_DB.fieldbyname('DBID').AsString)+''''); ExecSQL; end; CDS_DB.Delete; end; procedure TfrmOrderInPutNew.Day1Change(Sender: TObject); var DayL:string; begin if trim(Day1.Text)='' then DayL:='0' else DayL:=Trim(Day1.Text); ETDDate.DateTime:=ETADate.Date-strtoint(DayL); end; procedure TfrmOrderInPutNew.OrdQtyKeyPress(Sender: TObject; var Key: Char); begin if not (Key in['0'..'9','.',#8,#13]) then begin key:=#0; end; end; procedure TfrmOrderInPutNew.Day2Change(Sender: TObject); var DayL:string; begin if trim(Day2.Text)='' then DayL:='0' else DayL:=Trim(Day2.Text); ZGDate.DateTime:=ETDDate.Date-strtoint(DayL); end; procedure TfrmOrderInPutNew.Day3Change(Sender: TObject); var DayL:string; begin if trim(Day3.Text)='' then DayL:='0' else DayL:=Trim(Day3.Text); BegSCDate.DateTime:=BegRKDate.Date-strtoint(DayL); end; procedure TfrmOrderInPutNew.ETADateChange(Sender: TObject); begin if Trim(Day1.Text)<>'' then begin ETDDate.DateTime:=ETADate.Date-strtoint(Day1.Text); end; if Trim(Day2.Text)<>'' then begin ZGDate.DateTime:=ETDDate.Date-strtoint(Day2.Text); end; end; procedure TfrmOrderInPutNew.BegRKDateChange(Sender: TObject); begin if Trim(Day3.Text)<>'' then begin BegSCDate.DateTime:=BegRKDate.Date-strtoint(Day3.Text); end; end; procedure TfrmOrderInPutNew.Tv1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin MInt:=1; Tv1.Bands[0].Caption:='主要原料√'; Tv2.Bands[0].Caption:='辅助原料'; Tv3.Bands[0].Caption:='其它'; Tv1.Bands[0].Styles.Header.TextColor:=clBlue; Tv2.Bands[0].Styles.Header.TextColor:=clBlack; Tv3.Bands[0].Styles.Header.TextColor:=clBlack; end; procedure TfrmOrderInPutNew.Tv2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin MInt:=2; Tv1.Bands[0].Caption:='主要原料'; Tv2.Bands[0].Caption:='辅助原料√'; Tv3.Bands[0].Caption:='其它'; Tv1.Bands[0].Styles.Header.TextColor:=clBlack; Tv2.Bands[0].Styles.Header.TextColor:=clBlue; Tv3.Bands[0].Styles.Header.TextColor:=clBlack; end; procedure TfrmOrderInPutNew.Tv3MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin MInt:=3; Tv1.Bands[0].Caption:='主要原料'; Tv2.Bands[0].Caption:='辅助原料'; Tv3.Bands[0].Caption:='其它√'; Tv1.Bands[0].Styles.Header.TextColor:=clBlack; Tv2.Bands[0].Styles.Header.TextColor:=clBlack; Tv3.Bands[0].Styles.Header.TextColor:=clBlue; end; procedure TfrmOrderInPutNew.v1Column2PropertiesEditValueChanged( Sender: TObject); var mvalue,YLSH,DHSL,YLQty:Double; FOrdQty,FKZ:String; begin if Trim(TcxTextEdit(Sender).EditingText)<>'' then mvalue:=TcxTextEdit(Sender).EditingValue else mvalue:=0; with Order_SubZ do begin Edit; FieldByName('YLPB').Value:=mvalue; Post; end; //㎏㎡ YLUpdate(); end; procedure TfrmOrderInPutNew.OnlyUpYCLData(); var mvalue,YLSH,DHSL,YLQty:Double; FOrdQty,FKZ:String; begin YLQty:=0; if Trim(Order_SubZ.fieldbyname('YLPB').AsString)<>'' then mvalue:=Order_SubZ.fieldbyname('YLPB').Value else mvalue:=0; //㎏㎡ with ADOTemp do begin Close; SQL.Clear; sql.Add(' select A.* from WFBYCL_PBSub A '); //SQL.Add(' inner join WFBYCL_PB B on B.PBID=A.PBID '); sql.Add(' where A.PBID='''+Trim(Order_SubZ.fieldbyname('PBID').AsString)+''''); Open; end; with ADOTemp do begin First; while not Eof do begin CDS_Sub.Locate('SubId',Trim(ADOTemp.fieldbyname('SubId').AsString),[]); if Trim(CDS_Sub.fieldbyname('SOrdQty').AsString)='' then FOrdQty:='0' else FOrdQty:=Trim(CDS_Sub.fieldbyname('SOrdQty').AsString); if Trim(OrdUnit.Text)='㎏' then begin if Trim(Order_SubZ.fieldbyname('YLSH').AsString)='' then begin YLSH:=0; end else YLSH:=StrToFloat(Order_SubZ.fieldbyname('YLSH').AsString); YLQty:=YLQty+StrToFloat(FOrdQty)*mvalue/100*(1+YLSH/100); end else if Trim(OrdUnit.Text)='㎡' then begin if Trim(CDS_Sub.fieldbyname('SWFBKZ').AsString)='' then begin FKZ:='0'; end else FKZ:=Trim(CDS_Sub.fieldbyname('SWFBKZ').AsString); DHSL:=StrToFloat(FOrdQty)*strtofloat(FKZ)/1000; if Trim(Order_SubZ.fieldbyname('YLSH').AsString)='' then begin YLSH:=0; end else YLSH:=StrToFloat(Order_SubZ.fieldbyname('YLSH').AsString); YLQty:=YLQty+DHSL*mvalue/100*(1+YLSH/100); end; Next; end; with Order_SubZ do begin Edit; FieldByName('YLQty').Value:=YLQty; if YLQty-FieldByName('YCLYJKC').Value>=0 then FieldByName('BZ').Value:=YLQty-FieldByName('YCLYJKC').Value else FieldByName('BZ').Value:=null; Post; end; end; end; procedure TfrmOrderInPutNew.v1Column3PropertiesEditValueChanged( Sender: TObject); var mvalue,YLSH,DHSL,YLQty,YLPB:Double; FOrdQty,FKZ:String; begin if Trim(TcxTextEdit(Sender).EditingText)<>'' then mvalue:=TcxTextEdit(Sender).EditingValue else mvalue:=0; with Order_SubZ do begin Edit; FieldByName('YLSH').Value:=mvalue; Post; end; //㎏㎡ YLUpdate(); end; procedure TfrmOrderInPutNew.v2Column2PropertiesEditValueChanged( Sender: TObject); var mvalue,YLSHQ,DHSL,YLQty,YLPB:Double; FOrdQty,FKZ:String; begin if Trim(TcxTextEdit(Sender).EditingText)<>'' then mvalue:=TcxTextEdit(Sender).EditingValue else mvalue:=0; with Order_SubF do begin Edit; FieldByName('YLSHQ').Value:=mvalue; Post; end; //㎏㎡ YLUpdate(); end; procedure TfrmOrderInPutNew.OrdQtyChange(Sender: TObject); begin YLUpdate(); end; procedure TfrmOrderInPutNew.YLUpdate(); var mvalue,YLSH,DHSL,YLQty,YLPB,YLSHQ:Double; FOrdQty,FKZ:String; begin YLQty:=0; with Order_SubZ do begin if Order_SubZ.IsEmpty=False then begin First; while not Eof do begin YLQty:=0; with ADOTemp do begin Close; SQL.Clear; sql.Add('select * from WFBYCL_PBSub where PBID='''+Trim(Order_SubZ.fieldbyname('PBID').AsString)+''''); Open; end; with ADOTemp do begin First; while not Eof do begin CDS_Sub.Locate('SubId',Trim(ADOTemp.fieldbyname('SubId').AsString),[]); if Trim(CDS_Sub.fieldbyname('SOrdQty').AsString)='' then FOrdQty:='0' else FOrdQty:=Trim(CDS_Sub.fieldbyname('SOrdQty').AsString); if Trim(OrdUnit.Text)='㎏' then begin if Trim(Order_SubZ.fieldbyname('YLPB').AsString)='' then begin YLPB:=0; end else YLPB:=StrToFloat(Order_SubZ.fieldbyname('YLPB').AsString); if Trim(Order_SubZ.fieldbyname('YLSH').AsString)='' then begin YLSH:=0; end else YLSH:=StrToFloat(Order_SubZ.fieldbyname('YLSH').AsString); YLQty:=YLQty+StrToFloat(FOrdQty)*YLPB/100*(1+YLSH/100); end else if Trim(OrdUnit.Text)='㎡' then begin if Trim(CDS_Sub.fieldbyname('SWFBKZ').AsString)='' then begin FKZ:='0'; end else FKZ:=Trim(CDS_Sub.fieldbyname('SWFBKZ').AsString); DHSL:=StrToFloat(FOrdQty)*strtofloat(FKZ)/1000; if Trim(Order_SubZ.fieldbyname('YLPB').AsString)='' then begin YLPB:=0; end else YLPB:=StrToFloat(Order_SubZ.fieldbyname('YLPB').AsString); if Trim(Order_SubZ.fieldbyname('YLSH').AsString)='' then begin YLSH:=0; end else YLSH:=StrToFloat(Order_SubZ.fieldbyname('YLSH').AsString); YLQty:=YLQty+DHSL*YLPB/100*(1+YLSH/100); end; Next; end; with Order_SubZ do begin Edit; FieldByName('YLQty').Value:=YLQty; if YLQty-FieldByName('YCLYJKC').Value>=0 then FieldByName('BZ').Value:=YLQty-FieldByName('YCLYJKC').Value else FieldByName('BZ').Value:=null; Post; end; end; Next; end; end; end; if Order_SubF.IsEmpty=False then begin with Order_SubF do begin First; while not Eof do begin YLQty:=0; with ADOTemp do begin Close; SQL.Clear; sql.Add('select * from WFBYCL_PBSub where PBID='''+Trim(Order_SubF.fieldbyname('PBID').AsString)+''''); Open; end; with ADOTemp do begin First; while not Eof do begin CDS_Sub.Locate('SubId',Trim(ADOTemp.fieldbyname('SubId').AsString),[]); if Trim(CDS_Sub.fieldbyname('SOrdQty').AsString)='' then FOrdQty:='0' else FOrdQty:=Trim(CDS_Sub.fieldbyname('SOrdQty').AsString); if Trim(OrdUnit.Text)='㎏' then begin if Trim(Order_SubF.fieldbyname('YLSHQ').AsString)='' then begin YLSHQ:=0; end else YLSHQ:=StrToFloat(Order_SubF.fieldbyname('YLSHQ').AsString); YLQty:=YLQty+StrToFloat(FOrdQty)*(YLSHQ*1.00/1000); end else if Trim(OrdUnit.Text)='㎡' then begin if Trim(CDS_Sub.fieldbyname('SWFBKZ').AsString)='' then begin FKZ:='0'; end else FKZ:=Trim(CDS_Sub.fieldbyname('SWFBKZ').AsString); DHSL:=StrToFloat(FOrdQty)*strtofloat(FKZ)/1000; if Trim(Order_SubF.fieldbyname('YLSHQ').AsString)='' then begin YLSHQ:=0; end else YLSHQ:=StrToFloat(Order_SubF.fieldbyname('YLSHQ').AsString); YLQty:=YLQty+DHSL*(YLSHQ*1.00/1000); end; Next; end; with Order_SubF do begin Edit; FieldByName('YLQty').Value:=YLQty; if YLQty-FieldByName('YCLYJKC').Value>=0 then FieldByName('BZ').Value:=YLQty-FieldByName('YCLYJKC').Value else FieldByName('BZ').Value:=null; Post; end; end; Next; end; end; end; end; procedure TfrmOrderInPutNew.v3Column4PropertiesEditValueChanged( Sender: TObject); var mvalue:Double; begin mvalue:=TcxTextEdit(Sender).EditingValue; with Order_SubQ do begin Edit; FieldByName('YLQty').Value:=mvalue; if mvalue-fieldbyname('YCLYJKC').Value>=0 then FieldByName('BZ').Value:=mvalue-fieldbyname('YCLYJKC').Value else FieldByName('BZ').Value:=null; Post; end; end; procedure TfrmOrderInPutNew.TBPrintClick(Sender: TObject); var fPrintFile:String; begin with ADOQueryQG do begin Close; sql.Clear; sql.Add(' exec P_Print_SGD :OrderNo'); Parameters.ParamByName('OrderNo').Value:=Trim(OrderNo.Text); Open; end; if ADOQueryQG.IsEmpty then Exit; fPrintFile:=ExtractFilePath(Application.ExeName)+'Report\请购单.rmf' ; if FileExists(fPrintFile) then begin RM2.LoadFromFile(fPrintFile); RMVariables['dyr']:=Trim(DName); RM2.ShowReport; end else begin Application.MessageBox(PChar('没有找'+ExtractFilePath(Application.ExeName)+'Report\请购单.rmf'),'提示',0); end; end; procedure TfrmOrderInPutNew.v1Column1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin EditYCL(Order_SubZ); end; procedure TfrmOrderInPutNew.v2Column1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin EditYCL(Order_SubF); end; procedure TfrmOrderInPutNew.v3Column1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin EditYCL(Order_SubQ); end; procedure TfrmOrderInPutNew.MenuItem1Click(Sender: TObject); var i:Integer; begin CopyAddRow(TvSub,CDS_Sub); i:=CDS_Sub.RecordCount; with CDS_Sub do begin Edit; FieldByName('MainId').Value:=''; FieldByName('SubId').Value:=''; FieldByName('SWFBColor').Value:=''; FieldByName('SWFBCode').Value:=''; FieldByName('SWFBCodeName').Value:=''; FieldByName('SOrdQty').Value:=0; FieldByName('XHNO').Value:=IntToStr(i); Post; end; OrdQty.Text:=floattostr(TvSub.DataController.Summary.FooterSummaryValues[0]); end; procedure TfrmOrderInPutNew.MenuItem2Click(Sender: TObject); var mvalue,YLSH,DHSL,YLQty,YLPB,YLSHQ:Double; FOrdQty,FKZ:String; begin if CDS_Sub.IsEmpty then Exit; if Trim(CDS_Sub.fieldbyname('SubID').AsString)<>'' then begin if Application.MessageBox('确定要删除数据吗?','提示',32+4)<>IDYES then Exit; with ADOTemp do begin Close; sql.Clear; sql.Add('select * from WFBYCL_PBSub where SubId='''+Trim(CDS_Sub.fieldbyname('SubID').AsString)+''''); Open; end; if ADOTemp.IsEmpty=False then begin with ADOCMD do begin Close; sql.Clear; sql.Add('delete WFBYCL_PBSub where SubId='''+Trim(CDS_Sub.fieldbyname('SubID').AsString)+''''); sql.Add('delete WFBOrder_Sub where SubID='''+Trim(CDS_Sub.fieldbyname('SubID').AsString)+''''); ExecSQL; end; with ADOTemp do begin Close; SQL.Clear; sql.Add('select * from WFBYCL_PB where MainId='''+Trim(FMainId)+''' '); sql.Add(' and not exists(select * from WFBYCL_PBSub A where A.PBId=WFBYCL_PB.PBID and A.MainId='''+Trim(FMainId)+''' )'); open; end; with ADOTemp do begin ADOTemp.First; while not ADOTemp.Eof do begin if Trim(ADOTemp.fieldbyname('PBID').AsString)<>'' then begin if Order_SubZ.IsEmpty=False then begin if Order_SubZ.Locate('PBID',Trim(ADOTemp.fieldbyname('PBID').AsString),[]) then Order_SubZ.Delete; end; if Order_SubF.IsEmpty=False then begin if Order_SubF.Locate('PBID',Trim(ADOTemp.fieldbyname('PBID').AsString),[]) then Order_SubF.Delete; end; if Order_SubQ.IsEmpty=False then begin if Order_SubQ.Locate('PBID',Trim(ADOTemp.fieldbyname('PBID').AsString),[]) then Order_SubQ.Delete; end; end; ADOTemp.Next; end; end; with ADOCMD do begin Close; SQL.Clear; sql.Add(' delete WFBYCL_PB where not exists(select * from WFBYCL_PBSub A where A.PBId=WFBYCL_PB.PBID )'); SQL.Add(' and MainId='''+Trim(FMainId)+''''); ExecSQL; end; end else begin with ADOCmd do begin close; sql.Clear; sql.Add('delete WFBOrder_Sub where SubID='''+Trim(CDS_Sub.fieldbyname('SubID').AsString)+''''); ExecSQL; end; end; end; CDS_Sub.Delete; //YLUpdate(); if CDS_Sub.isempty=False then OrdQty.Text:=floattostr(TvSub.DataController.Summary.FooterSummaryValues[0]); YLUpdate(); end; procedure TfrmOrderInPutNew.cxGridDBColumn3PropertiesButtonClick( Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp:=TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag:='WFBColor'; flagname:='颜色'; if ShowModal=1 then begin with Self.CDS_Sub do begin Edit; FieldByName('SWFBColor').Value:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString); //Post; end; end; end; finally frmZDYHelp.Free; end; end; procedure TfrmOrderInPutNew.vSubColumn2PropertiesButtonClick( Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp:=TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag:='WFBHX'; flagname:='花型'; if ShowModal=1 then begin with Self.CDS_Sub do begin Edit; FieldByName('SWFBHW').Value:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString); //Post; end; end; end; finally frmZDYHelp.Free; end; end; procedure TfrmOrderInPutNew.cxGridDBColumn2PropertiesEditValueChanged( Sender: TObject); var mvalue,YLSH,DHSL,YLQty,YLPB,YLSHQ:Double; FOrdQty,FKZ:String; begin FKZ:=TcxTextEdit(Sender).EditingText; with CDS_Sub do begin Edit; if Trim(FKZ)='' then FieldByName('SWFBKZ').Value:='0' else FieldByName('SWFBKZ').Value:=FKZ; Post; end; YLUpdate(); end; procedure TfrmOrderInPutNew.TvSubColumn1PropertiesEditValueChanged( Sender: TObject); var mvalue,YLSH,DHSL,YLQty,YLPB,YLSHQ:Double; FOrdQty,FKZ:String; begin FOrdQty:=TcxTextEdit(Sender).EditingText; with CDS_Sub do begin Edit; if Trim(FOrdQty)='' then FieldByName('SOrdQty').Value:='0' else FieldByName('SOrdQty').Value:=FOrdQty; Post; end; OrdQty.Text:=floattostr(TvSub.DataController.Summary.FooterSummaryValues[0]); YLUpdate(); end; procedure TfrmOrderInPutNew.Panel10MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin ReleaseCapture; TWinControl(Panel1).perform(WM_SYSCOMMAND, $F012, 0); end; procedure TfrmOrderInPutNew.Image2Click(Sender: TObject); begin Panel1.Visible:=False; end; procedure TfrmOrderInPutNew.Button3Click(Sender: TObject); begin Panel1.Visible:=False; end; procedure TfrmOrderInPutNew.Button2Click(Sender: TObject); begin if CDS_Sel.Locate('ssel',True,[])=False then begin Application.MessageBox('没有选择数据!','提示',0); Exit; end; if MInt=1 then begin SELYCLKC(Order_SubZ); end else if MInt=2 then begin SELYCLKC(Order_SubF); end else if MInt=3 then begin SELYCLKC(Order_SubQ); end; Panel1.Visible:=False; end; procedure TfrmOrderInPutNew.FormClose(Sender: TObject; var Action: TCloseAction); var maxno,FFS:string; wz:Integer; begin WriteCxBandedGrid('配料主',Tv1,'无纺布订单'); WriteCxBandedGrid('配料辅',Tv2,'无纺布订单'); WriteCxBandedGrid('配料其它',Tv3,'无纺布订单'); WriteCxGrid('订单子表',TvSub,'无纺布订单'); WriteCxGrid('订单打包',TVDB,'无纺布订单'); { if CopyInt=1 then begin with ADOCmd do begin Close; sql.Clear; sql.Add('delete WFBOrder_Main where MainId='''+Trim(FMainId)+''''); sql.Add('delete WFBOrder_Sub where MainId='''+Trim(FMainId)+''''); sql.Add('delete WFB_DB where MainId='''+Trim(FMainId)+''''); sql.Add('delete WFBYCL_PB where MainId='''+Trim(FMainId)+''''); sql.Add('delete WFBYCL_PBSub where MainId='''+Trim(FMainId)+''''); ExecSQL; end; end; wz:=Pos('F',FMainId); FFS:=Copy(FMainId,wz,4); if ((CopyInt=1) or (FFS='FZ')) then begin UpMainId(); end;} end; procedure TfrmOrderInPutNew.UpMainId(); var maxno:string; begin try ADOCmd.Connection.BeginTrans; with ADOTemp do begin Close; SQL.Clear; sql.Add('select * from WFBYCL_PBSub where MainId='''+Trim(FMainId)+''''); Open; end; with ADOTemp do begin First; while not Eof do begin if GetLSNo(ADOCmd,maxno,'PS','WFBYCL_PBSub',4,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取最大号失败!','提示',0); Exit; end; with ADOCmd do begin Close; sql.Clear; sql.Add('Update WFBYCL_PBSub Set PSID='''+Trim(maxno)+''''); SQL.Add(' where PSID='''+Trim(ADOTemp.fieldbyname('PSID').AsString)+''''); ExecSQL; end; Next; end; end; with ADOTemp do begin Close; SQL.Clear; sql.Add('select * from WFBYCL_PB where MainId='''+Trim(FMainId)+''''); Open; end; with ADOTemp do begin First; while not Eof do begin if GetLSNo(ADOCmd,maxno,'PB','WFBYCL_PB',4,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取最大号失败!','提示',0); Exit; end; with ADOCmd do begin Close; sql.Clear; sql.Add('Update WFBYCL_PB Set PBID='''+Trim(maxno)+''''); SQL.Add(' where PBID='''+Trim(ADOTemp.fieldbyname('PBID').AsString)+''''); sql.Add('UPdate WFBYCL_PBSub Set PBID='''+Trim(maxno)+''''); SQL.Add(' where PBID='''+Trim(ADOTemp.fieldbyname('PBID').AsString)+''''); ExecSQL; end; Next; end; end; with ADOTemp do begin Close; SQL.Clear; sql.Add('select * from WFBOrder_Sub where MainId='''+Trim(FMainId)+''''); Open; end; with ADOTemp do begin First; while not Eof do begin if GetLSNo(ADOCmd,maxno,'','WFBOrder_Sub',3,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取最大号失败!','提示',0); Exit; end; with ADOCmd do begin Close; sql.Clear; sql.Add('Update WFBOrder_Sub Set SubID='''+Trim(maxno)+''''); SQL.Add(' where SubID='''+Trim(ADOTemp.fieldbyname('SubID').AsString)+''''); sql.Add('UPdate WFBYCL_PBSub Set SubID='''+Trim(maxno)+''''); SQL.Add(' where SubID='''+Trim(ADOTemp.fieldbyname('SubID').AsString)+''''); ExecSQL; end; Next; end; end; if GetLSNo(ADOCmd,maxno,'','WFBOrder_Main',2,1)=False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取最大号失败!','提示',0); Exit; end; with ADOCmd do begin Close; sql.Clear; sql.Add('Update WFBOrder_Main Set MainID='''+Trim(maxno)+''''); SQL.Add(' where MainID='''+Trim(FMainId)+''''); sql.Add('Update WFBOrder_Sub Set MainID='''+Trim(maxno)+''''); SQL.Add(' where MainID='''+Trim(FMainId)+''''); sql.Add('Update WFB_DB Set MainID='''+Trim(maxno)+''''); SQL.Add(' where MainID='''+Trim(FMainId)+''''); sql.Add('UPdate WFBYCL_PB Set MainID='''+Trim(maxno)+''''); SQL.Add(' where MainID='''+Trim(FMainId)+''''); sql.Add('UPdate WFBYCL_PBSub Set MainID='''+Trim(maxno)+''''); SQL.Add(' where MainID='''+Trim(FMainId)+''''); ExecSQL; end; FMainId:=Trim(maxno); ADOCmd.Connection.CommitTrans; except ADOCmd.Connection.RollbackTrans; Application.MessageBox('更新流水号失败!','提示',0); end; end; procedure TfrmOrderInPutNew.vSubColumn4PropertiesButtonClick( Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp:=TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag:=Trim(WFBCodeName.Name); flagname:='代号'; if ShowModal=1 then begin CDS_Sub.Edit; CDS_Sub.FieldByName('SWFBCodeName').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); CDS_Sub.FieldByName('SWFBCode').Value:=Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString); end; end; finally frmZDYHelp.Free; end; with ADOTemp do begin Close; SQL.Clear; sql.Add('select Top 1* from WFBOrder_Sub where SWFBCode='''+Trim(CDS_Sub.fieldbyname('SWFBCode').AsString)+''''); Open; end; if ADOTemp.IsEmpty then Exit; with ADOTemp do begin Close; SQL.Clear; sql.Add('select Top 1* from WFBOrder_Sub where SWFBCode='''+Trim(CDS_Sub.fieldbyname('SWFBCode').AsString)+''''); sql.Add(' order by SFillTIme Desc'); Open; end; with CDS_Sub do begin Edit; FieldByName('SWFBColor').Value:=ADOTemp.fieldbyname('SWFBColor').Value; FieldByName('SWFBHW').Value:=ADOTemp.fieldbyname('SWFBHW').Value; FieldByName('SWFBKZ').Value:=ADOTemp.fieldbyname('SWFBKZ').Value; FieldByName('SWFBFK').Value:=ADOTemp.fieldbyname('SWFBFK').Value; FieldByName('SOrdPrice').Value:=ADOTemp.fieldbyname('SOrdPrice').Value; FieldByName('WKMS').Value:=ADOTemp.fieldbyname('WKMS').Value; FieldByName('KZSmal').Value:=ADOTemp.fieldbyname('KZSmal').Value; FieldByName('KZBig').Value:=ADOTemp.fieldbyname('KZBig').Value; //Post; end; end; procedure TfrmOrderInPutNew.MenuItem3Click(Sender: TObject); begin CDS_Sel.DisableControls; with CDS_Sel do begin First; while not Eof do begin Edit; FieldByName('SSel').Value:=True; Post; Next; end; end; CDS_Sel.EnableControls; end; procedure TfrmOrderInPutNew.MenuItem4Click(Sender: TObject); begin CDS_Sel.DisableControls; with CDS_Sel do begin First; while not Eof do begin Edit; FieldByName('SSel').Value:=False; Post; Next; end; end; CDS_Sel.EnableControls; end; procedure TfrmOrderInPutNew.vSubColumn5PropertiesButtonClick( Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp:=TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag:=Trim('WKMS'); flagname:='网孔目数'; if ShowModal=1 then begin Self.CDS_Sub.Edit; CDS_Sub.FieldByName('WKMS').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmOrderInPutNew.BZPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp:=TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag:=Trim('JJDW'); flagname:='计价单位'; if ShowModal=1 then begin Self.FXS:=99; BZ.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); // BZ.Hint:=Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmOrderInPutNew.BZPropertiesChange(Sender: TObject); begin if FXS=99 then begin PanZDY.Visible:=False; FXS:=0; Exit; end; ZDYHelp(BZ,'JJDW'); end; procedure TfrmOrderInPutNew.TBChkOkClick(Sender: TObject); begin ChkInt:=1; TBSave.Click; end; procedure TfrmOrderInPutNew.TBChkNoClick(Sender: TObject); begin ChkInt:=2; TBSave.Click; end; procedure TfrmOrderInPutNew.Button4Click(Sender: TObject); begin if CDS_Sub.IsEmpty then exit; if( (Order_SubZ.IsEmpty) and (Order_SubF.IsEmpty) and (Order_SubQ.IsEmpty) )then Exit; if Trim(OrderNo.Text)='' then begin Application.MessageBox('订单编号不能为空!','提示',0); Exit; end; SaveData10(); if CDS_Sub.Locate('SSel',True,[])=False then begin Application.MessageBox('详单未选择数据,不能更新!','提示',0); Exit; end; if Order_SubZ.Locate('SSel',True,[])=False then begin if Order_SubF.Locate('SSel',True,[])=False then if Order_SubZ.Locate('SSel',True,[])=False then begin Application.MessageBox('原料表未选择数据,不能更新!','提示',0); Exit; end; end; try ADOCMD.Connection.BeginTrans; YCLPBIDUPdate(Order_SubZ); YCLPBIDUPdate(Order_SubF); YCLPBIDUPdate(Order_SubQ); ADOCMD.Connection.CommitTrans; YLUpdate(); Application.MessageBox('更新成功!','提示',0); Exit; except ADOCMD.Connection.RollbackTrans; Application.MessageBox('更新失败!','提示',0); end; end; procedure TfrmOrderInPutNew.YCLPBIDUPdate(SOrder_SubZ:TClientDataSet); var maxno:String; begin with CDS_Sub do begin First; while not Eof do begin if CDS_Sub.FieldByName('SSel').AsBoolean=True then begin with SOrder_SubZ do begin First; while not Eof do begin if SOrder_SubZ.FieldByName('SSel').AsBoolean=True then begin with ADOCMD do begin Close; sql.Clear; sql.Add('delete WFBYCL_PBSub where SubId='''+Trim(CDS_Sub.fieldbyname('SubId').AsString)+''''); sql.Add(' and PBID='''+Trim(SOrder_SubZ.fieldbyname('PBID').AsString)+''''); ExecSQL; end; if GetLSNo(ADOCMD,maxno,'PS','WFBYCL_PBSub',4,1)=False then begin ADOCMD.Connection.RollbackTrans; Application.MessageBox('取最大号失败!','提示',0); Exit; end; with ADOCMD do begin Close; sql.Clear; sql.Add('select * from WFBYCL_PBSub where 1<>1'); Open; end; with ADOCMD do begin Append; FieldByName('MainId').Value:=Trim(FMainId); FieldByName('SubId').Value:=Trim(CDS_Sub.fieldbyname('SubId').AsString); FieldByName('PBID').Value:=Trim(SOrder_SubZ.fieldbyname('PBID').AsString); FieldByName('PSID').Value:=Trim(maxno); Post; end; end; Next; end; end; end; Next; end; end; end; procedure TfrmOrderInPutNew.N3Click(Sender: TObject); begin SelAll(CDS_Sub,True); end; procedure TfrmOrderInPutNew.SelAll(SCDS_Sub:TClientDataSet;FSEL:Boolean); begin if SCDS_Sub.IsEmpty then exit; with SCDS_Sub do begin First; while not eof do begin Edit; FieldByName('SSel').Value:=FSEL; post; Next; end; end; end; procedure TfrmOrderInPutNew.N4Click(Sender: TObject); begin SelAll(CDS_Sub,False); end; procedure TfrmOrderInPutNew.MenuItem7Click(Sender: TObject); begin if MInt=1 then begin SelAll(Order_SubZ,True); end else if MInt=2 then begin SelAll(Order_SubF,True); end else if MInt=3 then begin SelAll(Order_SubQ,True); end; end; procedure TfrmOrderInPutNew.MenuItem8Click(Sender: TObject); begin if MInt=1 then begin SelAll(Order_SubZ,False); end else if MInt=2 then begin SelAll(Order_SubF,False); end else if MInt=3 then begin SelAll(Order_SubQ,False); end; end; end.