1581 lines
42 KiB
ObjectPascal
1581 lines
42 KiB
ObjectPascal
unit U_TatDRList;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
|
||
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses, cxControls,
|
||
cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
||
cxGrid, DBClient, cxCheckBox, cxCalendar, cxSplitter, RM_Dataset, RM_System,
|
||
RM_Common, RM_Class, RM_GridReport, RM_e_Xls, Menus, cxPC, cxButtonEdit,
|
||
cxDropDownEdit, cxTextEdit, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator,
|
||
dxBarBuiltInMenu, dxSkinsCore, dxSkinsDefaultPainters, U_BaseList, Clipbrd,
|
||
dxDateRanges, dxScrollbarAnnotations, IdBaseComponent, IdComponent,
|
||
IdTCPConnection, IdTCPClient, IdHTTP, cxButtons;
|
||
|
||
type
|
||
TfrmTatDRList = class(TfrmBaseList)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBFind: TToolButton;
|
||
TBAdd: TToolButton;
|
||
TBEdit: TToolButton;
|
||
TBDel: TToolButton;
|
||
TBPrint: TToolButton;
|
||
TBClose: TToolButton;
|
||
Tv1: TcxGridDBTableView;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
cxGrid1: TcxGrid;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
TBExport: TToolButton;
|
||
v1OrdDate: TcxGridDBColumn;
|
||
Order_Main: TClientDataSet;
|
||
ToolButton1: TToolButton;
|
||
v1Column4: TcxGridDBColumn;
|
||
Panel1: TPanel;
|
||
Label4: TLabel;
|
||
Label8: TLabel;
|
||
Label12: TLabel;
|
||
Label13: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
ToCoName: TEdit;
|
||
MPRTCodeName: TEdit;
|
||
MPRTKZ: TEdit;
|
||
MPRTMF: TEdit;
|
||
cxTabControl1: TcxTabControl;
|
||
tchk: TToolButton;
|
||
Tnochk: TToolButton;
|
||
cxSplitter1: TcxSplitter;
|
||
DS_2: TDataSource;
|
||
v1Column8: TcxGridDBColumn;
|
||
Label2: TLabel;
|
||
ClientDataSet2: TClientDataSet;
|
||
GPM_2: TcxGridPopupMenu;
|
||
v1Column13: TcxGridDBColumn;
|
||
v1Column17: TcxGridDBColumn;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column7: TcxGridDBColumn;
|
||
Tv1ToCoName: TcxGridDBColumn;
|
||
v1Column27: TcxGridDBColumn;
|
||
btnWC: TToolButton;
|
||
btnWCCX: TToolButton;
|
||
CheckBox1: TCheckBox;
|
||
ToolButton6: TToolButton;
|
||
Label1: TLabel;
|
||
cxGrid2: TcxGrid;
|
||
TV2: TcxGridDBTableView;
|
||
cxGridDBColumn3: TcxGridDBColumn;
|
||
v1Column6: TcxGridDBColumn;
|
||
cxGridDBColumn4: TcxGridDBColumn;
|
||
cxGridDBColumn7: TcxGridDBColumn;
|
||
cv1Column3: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
TV2Column1: TcxGridDBColumn;
|
||
TV2Column2: TcxGridDBColumn;
|
||
TV2Column3: TcxGridDBColumn;
|
||
Label3: TLabel;
|
||
shdanwei: TEdit;
|
||
ToolButton2: TToolButton;
|
||
IdHTTP1: TIdHTTP;
|
||
ToolButton3: TToolButton;
|
||
Tv1Column2: TcxGridDBColumn;
|
||
ToolButton4: TToolButton;
|
||
Tv1Column3: TcxGridDBColumn;
|
||
Tv1Column4: TcxGridDBColumn;
|
||
Tv1Column5: TcxGridDBColumn;
|
||
ToolButton5: TToolButton;
|
||
ToolButton7: TToolButton;
|
||
TV2Column4: TcxGridDBColumn;
|
||
TV2Column5: TcxGridDBColumn;
|
||
TV2Column6: TcxGridDBColumn;
|
||
TV2Column7: TcxGridDBColumn;
|
||
Tv1Column6: TcxGridDBColumn;
|
||
TbGoodsEdit: TToolButton;
|
||
TV2Volume: TcxGridDBColumn;
|
||
TV2Applicant: TcxGridDBColumn;
|
||
TV2ApplicationReaon: TcxGridDBColumn;
|
||
Tv1CoAddress: TcxGridDBColumn;
|
||
Label5: TLabel;
|
||
SSelJS: TLabel;
|
||
Tv1sselJS: TcxGridDBColumn;
|
||
PM_1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
PM11: TMenuItem;
|
||
Tv1Telephone: TcxGridDBColumn;
|
||
cxGridPopupMenu2: TcxGridPopupMenu;
|
||
TV2issp: TcxGridDBColumn;
|
||
N2: TMenuItem;
|
||
Tv1Contacts: TcxGridDBColumn;
|
||
TbAddressCopy: TToolButton;
|
||
Tv1OverTime: TcxGridDBColumn;
|
||
Tv1CheckEdit: TcxGridDBColumn;
|
||
Tv1CoName: TcxGridDBColumn;
|
||
ToolButton8: TToolButton;
|
||
TbUndoVisible: TToolButton;
|
||
TV2PFPrice: TcxGridDBColumn;
|
||
Tv1Saleser: TcxGridDBColumn;
|
||
TbNowDay: TcxButton;
|
||
//RMllPDFExport1: TRMllPDFExport;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBFindClick(Sender: TObject);
|
||
procedure TBEditClick(Sender: TObject);
|
||
procedure TBDelClick(Sender: TObject);
|
||
procedure TBExportClick(Sender: TObject);
|
||
procedure TBPrintClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure TBAddClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure CheckBox1Click(Sender: TObject);
|
||
procedure CheckBox2Click(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure ToCoNameChange(Sender: TObject);
|
||
procedure tchkClick(Sender: TObject);
|
||
procedure TnochkClick(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure btnWCClick(Sender: TObject);
|
||
procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
procedure btnWCCXClick(Sender: TObject);
|
||
procedure v1Column7PropertiesEditValueChanged(Sender: TObject);
|
||
procedure Tv1Column9PropertiesEditValueChanged(Sender: TObject);
|
||
procedure ToolButton6Click(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
procedure ToolButton5Click(Sender: TObject);
|
||
procedure ToolButton7Click(Sender: TObject);
|
||
procedure TbGoodsEditClick(Sender: TObject);
|
||
procedure v1Column4PropertiesChange(Sender: TObject);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure PM11Click(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
procedure TbAddressCopyClick(Sender: TObject);
|
||
procedure Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
||
procedure Tv1CheckEditStylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle);
|
||
procedure Tv1FlagStylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle);
|
||
procedure ToolButton8Click(Sender: TObject);
|
||
procedure Tv1OverTimeCustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
||
procedure TbUndoVisibleClick(Sender: TObject);
|
||
procedure TbNowDayClick(Sender: TObject);
|
||
|
||
private
|
||
fcxGridStyleFlag: Boolean;
|
||
procedure InitGrid();
|
||
procedure InitSubGrid();
|
||
procedure InitForm();
|
||
procedure SetStatus();
|
||
function DelData(): Boolean;
|
||
|
||
{ Private declarations }
|
||
public
|
||
FFInt: Integer;
|
||
canshu1, canshu2: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
//var
|
||
//frmContractListNX: TfrmContractListNX;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_TatDRtInPut, U_RTFun, U_ZDYHelp, U_LabelPrint,
|
||
U_AttachmentUpload;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmTatDRList.SetStatus();
|
||
begin
|
||
tchk.Enabled := False;
|
||
Tnochk.Enabled := False;
|
||
btnWC.Enabled := False;
|
||
btnWCCX.Enabled := False;
|
||
ToolButton3.Enabled := False;
|
||
ToolButton5.Enabled := False;
|
||
TbGoodsEdit.Enabled := False;
|
||
|
||
TBEdit.Enabled := False;
|
||
|
||
Tv1ToCoName.Visible := False;
|
||
Tv1CoName.Visible := False;
|
||
|
||
TBDel.Enabled := False;
|
||
if CANSHU1 = '查询' then
|
||
begin
|
||
ToolButton1.Enabled := True;
|
||
TBPrint.Enabled := True;
|
||
ToolButton2.Enabled := True;
|
||
ToolButton4.Enabled := True;
|
||
TBExport.Enabled := True;
|
||
ToolButton7.Enabled := True;
|
||
TbGoodsEdit.Enabled := True;
|
||
|
||
TBAdd.Enabled := True;
|
||
|
||
Tv1ToCoName.Visible := True;
|
||
TV2PFPrice.Visible := False;
|
||
// TBDel.Enabled := True;
|
||
case cxTabControl1.TabIndex of
|
||
0:
|
||
begin
|
||
TBEdit.Enabled := True;
|
||
end;
|
||
1:
|
||
begin
|
||
btnWC.Enabled := true;
|
||
TBEdit.Enabled := True;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
if canshu1 = '管理' then
|
||
begin
|
||
Tv1CoName.Visible := True;
|
||
case cxTabControl1.TabIndex of
|
||
0:
|
||
begin
|
||
ToolButton3.Enabled := true;
|
||
// TbGoodsEdit.Enabled := True;
|
||
tchk.Enabled := true;
|
||
|
||
TBDel.Enabled := True;
|
||
|
||
TBEdit.Enabled := True;
|
||
end;
|
||
1:
|
||
begin
|
||
Tnochk.Enabled := true;
|
||
btnWC.Enabled := true;
|
||
TBDel.Enabled := True;
|
||
|
||
TBEdit.Enabled := True;
|
||
end;
|
||
2:
|
||
begin
|
||
btnWCCX.Enabled := true;
|
||
end;
|
||
3:
|
||
begin
|
||
ToolButton5.Enabled := true;
|
||
end;
|
||
end;
|
||
end
|
||
else if canshu1 = '录入' then
|
||
begin
|
||
|
||
Tv1ToCoName.Visible := True;
|
||
case cxTabControl1.TabIndex of
|
||
0:
|
||
begin
|
||
TBEdit.Enabled := True;
|
||
end;
|
||
1:
|
||
begin
|
||
TBEdit.Enabled := True;
|
||
btnWC.Enabled := true;
|
||
|
||
// TBDel.Enabled := True;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
if canshu1 = '财务' then
|
||
begin
|
||
TBAdd.Enabled := False;
|
||
TBPrint.Enabled := False;
|
||
ToolButton2.Enabled := False;
|
||
TbAddressCopy.Enabled := False;
|
||
ToolButton8.Enabled := False;
|
||
TbUndoVisible.Enabled := False;
|
||
|
||
// Tv1CoName.Visible := True;
|
||
// case cxTabControl1.TabIndex of
|
||
// 0:
|
||
// begin
|
||
// ToolButton3.Enabled := true;
|
||
//// TbGoodsEdit.Enabled := True;
|
||
// tchk.Enabled := true;
|
||
//
|
||
// TBDel.Enabled := True;
|
||
//
|
||
// TBEdit.Enabled := True;
|
||
// end;
|
||
// 1:
|
||
// begin
|
||
// Tnochk.Enabled := true;
|
||
// btnWC.Enabled := true;
|
||
// TBDel.Enabled := True;
|
||
//
|
||
// TBEdit.Enabled := True;
|
||
// end;
|
||
// 2:
|
||
// begin
|
||
// btnWCCX.Enabled := true;
|
||
// end;
|
||
// 3:
|
||
// begin
|
||
// ToolButton5.Enabled := true;
|
||
// end;
|
||
// end;
|
||
end
|
||
end;
|
||
|
||
procedure TfrmTatDRList.FormDestroy(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
//frmFHSQList:=nil;
|
||
|
||
end;
|
||
|
||
procedure TfrmTatDRList.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
|
||
sselJS.Caption := '0';
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered := False;
|
||
Close;
|
||
sql.Clear;
|
||
Sql.Add(' select A.* ');
|
||
sql.Add(' from V_TatDRList A where 1=1');
|
||
if CheckBox1.Checked then
|
||
begin
|
||
sql.Add(' and A.Filltime>=''' + FormatDateTime('yyyy-MM-dd', begdate.DateTime) + ''' ');
|
||
sql.Add(' and A.Filltime<''' + FormatDateTime('yyyy-MM-dd', Enddate.DateTime + 1) + ''' ');
|
||
end;
|
||
case cxTabControl1.TabIndex of
|
||
0:
|
||
begin
|
||
SQL.Add(' and isnull(A.status,''0'')=''0'' ');
|
||
end;
|
||
1:
|
||
begin
|
||
SQL.Add(' and isnull(A.status,''0'')=''9'' ');
|
||
end;
|
||
2:
|
||
begin
|
||
SQL.Add(' and isnull(A.status,''0'')=''10'' ');
|
||
end;
|
||
3:
|
||
begin
|
||
SQL.Add(' and isnull(A.status,''0'')=''-2'' ');
|
||
end;
|
||
4:
|
||
begin
|
||
SQL.Add(' and isnull(A.status,''0'')<>''-2'' ');
|
||
end;
|
||
end;
|
||
|
||
if Trim(canshu1) = '录入' then
|
||
begin
|
||
sql.Add(' and isnull(A.Filler,'''')=''' + Trim(DName) + '''');
|
||
end;
|
||
sql.Add(' order by A.Filltime desc ');
|
||
// ShowMessage(sql.Text);
|
||
Open;
|
||
end;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS(ADOQueryMain, Order_Main);
|
||
SInitCDSData(ADOQueryMain, Order_Main);
|
||
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
TV1.DataController.Filter.Clear;
|
||
TV2.DataController.Filter.Clear;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.InitForm();
|
||
begin
|
||
|
||
ReadCxGrid(trim(self.Caption) + 'Tv1', Tv1, '发货管理');
|
||
ReadCxGrid(trim(self.Caption) + 'Tv2', Tv2, '发货管理');
|
||
|
||
EndDate.DateTime := SGetServerDate(ADOQueryTemp);
|
||
BegDate.DateTime := EndDate.DateTime - 60;
|
||
InitGrid();
|
||
|
||
end;
|
||
|
||
procedure TfrmTatDRList.TBFindClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS(ADOQueryMain, Order_Main);
|
||
SInitCDSData(ADOQueryMain, Order_Main);
|
||
end;
|
||
|
||
procedure TfrmTatDRList.TBEditClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
Exit;
|
||
// if cxTabControl1.TabIndex <> 0 then
|
||
// Exit;
|
||
// if Trim(canshu1) <> '管理' then
|
||
// begin
|
||
|
||
// with ADOQueryTemp do
|
||
// begin
|
||
// Close;
|
||
// sql.Clear;
|
||
// SQL.Add('select FILLER from Tat_Cloth_DR_Main A ');
|
||
// SQL.Add('where DRMID=''' + Trim(Order_Main.fieldbyname('DRMID').AsString) + ''' ');
|
||
// SQL.Add('and filler in ( select username from SY_User where UType=(select UType from SY_User where UserName=' + quotedstr(Trim(dname)));
|
||
// SQL.Add('))');
|
||
// Open;
|
||
// end;
|
||
//
|
||
// if ADOQueryTemp.ISEMPTY = True then
|
||
// begin
|
||
// Application.MessageBox('不能操作他人的数据!', '提示', 0);
|
||
// Exit;
|
||
// end;
|
||
if Trim(Order_Main.fieldbyname('Filler').AsString) <> Trim(DName) then
|
||
begin
|
||
Application.MessageBox('不能操作他人的数据!', '提示', 0);
|
||
Exit;
|
||
end;
|
||
// end;
|
||
// with ADOQueryTemp do
|
||
// begin
|
||
// close;
|
||
// sql.Clear;
|
||
// sql.Add('select * from Tat_Cloth_DR_Main');
|
||
// sql.Add('where DRMID=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
// Open;
|
||
// end;
|
||
// if Trim(ADOQueryTemp.fieldbyname('YSID').AsString) <> '' then
|
||
// begin
|
||
// Application.MessageBox('已生成应收账款不能修改数据!', '提示', 0);
|
||
// Exit;
|
||
// end;
|
||
try
|
||
frmTatDRtInPut := TfrmTatDRtInPut.Create(Application);
|
||
with frmTatDRtInPut do
|
||
begin
|
||
PState := 1;
|
||
canshu1 := self.canshu1;
|
||
isCheck := cxTabControl1.TabIndex;
|
||
Tv1Volume.Options.Editing := False;
|
||
Tv1ApplicationReaon.Options.Editing := False;
|
||
FDRMID := Trim(Self.Order_Main.fieldbyname('DRMID').AsString);
|
||
if ShowModal = 1 then
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
end;
|
||
finally
|
||
frmTatDRtInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.TBDelClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
Exit;
|
||
if (cxTabControl1.TabIndex <> 0) and (cxTabControl1.TabIndex <> 1) then
|
||
Exit;
|
||
// if canshu1 <> '管理' then
|
||
// begin
|
||
// if Trim(Order_Main.fieldbyname('Filler').AsString) <> Trim(DName) then
|
||
// begin
|
||
// Application.MessageBox('不能操作他人的数据!', '提示', 0);
|
||
// Exit;
|
||
// end;
|
||
// end;
|
||
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select * from Tat_Cloth_IO where ioflag=''出库'' ');
|
||
sql.add(' and IONo=''' + Trim(Order_Main.fieldbyname('DRMID').AsString) + '''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty = False then
|
||
begin
|
||
Application.MessageBox('出库数据不能删除!', '提示', 0);
|
||
exit;
|
||
end;
|
||
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select * from Tat_Cloth_IO where ioflag=''待出库'' ');
|
||
sql.add(' and IONo=''' + Trim(Order_Main.fieldbyname('DRMID').AsString) + '''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty = False then
|
||
begin
|
||
Application.MessageBox('待出库数据不能删除!', '提示', 0);
|
||
exit;
|
||
end;
|
||
|
||
if Application.MessageBox('确定要删除数据吗?', '提示', 32 + 4) <> IDYES then
|
||
Exit;
|
||
if DelData() then
|
||
begin
|
||
Order_Main.Delete;
|
||
InitSubGrid();
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.TbGoodsEditClick(Sender: TObject);
|
||
var
|
||
maxno: string;
|
||
begin
|
||
try
|
||
frmTatDRtInPut := TfrmTatDRtInPut.Create(Application);
|
||
with frmTatDRtInPut do
|
||
begin
|
||
PState := 2; ///配货修改
|
||
FDRMID := Trim(Self.Order_Main.fieldbyname('DRMID').AsString);
|
||
canshu1 := self.canshu1;
|
||
|
||
ScrollBox1.Visible := False;
|
||
ToolBar2.Visible := false;
|
||
TbPHSave.visible := True;
|
||
TBSave.Visible := False;
|
||
|
||
// Tv1Applicant.Visible := True;
|
||
|
||
Tv1C_Name.Options.Editing := False;
|
||
Tv1C_code.Options.Editing := False;
|
||
Tv1C_width.Options.Editing := False;
|
||
Tv1C_GramWeight.Options.Editing := False;
|
||
Tv1c_Color.Options.Editing := False;
|
||
Tv1Piece.Options.Editing := False;
|
||
Tv1Qty.Options.Editing := False;
|
||
Tv1PINGFANG.Options.Editing := False;
|
||
|
||
if ShowModal = 1 then
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
end;
|
||
finally
|
||
frmTatDRtInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.TbNowDayClick(Sender: TObject);
|
||
begin
|
||
BegDate.Date := strToDate(FormatDateTime('yyyy-MM-dd', SGetServerDate(ADOQueryCmd)));
|
||
EndDate.Date := strToDate(FormatDateTime('yyyy-MM-dd', SGetServerDate(ADOQueryCmd)));
|
||
InitGrid();
|
||
end;
|
||
|
||
function TfrmTatDRList.DelData(): Boolean;
|
||
begin
|
||
|
||
try
|
||
with Order_Main do
|
||
begin
|
||
DisableControls;
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
if fieldbyname('SSel').AsBoolean then
|
||
begin
|
||
Result := false;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete Tat_Cloth_DR_Sub where DRMID=''' + Trim(Order_Main.fieldbyname('DRMID').AsString) + '''');
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete Tat_Cloth_DR_Main where DRMID=''' + Trim(Order_Main.fieldbyname('DRMID').AsString) + '''');
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
Result := True;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Result := False;
|
||
Application.MessageBox('数据删除异常!', '提示', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.TBExportClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then
|
||
Exit;
|
||
with Order_Main do
|
||
begin
|
||
Filtered := false;
|
||
Filter := ' ssel = 1';
|
||
Filtered := true;
|
||
end;
|
||
TcxGridToExcel(Self.Caption, cxGrid1);
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTatDRList.TBPrintClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
Exit;
|
||
|
||
try
|
||
frmLabelPrint := TfrmLabelPrint.Create(Application);
|
||
with frmLabelPrint do
|
||
begin
|
||
FLMType := 'TradeClothDR1';
|
||
FFiltration1 := Trim(self.Order_Main.fieldbyname('DRMID').AsString);
|
||
if ShowModal = 1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmLabelPrint.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTatDRList.TbUndoVisibleClick(Sender: TObject);
|
||
begin
|
||
with Order_Main do
|
||
begin
|
||
Edit;
|
||
FieldByName('OverTime').Value := '';
|
||
post;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.TBAddClick(Sender: TObject);
|
||
var
|
||
maxno: string;
|
||
begin
|
||
try
|
||
frmTatDRtInPut := TfrmTatDRtInPut.Create(Application);
|
||
with frmTatDRtInPut do
|
||
begin
|
||
PState := 0;
|
||
isCheck := 0;
|
||
FDRMID := '';
|
||
canshu1 := self.canshu1;
|
||
if ShowModal = 1 then
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
end;
|
||
finally
|
||
frmTatDRtInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
//procedure TfrmTatDRList.TbAddressCopyClick(Sender: TObject);
|
||
//var
|
||
// CopyValue : string;
|
||
//begin
|
||
// if Order_Main.IsEmpty then
|
||
// begin
|
||
// Exit;
|
||
// end;
|
||
//
|
||
// if not Order_Main.Active then
|
||
// begin
|
||
// Application.MessageBox('未选中记录!','提示信息',MB_OK);
|
||
// end;
|
||
//
|
||
// CopyValue := Order_Main.FieldByName('Contacts').AsString + ' ' ;
|
||
// CopyValue := CopyValue + Order_Main.FieldByName('Telephone').AsString + #13;
|
||
// CopyValue := CopyValue + Order_Main.FieldByName('CoAddress').AsString;
|
||
// Clipboard.SetTextBuf(PChar(Trim(CopyValue)));
|
||
//end;
|
||
procedure TfrmTatDRList.TbAddressCopyClick(Sender: TObject);
|
||
var
|
||
CopyValue: string;
|
||
MsgLabel: TLabel;
|
||
begin
|
||
if Order_Main.IsEmpty or not Order_Main.Active then
|
||
begin
|
||
Application.MessageBox('未选中记录!', '提示信息', MB_OK);
|
||
Exit;
|
||
end;
|
||
|
||
CopyValue := Order_Main.FieldByName('Contacts').AsString + ' ';
|
||
CopyValue := CopyValue + Order_Main.FieldByName('Telephone').AsString + #13;
|
||
CopyValue := CopyValue + Order_Main.FieldByName('CoAddress').AsString;
|
||
|
||
Clipboard.AsText := Trim(CopyValue);
|
||
// MessageDlg('地址信息已成功复制到剪贴板!', mtInformation, [mbOK], 0);
|
||
|
||
|
||
end;
|
||
|
||
procedure TfrmTatDRList.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
fcxGridStyleFlag := False;
|
||
canshu1 := self.fParameters1;
|
||
InitForm();
|
||
SetStatus();
|
||
|
||
end;
|
||
|
||
procedure TfrmTatDRList.CheckBox1Click(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTatDRList.CheckBox2Click(Sender: TObject);
|
||
begin
|
||
TBRafresh.Click;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
Exit;
|
||
try
|
||
frmTatDRtInPut := TfrmTatDRtInPut.Create(Application);
|
||
with frmTatDRtInPut do
|
||
begin
|
||
PState := 1;
|
||
FDRMID := Trim(Self.Order_Main.fieldbyname('DRMID').AsString);
|
||
ToolBar2.Visible := False;
|
||
TBSave.Visible := False;
|
||
ScrollBox1.Enabled := False;
|
||
canshu1 := self.canshu1;
|
||
Tv1.OptionsSelection.CellSelect := False;
|
||
if ShowModal = 1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmTatDRtInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if order_main.IsEmpty then
|
||
Exit;
|
||
|
||
try
|
||
frmLabelPrint := TfrmLabelPrint.Create(Application);
|
||
with frmLabelPrint do
|
||
begin
|
||
FLMType := 'TatClothOut1';
|
||
FFiltration1 := Trim(self.order_main.fieldbyname('DRMID').AsString);
|
||
if ShowModal = 1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmLabelPrint.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
exit;
|
||
if cxTabControl1.TabIndex <> 0 then
|
||
exit;
|
||
|
||
if Order_Main.Locate('ssel', True, []) = false then
|
||
begin
|
||
Application.MessageBox('请先选择数据!', '提示信息', MB_OK);
|
||
exit;
|
||
end;
|
||
try
|
||
with Order_Main do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
if fieldbyname('SSel').AsBoolean then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update Tat_Cloth_DR_Main SET Status=''-2'' ');
|
||
sql.Add('where DRMID=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
execsql;
|
||
end;
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
|
||
InitGrid();
|
||
InitSubGrid();
|
||
application.MessageBox('取消成功!', '提示信息');
|
||
except
|
||
application.MessageBox('取消失败!', '提示信息', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.ToolButton4Click(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
Exit;
|
||
try
|
||
frmAttachmentUpload := TfrmAttachmentUpload.Create(Application);
|
||
with frmAttachmentUpload do
|
||
begin
|
||
if Trim(canshu1) <> '查询' then
|
||
FEditAuthority := True;
|
||
fkeyNO := Trim(Self.Order_Main.fieldbyname('DRMID').AsString);
|
||
fType := '发货申请';
|
||
if ShowModal = 1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmAttachmentUpload.Free;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmTatDRList.ToolButton5Click(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
exit;
|
||
if cxTabControl1.TabIndex <> 3 then
|
||
exit;
|
||
|
||
if Order_Main.Locate('ssel', True, []) = false then
|
||
begin
|
||
Application.MessageBox('请先选择数据!', '提示信息', MB_OK);
|
||
exit;
|
||
end;
|
||
try
|
||
with Order_Main do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
if fieldbyname('SSel').AsBoolean then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update Tat_Cloth_DR_Main SET Status=''0'' ');
|
||
sql.Add('where DRMID=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
execsql;
|
||
end;
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
|
||
InitGrid();
|
||
InitSubGrid();
|
||
application.MessageBox('撤销取消成功!', '提示信息');
|
||
except
|
||
application.MessageBox('撤销取消失败!', '提示信息', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.ToCoNameChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS(ADOQueryMain, Order_Main);
|
||
SInitCDSData(ADOQueryMain, Order_Main);
|
||
end;
|
||
|
||
procedure TfrmTatDRList.tchkClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
exit;
|
||
if cxTabControl1.TabIndex <> 0 then
|
||
exit;
|
||
|
||
if Order_Main.Locate('ssel', True, []) = false then
|
||
begin
|
||
Application.MessageBox('请先选择数据!', '提示信息', MB_OK);
|
||
exit;
|
||
end;
|
||
|
||
try
|
||
with Order_Main do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
if fieldbyname('SSel').AsBoolean then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update Tat_Cloth_DR_Main SET Chker=''' + Trim(DName) + ''',ChkTime=getdate(),Status=''9'' ');
|
||
sql.Add('where DRMID=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
execsql;
|
||
end;
|
||
end;
|
||
|
||
next;
|
||
end;
|
||
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
|
||
InitGrid();
|
||
InitSubGrid();
|
||
application.MessageBox('审核成功!', '提示信息');
|
||
except
|
||
application.MessageBox('审核失败!', '提示信息', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.InitSubGrid();
|
||
begin
|
||
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.* ');
|
||
sql.Add('from Tat_Cloth_DR_Sub A where A.DRMID=''' + Trim(Order_Main.fieldbyname('DRMID').AsString) + '''');
|
||
// ShowMessage(SQL.Text);
|
||
Open;
|
||
end;
|
||
SCreateCDS(ADOQueryTemp, ClientDataSet2);
|
||
SInitCDSData(ADOQueryTemp, ClientDataSet2);
|
||
end;
|
||
|
||
procedure TfrmTatDRList.N1Click(Sender: TObject);
|
||
var
|
||
msumJS: Currency;
|
||
begin
|
||
SelOKNo(Order_Main, true);
|
||
msumJS := 0;
|
||
Order_Main.First;
|
||
while not Order_Main.Eof do
|
||
begin
|
||
msumJS := msumJS + Order_Main.FieldByName('sselJS').AsCurrency;
|
||
Order_Main.Next;
|
||
end;
|
||
|
||
SSelJS.Caption := CurrToStr(msumJS);
|
||
end;
|
||
|
||
procedure TfrmTatDRList.N2Click(Sender: TObject);
|
||
begin
|
||
Clipboard.SetTextBuf(PChar(Trim(Order_Main.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
|
||
end;
|
||
|
||
procedure TfrmTatDRList.PM11Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(Order_Main, false);
|
||
SSelJS.Caption := '0';
|
||
end;
|
||
|
||
procedure TfrmTatDRList.TnochkClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
exit;
|
||
if cxTabControl1.TabIndex <> 1 then
|
||
exit;
|
||
if Order_Main.Locate('ssel', True, []) = false then
|
||
begin
|
||
Application.MessageBox('请先选择数据!', '提示信息', MB_OK);
|
||
exit;
|
||
end;
|
||
try
|
||
with Order_Main do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
if fieldbyname('SSel').AsBoolean then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update Tat_Cloth_DR_Main SET Chker=Null,ChkTime=Null,status=''0'' ');
|
||
sql.Add('where DRMID=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
execsql;
|
||
end;
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
InitGrid();
|
||
application.MessageBox('撤销成功!', '提示信息');
|
||
except
|
||
application.MessageBox('撤销失败!', '提示信息', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
TBRafresh.Click;
|
||
SetStatus();
|
||
end;
|
||
|
||
procedure TfrmTatDRList.btnWCCXClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
exit;
|
||
|
||
if Order_Main.Locate('ssel', True, []) = false then
|
||
begin
|
||
Application.MessageBox('请先选择数据!', '提示信息', MB_OK);
|
||
exit;
|
||
end;
|
||
try
|
||
with Order_Main do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
if fieldbyname('SSel').AsBoolean then
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('exec P_Fin_Judge_All @DataID=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.FieldByName('intReturn').AsInteger = -1 then
|
||
begin
|
||
Application.MessageBox(PChar(ADOQueryTemp.fieldbyname('ShowMsg').AsString), '提示', 0);
|
||
exit;
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update Tat_Cloth_DR_Main SET status=''9'' ,Comper=null,Comptime=null ');
|
||
sql.Add('where DRMID=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
execsql;
|
||
end;
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
InitGrid();
|
||
InitSubGrid();
|
||
application.MessageBox('操作成功!', '提示信息');
|
||
except
|
||
application.MessageBox('操作失败!', '提示信息', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.ToolButton6Click(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(trim(self.Caption) + 'Tv1', Tv1, '发货管理');
|
||
WriteCxGrid(trim(self.Caption) + 'Tv2', Tv2, '发货管理');
|
||
end;
|
||
|
||
procedure TfrmTatDRList.ToolButton7Click(Sender: TObject);
|
||
begin
|
||
try
|
||
with Order_Main do
|
||
begin
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
|
||
sql.Add('update Tat_Cloth_Stock SET StkExists=0 ');
|
||
// sql.Add('where iono=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
sql.add('where IsStocking=''1''');
|
||
sql.Add('and STKID IN (SELECT STKID FROM Tat_Cloth_IO F ');
|
||
SQL.Add('where iono=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
sql.add('and ioflag=''待出库'')');
|
||
|
||
sql.Add('update Tat_Cloth_Inspect SET CIIOFlag=''已出库'' ');
|
||
// sql.Add('where iono=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
sql.add('where ');
|
||
sql.Add(' ciid IN (SELECT STKID FROM Tat_Cloth_IO F ');
|
||
SQL.Add('where iono=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
sql.add('and ioflag=''待出库'')');
|
||
|
||
sql.Add('update Tat_Cloth_IO SET ioflag=''出库'',iotime=getdate() ');
|
||
sql.Add('where iono=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
sql.add('and ioflag=''待出库''');
|
||
execsql;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('exec P_Tat_Cloth_DR @OutNoS=' + Quotedstr(Trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
Open;
|
||
end;
|
||
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
|
||
begin
|
||
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
|
||
end;
|
||
EnableControls;
|
||
end;
|
||
InitGrid();
|
||
InitSubGrid();
|
||
application.MessageBox('操作成功!', '提示信息');
|
||
except
|
||
application.MessageBox('操作失败!', '提示信息', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.ToolButton8Click(Sender: TObject);
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
SQL.Add(' SELECT 1 FROM Tat_Cloth_DR_Sub X WHERE X.DRMID=' + quotedStr(Trim(Order_Main.FieldByName('DRMID').asString)));
|
||
sql.Add(' AND isnull(X.Piece,0) > isnull(X.DlyPiece,0)');
|
||
SQL.Add(' AND CONVERT(date, ' + quotedStr(Trim(Order_Main.FieldByName('DlyDate').asString)) + ') < CONVERT(date, GETDATE())');
|
||
Open;
|
||
end;
|
||
|
||
if not ADOQueryCmd.IsEmpty then
|
||
begin
|
||
with Order_Main do
|
||
begin
|
||
Edit;
|
||
FieldByName('OverTime').asString := '未发完';
|
||
post;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox('已发完!', '提示信息', MB_OK);
|
||
Exit;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmTatDRList.btnWCClick(Sender: TObject);
|
||
var
|
||
str: string;
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
exit;
|
||
|
||
if Order_Main.Locate('ssel', True, []) = false then
|
||
begin
|
||
Application.MessageBox('请先选择数据!', '提示信息', MB_OK);
|
||
exit;
|
||
end;
|
||
try
|
||
with Order_Main do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
if fieldbyname('SSel').AsBoolean then
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
SQL.Add('SELECT TT=ISNULL(SUM(DlyPiece),0),T1=ISNULL(SUM(PIECE),0) FROM Tat_Cloth_DR_SUB A WHERE A.DRMID=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
OPEN;
|
||
end;
|
||
if ADOQueryTemp.FieldByName('TT').AsInteger = 0 then
|
||
begin
|
||
application.MessageBox('发货数量为0,不能完成!', '提示信息');
|
||
EnableControls;
|
||
exit;
|
||
end;
|
||
if ADOQueryTemp.FieldByName('TT').AsInteger < ADOQueryTemp.FieldByName('T1').AsInteger then
|
||
begin
|
||
if InputQuery('输入备注', '备注', str) then
|
||
begin
|
||
|
||
if Trim(str) = '' then
|
||
begin
|
||
ShowMessage('备注不能为空!');
|
||
Exit; // 或者使用 Exit; 来退出当前过程
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('update Tat_Cloth_DR_main ');
|
||
sql.Add(' set wcnote=' + quotedstr(str));
|
||
sql.Add(' where drmid=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
ExecSQL;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
EnableControls;
|
||
exit;
|
||
end;
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update Tat_Cloth_DR_Main SET status=''10'' ,Comper=''' + Trim(DName) + ''',Comptime=getdate() ');
|
||
sql.Add('where DRMID=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
|
||
// sql.Add('exec P_Do_WXInsert_MD ');
|
||
// sql.Add('@CKORDNO=' + quotedstr(trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
|
||
execsql;
|
||
end;
|
||
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
InitGrid();
|
||
InitSubGrid();
|
||
application.MessageBox('操作成功!', '提示信息');
|
||
except
|
||
application.MessageBox('操作失败!', '提示信息', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.Tv1CheckEditStylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle);
|
||
var
|
||
GroupValue: string;
|
||
// ColorValue: Integer;
|
||
I: Integer;
|
||
begin
|
||
if (ARecord <> nil) and (ARecord is TcxGridDataRow) then
|
||
begin
|
||
GroupValue := VarToStr(ARecord.Values[Tv1CheckEdit.Index]);
|
||
if (GroupValue <> '') and (GroupValue <> null) then
|
||
begin
|
||
// ColorValue := StrToInt(GroupValue);
|
||
AStyle := TcxStyle.Create(nil);
|
||
if GroupValue = '已改单' then
|
||
AStyle.Color := $0090FFFF;
|
||
AStyle.TextColor := clBlack;
|
||
end;
|
||
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.Tv1Column9PropertiesEditValueChanged(Sender: TObject);
|
||
var
|
||
mvalue, FFieldName: string;
|
||
begin
|
||
mvalue := TcxTextEdit(Sender).EditingText;
|
||
FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
|
||
|
||
if mvalue = '' then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('update Tat_Cloth_DR_Main set ' + FFieldName + '=' + 'NULL');
|
||
sql.Add('where DRMID=' + quotedstr(Trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
ExecSQL;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
with Order_Main do
|
||
begin
|
||
Edit;
|
||
FieldByName(FFieldName).Value := mvalue;
|
||
Post;
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('update Tat_Cloth_DR_Main set ' + FFieldName + '=' + quotedstr(Trim(mvalue)));
|
||
sql.Add('where DRMID=' + quotedstr(Trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
|
||
tv1.Controller.EditingController.ShowEdit();
|
||
end;
|
||
|
||
procedure TfrmTatDRList.Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
||
var
|
||
FLAG: Variant;
|
||
begin
|
||
// FLAG := AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('FLAG').Index];
|
||
// if FLAG = 1 then // 未排入计划单
|
||
// begin
|
||
// ACanvas.Brush.Color := $00CCCCFF; // 浅红色背景
|
||
// ACanvas.Font.Color := clRed;
|
||
// ACanvas.Font.Style := [fsBold];
|
||
// end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.Tv1FlagStylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle);
|
||
var
|
||
GroupValue: string;
|
||
// ColorValue: Integer;
|
||
I: Integer;
|
||
begin
|
||
|
||
// if not fcxGridStyleFlag then
|
||
// begin
|
||
// Exit;
|
||
// end;
|
||
//
|
||
// if (ARecord <> nil) and (ARecord is TcxGridDataRow) then
|
||
// begin
|
||
// GroupValue := VarToStr(ARecord.Values[Tv1OverTime.Index]);
|
||
// if (GroupValue <> '') and (GroupValue <> null) then
|
||
// begin
|
||
//// ColorValue := StrToInt(GroupValue);
|
||
// AStyle := TcxStyle.Create(nil);
|
||
// if GroupValue = '已超期' then
|
||
// AStyle.Color := $00CCCCFF;
|
||
// AStyle.TextColor := clBlack;
|
||
// end;
|
||
//
|
||
// end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
begin
|
||
InitSubGrid();
|
||
end;
|
||
|
||
procedure TfrmTatDRList.Tv1OverTimeCustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
||
//单格子
|
||
var
|
||
FLAG: string;
|
||
begin
|
||
// id := TV1.GetColumnByFieldName('OverTime').Index; //;-TV1.GroupedItemCount;
|
||
// if AViewInfo.GridRecord.Values[tv1.GetColumnByFieldName('OverTime').Index] = 1 then
|
||
// ACanvas.BRUSH.Color := clAqua;
|
||
// if AViewInfo.GridRecord.Values[id] = 1 then
|
||
// begin
|
||
// ACanvas.Brush.Color := clRed;
|
||
// end;
|
||
|
||
FLAG := AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('OverTime').Index];
|
||
if FLAG = '未发完' then // 未排入计划单
|
||
begin
|
||
ACanvas.Brush.Color := $00CCCCFF; // 浅红色背景
|
||
ACanvas.Font.Color := clRed;
|
||
ACanvas.Font.Style := [fsBold];
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.v1Column4PropertiesChange(Sender: TObject);
|
||
var
|
||
mDRMIDList: string;
|
||
TotalPiece: Variant;
|
||
mDRMID: string; //定位作用
|
||
begin
|
||
// mDRMIDList := '';
|
||
// 保存当前记录的 BCIID
|
||
// if not Order_Main.IsEmpty then
|
||
// mDRMID := Trim(Order_Main.FieldByName('DRMID').AsString)
|
||
// else
|
||
// mDRMID := '';
|
||
//
|
||
// try
|
||
// // 确保数据集状态正常
|
||
// Order_Main.DisableControls;
|
||
// try
|
||
// Order_Main.First;
|
||
// while not Order_Main.Eof do
|
||
// begin
|
||
// if Order_Main.FieldByName('ssel').AsBoolean then
|
||
// begin
|
||
// if mDRMIDList = '' then
|
||
// mDRMIDList := QuotedStr(Trim(Order_Main.FieldByName('DRMID').AsString))
|
||
// else
|
||
// mDRMIDList := mDRMIDList + ',' + QuotedStr(Trim(Order_Main.FieldByName('DRMID').AsString));
|
||
// end;
|
||
// Order_Main.Next;
|
||
// end;
|
||
// finally
|
||
// Order_Main.EnableControls;
|
||
// end;
|
||
//
|
||
// // 如果没有选择任何记录
|
||
// if mDRMIDList = '' then
|
||
// begin
|
||
//
|
||
// if mDRMID <> '' then
|
||
// Order_Main.Locate('DRMID', mDRMID, []);
|
||
// sselJS.Caption := '0';
|
||
// Exit;
|
||
// end;
|
||
//
|
||
// // 执行查询
|
||
// with ADOQueryCmd do
|
||
// begin
|
||
// Close;
|
||
// SQL.Clear;
|
||
// SQL.Add('select isnull(sum(Piece), 0) as sselJS from Tat_Cloth_DR_Sub');
|
||
// SQL.Add('where DRMID in (' + mDRMIDList + ')');
|
||
//
|
||
// // 调试时可以显示SQL语句
|
||
//// ShowMessage('SQL: ' + SQL.Text);
|
||
//
|
||
// Open;
|
||
//
|
||
// // 处理结果(更安全的方式)
|
||
// if not IsEmpty then
|
||
// begin
|
||
// TotalPiece := FieldByName('sselJS').Value;
|
||
// // 处理NULL值和空值
|
||
// if VarIsNull(TotalPiece) or VarIsEmpty(TotalPiece) then
|
||
// sselJS.Caption := '0'
|
||
// else
|
||
// sselJS.Caption := VarToStr(TotalPiece);
|
||
// end
|
||
// else
|
||
// begin
|
||
// sselJS.Caption := '0';
|
||
// end;
|
||
// end;
|
||
//
|
||
//
|
||
// // 最后尝试定位回原记录
|
||
// if mDRMID <> '' then
|
||
// Order_Main.Locate('DRMID', mDRMID, []);
|
||
//// sselJS.Text := '0';
|
||
//// sselJS.Text := ADOQueryCmd.FieldByName('sselJS').Value
|
||
// except
|
||
// on E: Exception do
|
||
// begin
|
||
// // 记录错误信息
|
||
// sselJS.Caption := '0';
|
||
// ShowMessage('查询失败: ' + E.Message + #13#10 + 'SQL语句: ' + ADOQueryCmd.SQL.Text);
|
||
// end;
|
||
// end;
|
||
|
||
|
||
try
|
||
|
||
mDRMID := Trim(Order_Main.FieldByName('DRMID').AsString);
|
||
// 确保数据集状态正常
|
||
Order_Main.DisableControls;
|
||
// with ADOQueryCmd do
|
||
// begin
|
||
// Close;
|
||
// SQL.Clear;
|
||
// SQL.Add('select isnull(sum(Piece), 0) as sselJS from Tat_Cloth_DR_Sub ');
|
||
// SQL.Add(' where DRMID = ' + QuotedStr(Trim(mDRMID)));
|
||
// Open;
|
||
// end;
|
||
|
||
// 如果没有选择任何记录
|
||
|
||
if Order_Main.IsEmpty then
|
||
exit;
|
||
with Order_Main do
|
||
begin
|
||
if fieldbyname('Ssel').AsBoolean = true then
|
||
sselJS.Caption := currtostr(strtoCurr(sselJS.Caption) + Order_Main.FieldByName('sselJS').AsCurrency)
|
||
else
|
||
sselJS.Caption := currtostr(strtoCurr(sselJS.Caption) - Order_Main.FieldByName('sselJS').AsCurrency);
|
||
end;
|
||
|
||
Order_Main.EnableControls;
|
||
|
||
except
|
||
on E: Exception do
|
||
begin
|
||
// 记录错误信息
|
||
sselJS.Caption := '0';
|
||
ShowMessage('查询失败: ' + E.Message + #13#10 + 'SQL语句: ' + ADOQueryCmd.SQL.Text);
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatDRList.v1Column7PropertiesEditValueChanged(Sender: TObject);
|
||
var
|
||
mvalue, FFieldName: string;
|
||
begin
|
||
mvalue := TcxTextEdit(Sender).EditingText;
|
||
FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
|
||
with Order_Main do
|
||
begin
|
||
Edit;
|
||
FieldByName(FFieldName).Value := mvalue;
|
||
Post;
|
||
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('update Tat_Cloth_DR_Main set ' + FFieldName + '=' + quotedstr(Trim(mvalue)));
|
||
sql.Add('where DRMID=' + quotedstr(Trim(Order_Main.fieldbyname('DRMID').AsString)));
|
||
ExecSQL;
|
||
end;
|
||
tv1.Controller.EditingController.ShowEdit();
|
||
end;
|
||
|
||
end.
|
||
|