unit U_ClothQuotationInPut; 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, StrUtils, cxDropDownEdit, cxGridCustomPopupMenu, cxGridPopupMenu, cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore, dxSkinsDefaultPainters, cxNavigator, dxDateRanges, dxBarBuiltInMenu, dxDateTimeWheelPicker, dxGDIPlusClasses, Vcl.Menus, MovePanel, cxCheckBox, cxImage, cxDBEdit, Vcl.DBCtrls, U_BaseInput, System.ImageList, Vcl.ImgList, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdFTP, ShellAPI, dxCore, cxDateUtils, dxSkinBasic, dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkroom, dxSkinDarkSide, dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis, dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinOffice2013DarkGray, dxSkinOffice2013LightGray, dxSkinOffice2013White, dxSkinOffice2016Colorful, dxSkinOffice2016Dark, dxSkinOffice2019Black, dxSkinOffice2019Colorful, dxSkinOffice2019DarkGray, dxSkinOffice2019White, dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver, dxSkinSpringtime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinTheBezier, dxSkinValentine, dxSkinVisualStudio2013Blue, dxSkinVisualStudio2013Dark, dxSkinVisualStudio2013Light, dxSkinVS2010, dxSkinWhiteprint, dxSkinWXI, dxSkinXmas2008Blue, dxScrollbarAnnotations, cxSplitter, cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox, cxCalc; type TfrmClothQuotationInPut = class(TfrmBaseInput) ToolBar1: TToolBar; TBSave: TToolButton; TBClose: TToolButton; ScrollBox1: TScrollBox; Label3: TLabel; ADOTemp: TADOQuery; ADOCmd: TADOQuery; DS_1: TDataSource; Order_Sub: TClientDataSet; Label9: TLabel; Label10: TLabel; MVCNo: TcxTextEdit; Label14: TLabel; Label20: TLabel; GPM_1: TcxGridPopupMenu; Label27: TLabel; Label29: TLabel; Label30: TLabel; Label5: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; Label16: TLabel; ToolButton3: TToolButton; Saleser: TcxTextEdit; lblSalesId: TLabel; Label25: TLabel; SalesId: TcxTextEdit; TallyId: TcxTextEdit; Panel1: TPanel; Panel2: TPanel; GroupBox5: TGroupBox; cxGrid2: TcxGrid; TV2: TcxGridDBTableView; TV2Column1: TcxGridDBColumn; TV2Column2: TcxGridDBColumn; TV2Column3: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; ToolBar2: TToolBar; ToolButton1: TToolButton; ToolButton2: TToolButton; cxGrid1: TcxGrid; Tv1: TcxGridDBTableView; Tv1Column7: TcxGridDBColumn; v1XHNo: TcxGridDBColumn; VC_SCSCode: TcxGridDBColumn; v1Column4: TcxGridDBColumn; Tv1Column3: TcxGridDBColumn; v1Column5: TcxGridDBColumn; v1Column1: TcxGridDBColumn; Tv1Column5: TcxGridDBColumn; v1Column8: TcxGridDBColumn; Tv1Column1: TcxGridDBColumn; Tv1Column8: TcxGridDBColumn; v1Column6: TcxGridDBColumn; v1Column7: TcxGridDBColumn; v1OrderUnit: TcxGridDBColumn; v1PRTPrice: TcxGridDBColumn; v1Column2: TcxGridDBColumn; cxGrid1Level1: TcxGridLevel; TV2Column4: TcxGridDBColumn; CDS_2: TClientDataSet; DS_2: TDataSource; GPM_2: TcxGridPopupMenu; ToolButton4: TToolButton; Payment: TcxButtonEdit; SellName: TcxButtonEdit; BuyName: TcxButtonEdit; JiaGeSY: TcxButtonEdit; YunShu: TcxButtonEdit; QiYun: TcxButtonEdit; MuDi: TcxButtonEdit; MVCDate: TcxDateEdit; Currency: TcxComboBox; IsTax: TcxComboBox; Tv1Column2: TcxGridDBColumn; Label2: TLabel; Label6: TLabel; Label7: TLabel; BuyAddress: TcxButtonEdit; Tv1Column4: TcxGridDBColumn; Tv1Column6: TcxGridDBColumn; Tv1Column9: TcxGridDBColumn; Tv1Column10: TcxGridDBColumn; Tv1Column11: TcxGridDBColumn; Tv1Column12: TcxGridDBColumn; Tv1Column13: TcxGridDBColumn; ToolButton5: TToolButton; Tv1Column14: TcxGridDBColumn; Label23: TLabel; Note: TcxMemo; BuyTel: TcxButtonEdit; Label1: TLabel; SellTel: TcxTextEdit; SellEmail: TcxButtonEdit; Label4: TLabel; BuyRepresentative: TcxButtonEdit; Tv1Column15: TcxGridDBColumn; DlyNote: TcxTextEdit; cxSplitter1: TcxSplitter; Tv1Column16: TcxGridDBColumn; Tv1Column17: TcxGridDBColumn; Tv1Column18: TcxGridDBColumn; cxStyleRepository1: TcxStyleRepository; cxStyle1: TcxStyle; Tv1Column19: TcxGridDBColumn; procedure TBCloseClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBSaveClick(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure v1Column4PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure v1Column6PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure v1Column7PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure SalesmanBtnUpClick(Sender: TObject); procedure v1Column15PropertiesEditValueChanged(Sender: TObject); procedure ShippMentKeyPress(Sender: TObject; var Key: Char); procedure ToolButton3Click(Sender: TObject); procedure ToolButton4Click(Sender: TObject); procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); procedure SellNameDblClick(Sender: TObject); procedure SellNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure BuyNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure PaymentPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure BuyAddressPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure ToolButton5Click(Sender: TObject); procedure cxLookupComboBox1KeyPress(Sender: TObject; var Key: Char); procedure Tv1Column15PropertiesEditValueChanged(Sender: TObject); procedure Tv1Column15PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); private FLeft, FTop: Integer; fuserName, Fstatus: string; procedure InitData(); procedure InitHistoricalPrice(); function TestData(): Boolean; function SaveData(): Boolean; procedure SetXH(); procedure JSBJ(); { Private declarations } public CopyInt: Integer; PState: string; fFlileFlag: string; FMVCMID: string; FAuthority, FGSTT: string; { Public declarations } end; var frmClothQuotationInPut: TfrmClothQuotationInPut; newh: hwnd; implementation uses U_DataLink, U_RTFun, U_ZDYHelp, U_CompanySel, U_ClothInfoSel, U_PictureUpload, U_InputBoxCostPrice; {$R *.dfm} procedure TfrmClothQuotationInPut.JSBJ(); var FCostPrice, FCostAdd, FCostRate, FPrice: Double; begin with Order_Sub do begin FCostPrice := Fieldbyname('CostPrice').AsFloat; FCostAdd := Fieldbyname('CostAdd').AsFloat; FCostRate := Fieldbyname('CostRate').AsFloat; end; FPrice := RoundFloat(FCostPrice * FCostRate + FCostAdd, 2); with Order_Sub do begin Edit; FieldByName('Price').Value := FPrice; Post; end; tv1.Controller.EditingController.ShowEdit(); end; procedure TfrmClothQuotationInPut.InitHistoricalPrice(); begin with ADOTemp do begin Close; SQL.Clear; sql.Add('select TOP 30 * '); sql.Add('from MV_Cloth_Main A inner join MV_Cloth_Sub B on A.MVCMId=B.MVCMId '); sql.Add('where B.C_Code=''' + Trim(Order_Sub.FieldByName('C_Code').AsString) + ''''); sql.Add('and isnull(A.status,''0'')<>''-1'''); sql.Add('and MVCType=''报价'''); sql.Add('order by A.MVCDate '); Open; end; SCreateCDS(ADOTemp, CDS_2); SInitCDSData(ADOTemp, CDS_2); end; procedure TfrmClothQuotationInPut.PaymentPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); var fsj: string; FWZ: Integer; begin fsj := Trim(TcxButtonEdit(Sender).Hint); FWZ := Pos('/', fsj); try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin MainType := 'MarketValue'; flag := Copy(fsj, 1, FWZ - 1); flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ); if ShowModal = 1 then begin TcxButtonEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmClothQuotationInPut.SellNameDblClick(Sender: TObject); begin TcxButtonEdit(Sender).Text := ''; TcxButtonEdit(Sender).Properties.LookupItems.Text := ''; end; procedure TfrmClothQuotationInPut.SellNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmCompanySel := TfrmCompanySel.Create(Application); with frmCompanySel do begin FCoType := '我司'; if ShowModal = 1 then begin self.Sellname.Properties.LookupItems.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoCode').AsString); self.Sellname.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoAbbrName').AsString); end; end; finally frmCompanySel.Free; end; end; procedure TfrmClothQuotationInPut.SetXH(); var i: Integer; begin with Order_Sub do begin First; i := 1; while not Eof do begin with Order_Sub do begin Edit; FieldByName('XHNoTemp').Value := i; Post; end; i := i + 1; Next; end; end; with Order_Sub do begin Order_Sub.IndexFieldNames := ''; First; i := 1; while not Eof do begin with Order_Sub do begin Edit; FieldByName('SerialNo').Value := FieldByName('XHNoTemp').AsInteger; Post; end; i := i + 1; Next; end; Order_Sub.IndexFieldNames := 'SerialNo'; end; end; procedure TfrmClothQuotationInPut.ShippMentKeyPress(Sender: TObject; var Key: Char); begin // if not (((Key >= '0') and (Key <= '9')) or (Key = '.') or (Key = #8)) then // begin // Key := #0; // end // else if (pos('.', TcxTextEdit(Sender).text) <> 0) then // begin // if Key = '.' then // begin // Key := #0; // end; // end; end; function TfrmClothQuotationInPut.TestData(): Boolean; begin try if Trim(MVCNo.Text) = '' then raise Exception.Create('报价号不能为空!'); if Trim(SellName.Text) = '' then raise Exception.Create('我方单位不能为空!'); if Trim(BuyName.Text) = '' then raise Exception.Create('对方单位不能为空!'); if Order_Sub.IsEmpty then raise Exception.Create('明细不能为空!'); if Order_Sub.Locate('C_Code', null, []) then raise Exception.Create('产品编号不能为空!'); if Order_Sub.Locate('C_Code', '', []) then raise Exception.Create('产品编号不能为空!'); // if Order_Sub.Locate('C_Name', null, []) then // raise Exception.Create('品名不能为空!'); // if Order_Sub.Locate('C_Name', '', []) then // raise Exception.Create('品名不能为空!'); if Order_Sub.Locate('C_Color', null, []) then // raise Exception.Create('颜色不能为空!'); // if Order_Sub.Locate('C_Color', '', []) then // raise Exception.Create('颜色不能为空!'); if Order_Sub.Locate('QtyUnit', null, []) then raise Exception.Create('数量单位不能为空!'); if Order_Sub.Locate('QtyUnit', '', []) then raise Exception.Create('数量单位不能为空!'); Result := True; except Result := false; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmClothQuotationInPut.TBCloseClick(Sender: TObject); begin Close; end; procedure TfrmClothQuotationInPut.InitData(); var maxno: string; begin //刷新产品信息 with ADOTemp do begin Close; SQL.Clear; sql.Add(' select * from MV_Cloth_Sub '); sql.Add('where MVCMID=''' + Trim(FMVCMID) + ''''); sql.Add(' order by SerialNo '); Open; end; SCreateCDS(ADOTemp, Order_Sub); SInitCDSData(ADOTemp, Order_Sub); //刷新条款信息 with ADOTemp do begin Close; sql.Clear; sql.Add('select * from MV_Cloth_Main where MVCMID=''' + Trim(FMVCMID) + ''''); Open; end; SCSHData(ADOTemp, ScrollBox1, 2); BuyName.Properties.LookupItems.Text := Trim(ADOTemp.FieldByName('BuyNo').AsString); Sellname.Properties.LookupItems.Text := Trim(ADOTemp.FieldByName('SellNo').AsString); Fstatus := Trim(ADOTemp.FieldByName('status').AsString); if PState = '新增' then begin MVCDate.Date := SGetServerDateTime(ADOTemp); // DlyDate.Date := MVCDate.Date; MVCNo.Text := '自动生成'; end; if PState = '复制' then begin PState := '新增'; FMVCMID := ''; MVCNo.Text := '自动生成'; with Order_Sub do begin First; while not Eof do begin if GetLSNo(ADOCmd, maxno, 'MVS', 'MV_Cloth_Sub', 4, 1) = False then begin Application.MessageBox('取子流水号失败!', '提示', 0); Exit; end; Edit; FieldByName('MVCMID').Value := ''; FieldByName('MVCSID').Value := maxno; Post; Next; end; end; end; end; procedure TfrmClothQuotationInPut.BuyAddressPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); var fsj: string; FWZ: Integer; begin if BuyAddress.Hint = '' then Exit; fsj := Trim(TcxButtonEdit(Sender).Hint); FWZ := Pos('/', fsj); try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin MainType := 'MarketValue'; flag := Copy(fsj, 1, FWZ - 1); flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ); V1Name.Caption := '地址'; V1Name.Width := 325; if ShowModal = 1 then begin TcxButtonEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmClothQuotationInPut.BuyNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); var fsj: string; begin try frmCompanySel := TfrmCompanySel.Create(Application); with frmCompanySel do begin FCoType := '客户'; if Self.FAuthority = '录入' then FAuthority := '理单业务'; if ShowModal = 1 then begin self.BuyName.Properties.LookupItems.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoCode').AsString); self.BuyName.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoAbbrName').AsString); self.SalesId.Text := Trim(frmCompanySel.CDS_1.fieldbyname('SalesId').AsString); self.Saleser.Text := Trim(frmCompanySel.CDS_1.fieldbyname('Saleser').AsString); self.BuyTel.Text := Trim(frmCompanySel.CDS_1.fieldbyname('Telephone').AsString); self.BuyRepresentative.Text := Trim(frmCompanySel.CDS_1.fieldbyname('Contacts').AsString); BuyAddress.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoAddress').AsString); BuyAddress.Hint := Trim(frmCompanySel.CDS_1.fieldbyname('CoCode').AsString) + '/' + Trim(frmCompanySel.CDS_1.fieldbyname('CoAbbrName').AsString) + '地址'; // fsj := 'select Name = Telephone from Bs_Company_contact where CoID=''' + Trim(frmCompanySel.CDS_1.fieldbyname('COID').AsString) + ''' '; // SInitTcxComBoxBySql(ADOQueryTemp, BuyTel, True, fsj); // fsj := 'select Name = Email from Bs_Company_contact where CoID=''' + Trim(frmCompanySel.CDS_1.fieldbyname('COID').AsString) + ''' '; // SInitTcxComBoxBySql(ADOQueryTemp, BuyEmail, True, fsj); end; end; finally frmCompanySel.Free; end; end; procedure TfrmClothQuotationInPut.cxLookupComboBox1KeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin with ADOTemp do begin Close; SQL.Clear; sql.Add('select TOP 30 * '); sql.Add('from Bs_Cloth_Info A '); sql.Add('where A.GC_Name LIKE ' + QuotedStr(Trim(Order_Sub.FieldByName('C_Code').AsString) + '%')); Open; end; SCreateCDS(ADOTemp, CDS_2); SInitCDSData(ADOTemp, CDS_2); end; // cxLookupComboBox1.Text; end; procedure TfrmClothQuotationInPut.FormShow(Sender: TObject); begin inherited; readCxGrid(trim(self.Caption) + 'Tv1', Tv1, '销售报价管理'); readCxGrid(trim(self.Caption) + 'Tv2', Tv2, '销售报价管理'); fFlileFlag := UserDataFlag + 'HX'; InitData(); end; function TfrmClothQuotationInPut.SaveData(): Boolean; var maxno: string; fMVCNo, fmxType, fDate: string; begin try Order_Sub.DisableControls; ADOCmd.Connection.BeginTrans; //////////////// 保存主表 ////////////////////// if Trim(FMVCMID) = '' then begin if GetLSNo(ADOTemp, maxno, 'MVM', 'MV_Cloth_Main', 3, 1) = False then raise Exception.Create('取最大号失败!'); fDate := 'BJ' + FormatDateTime('yy', SGetServerDate(ADOTemp)); if trim(MVCNo.Text) = '自动生成' then begin if GetLSNo(ADOTemp, fMVCNo, fDate, 'MV_Cloth_Main', 4, 0) = False then raise Exception.Create('取最报价编号失败!'); MVCNo.Text := fMVCNo; end; end else begin maxno := Trim(FMVCMID); end; with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from MV_Cloth_Main where MVCMID=''' + Trim(FMVCMID) + ''''); Open; end; with ADOCmd do begin if Trim(FMVCMID) = '' then begin Append; FieldByName('Filler').Value := Trim(DName); FieldByName('status').Value := '0'; end else begin Edit; FieldByName('Editer').Value := Trim(DName); FieldByName('EditTime').Value := SGetServerDateTime(ADOTemp); end; FieldByName('MVCMID').Value := Trim(maxno); RTSetsavedata(ADOCmd, 'MV_Cloth_Main', ScrollBox1, 2); FieldByName('BuyNo').Value := Trim(BuyName.Properties.LookupItems.Text); FieldByName('SellNo').Value := Sellname.Properties.LookupItems.Text; FieldByName('MVCType').Value := '报价'; Post; end; with ADOCmd do begin Close; sql.Clear; sql.Add('select * from MV_Cloth_Main where MVCNo=''' + Trim(MVCNo.Text) + ''''); Open; end; if ADOCmd.RecordCount > 1 then raise Exception.Create('报价单号重复!'); FMVCMID := Trim(maxno); //////////////// 保存主表 ////////////////////// /// //////////////// 保存子表 ////////////////////// with Order_Sub do begin First; while not Eof do begin maxno := Trim(Order_Sub.fieldbyname('MVCSID').AsString); with ADOCmd do begin Close; SQL.Clear; sql.Add('select * from MV_Cloth_Sub '); sql.Add(' where MVCMID=''' + Trim(FMVCMID) + ''''); sql.Add(' and MVCSID=''' + Trim(maxno) + ''''); Open; end; with ADOCmd do begin if ADOCmd.IsEmpty then Append else Edit; RTSetSaveDataCDS(ADOCmd, Tv1, Order_Sub, 'MV_Cloth_Sub', 0); FieldByName('MVCMID').Value := Trim(FMVCMID); FieldByName('MVCSID').Value := Trim(maxno); Post; end; with Order_Sub do begin Edit; FieldByName('MVCSID').Value := Trim(maxno); Post; end; Next; end; end; //////////////// 保存子表 ////////////////////// /// //////////////// 更新报价 ////////////////////// // with ADOCmd do // begin // close; // sql.Clear; // sql.Add('EXEC P_Con_Up_PiQty '); // sql.Add('@DataID=' + quotedstr(Trim(FMVCMID))); // execsql; // end; //////////////// 更新报价 ////////////////////// ADOCmd.Connection.CommitTrans; Order_Sub.EnableControls; Result := True; except Order_Sub.EnableControls; ADOCmd.Connection.RollbackTrans; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); Result := False; end; end; procedure TfrmClothQuotationInPut.TBSaveClick(Sender: TObject); begin MVCDate.SetFocus; if TestData() = false then exit; if SaveData() then begin Application.MessageBox('保存成功!', '提示', 0); end; end; procedure TfrmClothQuotationInPut.ToolButton1Click(Sender: TObject); var i: Integer; maxno: string; begin if GetLSNo(ADOCmd, maxno, 'MVS', 'MV_Cloth_Sub', 4, 1) = False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取子流水号失败!', '提示', 0); Exit; end; if Trim(MVCNo.Text) = '' then begin Application.MessageBox('报价号不能为空!', '提示', 0); Exit; end; i := Order_Sub.RecordCount; //当前的dataset有多少行记录 i := i + 1; CopyAddRow(Tv1, Order_Sub); with Order_Sub do begin Edit; FieldByName('SSEL').Value := FALSE; FieldByName('SerialNo').Value := i; fieldbyname('CostRate').Value := 1.3; FieldByName('MVCSID').Value := maxno; FieldByName('C_Color').Value := ''; FieldByName('Price').Value := null; Post; end; SetXH(); end; procedure TfrmClothQuotationInPut.ToolButton2Click(Sender: TObject); begin if Order_Sub.IsEmpty then Exit; if Application.MessageBox('确定要删除数据吗?', '提示', 32 + 4) <> IDYES then Exit; while Order_Sub.Locate('SSel', True, []) do begin // with ADOTemp do // begin // Close; // sql.Clear; // sql.Add('select * from Trade_Plan_Sub where MVCSID=''' + Trim(Order_Sub.fieldbyname('MVCSID').AsString) + ''''); // open; // end; // if ADOTemp.IsEmpty = false then // begin // exit; // application.MessageBox('该明细已经在生产!', '提示信息'); // end; if Trim(Order_Sub.fieldbyname('MVCSID').AsString) <> '' then begin with ADOCmd do begin Close; sql.Clear; sql.Add('delete MV_Cloth_Sub where MVCSID=''' + Trim(Order_Sub.fieldbyname('MVCSID').AsString) + ''''); ExecSQL; end; end; Order_Sub.Delete; end; SetXH(); end; procedure TfrmClothQuotationInPut.ToolButton3Click(Sender: TObject); begin WriteCxGrid(trim(self.Caption) + 'Tv1', Tv1, '销售报价管理'); WriteCxGrid(trim(self.Caption) + 'Tv2', Tv2, '销售报价管理'); end; procedure TfrmClothQuotationInPut.ToolButton4Click(Sender: TObject); begin GroupBox5.Visible := not GroupBox5.Visible; end; procedure TfrmClothQuotationInPut.ToolButton5Click(Sender: TObject); var i: Integer; maxno: string; begin Order_Sub.EnableControls; i := Order_Sub.RecordCount + 1; frmClothInfoSel := TfrmClothInfoSel.Create(self); with frmClothInfoSel do begin IsMultipleSelection := True; if showmodal = 1 then begin with CDS_Selok do begin DisableControls; Order_Sub.DisableControls; First; while not Eof do begin if GetLSNo(ADOCmd, maxno, 'MVS', 'MV_Cloth_Sub', 4, 1) = False then begin Application.MessageBox('取子流水号失败!', '提示', 0); Exit; end; Order_Sub.Append; Order_Sub.FieldByName('MVCSID').Value := maxno; Order_Sub.FieldByName('SerialNo').Value := i; Order_Sub.fieldbyname('CostRate').Value := 1.3; Order_Sub.fieldbyname('C_Code').Value := frmClothInfoSel.CDS_Selok.fieldbyname('C_Code').asstring; Order_Sub.fieldbyname('C_Name').Value := frmClothInfoSel.CDS_Selok.fieldbyname('C_Name').asstring; Order_Sub.fieldbyname('C_EName').Value := frmClothInfoSel.CDS_Selok.fieldbyname('C_EName').asstring; Order_Sub.fieldbyname('C_Spec').Value := frmClothInfoSel.CDS_Selok.fieldbyname('C_Spec').asstring; Order_Sub.fieldbyname('C_Composition').Value := frmClothInfoSel.CDS_Selok.fieldbyname('C_Composition').asstring; Order_Sub.fieldbyname('C_EComposition').Value := frmClothInfoSel.CDS_Selok.fieldbyname('C_EComposition').asstring; Order_Sub.fieldbyname('C_Color').Value := frmClothInfoSel.CDS_Selok.fieldbyname('C_Color').asstring; Order_Sub.fieldbyname('C_Width').Value := frmClothInfoSel.CDS_Selok.fieldbyname('C_Width').asstring; Order_Sub.fieldbyname('C_GramWeight').Value := frmClothInfoSel.CDS_Selok.fieldbyname('C_GramWeight').asstring; Order_Sub.fieldbyname('GC_Name').Value := frmClothInfoSel.CDS_Selok.fieldbyname('GC_Name').asstring; Order_Sub.fieldbyname('CraftCode').Value := frmClothInfoSel.CDS_Selok.fieldbyname('CraftCode').asstring; Order_Sub.fieldbyname('CraftName').Value := frmClothInfoSel.CDS_Selok.fieldbyname('CraftName').asstring; Order_Sub.fieldbyname('CraftEName').Value := frmClothInfoSel.CDS_Selok.fieldbyname('CraftEName').asstring; Order_Sub.fieldbyname('FtyName').Value := frmClothInfoSel.CDS_Selok.fieldbyname('FtyName').asstring; Order_Sub.fieldbyname('FtyNo').Value := frmClothInfoSel.CDS_Selok.fieldbyname('FtyNo').asstring; Order_Sub.fieldbyname('C_YarnSpec').Value := frmClothInfoSel.CDS_Selok.fieldbyname('C_YarnSpec').asstring; Order_Sub.Post; i := i + 1; Next; end; EnableControls; Order_Sub.EnableControls; end; end; free; end; tv1.Controller.EditingController.ShowEdit(); end; procedure TfrmClothQuotationInPut.Tv1Column15PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmInputBoxCostPrice := TfrmInputBoxCostPrice.Create(Application); with frmInputBoxCostPrice do begin CostPrice.Text := Order_Sub.FieldByName('CostPrice').AsString; CostPriceEquation.Text := Order_Sub.FieldByName('CostPriceEquation').AsString; if ShowModal = 1 then begin with Order_Sub do begin Edit; FieldByName('CostPrice').Value := CostPrice.Text; FieldByName('CostPriceEquation').Value := CostPriceEquation.Text; Post; end; JSBJ(); end; end; finally frmInputBoxCostPrice.Free; end; end; procedure TfrmClothQuotationInPut.Tv1Column15PropertiesEditValueChanged(Sender: TObject); var mvalue, FFieldName: string; begin mvalue := TcxTextEdit(Sender).EditingText; if Trim(mvalue) = '' then begin mvalue := '0'; end; FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName); with Order_Sub do begin Edit; FieldByName(FFieldName).Value := Trim(mvalue); Post; end; JSBJ(); end; procedure TfrmClothQuotationInPut.Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); begin InitHistoricalPrice(); end; procedure TfrmClothQuotationInPut.v1Column4PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := 'MPRTCodeName'; flagname := '产品名称'; if ShowModal = 1 then begin Order_Sub.Edit; Order_Sub.fieldbyname('PRTCodeName').Value := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); Order_Sub.fieldbyname('PRTCode').Value := Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString); Order_Sub.Post; end; end; finally frmZDYHelp.Free; end; tv1.Controller.EditingController.ShowEdit(); end; procedure TfrmClothQuotationInPut.v1Column6PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := 'C_MF'; flagname := '门幅信息'; if ShowModal = 1 then begin Order_Sub.Edit; Order_Sub.fieldbyname('C_MF').Value := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); // Order_Sub.fieldbyname('PRTCode').Value:=Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString); Order_Sub.Post; end; end; finally frmZDYHelp.Free; end; tv1.Controller.EditingController.ShowEdit(); end; procedure TfrmClothQuotationInPut.v1Column7PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := 'C_KZ'; flagname := '克重信息'; if ShowModal = 1 then begin Order_Sub.Edit; Order_Sub.fieldbyname('C_KZ').Value := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); // Order_Sub.fieldbyname('PRTCode').Value:=Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString); Order_Sub.Post; end; end; finally frmZDYHelp.Free; end; tv1.Controller.EditingController.ShowEdit(); end; procedure TfrmClothQuotationInPut.SalesmanBtnUpClick(Sender: TObject); var fsj: string; FWZ: Integer; begin fsj := Trim(TcxTextEdit(Sender).Hint); FWZ := Pos('/', fsj); try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := Copy(fsj, 1, FWZ - 1); flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ); if ShowModal = 1 then begin TcxTextEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmClothQuotationInPut.v1Column15PropertiesEditValueChanged(Sender: TObject); var mvalue: string; begin mvalue := TcxTextEdit(Sender).EditingText; if Trim(mvalue) = '' then begin mvalue := '0'; end; with Order_Sub do begin Edit; FieldByName('YongJinPrice').Value := mvalue; FieldByName('YongJin').Value := FieldByName('YongJinPrice').AsFloat * FieldByName('PRTOrderQty').AsFloat; Post; end; end; end.