RTFormwork/项目代码/RTBasicsV1/A01基础公司管理/U_ModuleNote.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

221 lines
5.8 KiB
ObjectPascal
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_ModuleNote;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, ToolWin, ComCtrls,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel,
cxClasses, cxControls, cxGridCustomView, cxGrid, DBClient, ADODB, ImgList,
StdCtrls, ExtCtrls, cxTextEdit, cxGridCustomPopupMenu, cxGridPopupMenu,
cxTimeEdit, cxCalendar;
type
TfrmModuleNote = class(TForm)
TV1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
cxGrid1: TcxGrid;
V1Name: TcxGridDBColumn;
ToolBar1: TToolBar;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
DataSource1: TDataSource;
ClientDataSet1: TClientDataSet;
TBAdd: TToolButton;
TBDel: TToolButton;
TBClose: TToolButton;
ToolButton1: TToolButton;
TBEdit: TToolButton;
V1OrderNo: TcxGridDBColumn;
Panel1: TPanel;
cxGridPopupMenu1: TcxGridPopupMenu;
Label2: TLabel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBAddClick(Sender: TObject);
procedure TBDelClick(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure TBEditClick(Sender: TObject);
procedure TV1CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure V1NamePropertiesEditValueChanged(Sender: TObject);
private
procedure InitGrid();
{ Private declarations }
public
flag:string;
{ Public declarations }
end;
var
frmModuleNote: TfrmModuleNote;
implementation
uses
U_DataLink,U_RTFun;
{$R *.dfm}
procedure TfrmModuleNote.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmModuleNote.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Close;
sql.Clear;
sql.Add('select * from SY_Module_Note A where A.MNType='''+flag+'''');
Open;
end;
SCreateCDS(ADOQueryMain,ClientDataSet1);
SInitCDSData(ADOQueryMain,ClientDataSet1);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmModuleNote.TBAddClick(Sender: TObject);
begin
TV1.OptionsData.Editing:=True;
TV1.OptionsSelection.CellSelect:=True;
with ClientDataSet1 do
begin
Append;
FieldByName('MNDate').Value:=Now;
Post;
end;
end;
procedure TfrmModuleNote.TBDelClick(Sender: TObject);
begin
if ClientDataSet1.IsEmpty then Exit;
if (Trim(ClientDataSet1.FieldByName('MNID').AsString)<>'') then
begin
if application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD>?','<27><>ʾ<EFBFBD><CABE>Ϣ',1)=2 then exit;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete SY_Module_Note where MNID='''+Trim(ClientDataSet1.fieldbyname('MNID').AsString)+'''');
ExecSQL;
end;
end;
ClientDataSet1.Delete;
end;
procedure TfrmModuleNote.TBCloseClick(Sender: TObject);
begin
ModalResult:=2;
WriteCxGrid('<27>Զ<EFBFBD><D4B6><EFBFBD>'+Trim(flag),TV1,<><C4A3>˵<EFBFBD><CBB5>');
Close;
end;
procedure TfrmModuleNote.FormShow(Sender: TObject);
var
fsj,fsj1:string;
begin
InitGrid();
ReadCxGrid('<27>Զ<EFBFBD><D4B6><EFBFBD>'+Trim(flag),TV1,<><C4A3>˵<EFBFBD><CBB5>');
frmModuleNote.Caption:=Trim(flag);
end;
procedure TfrmModuleNote.ToolButton1Click(Sender: TObject);
begin
WriteCxGrid('<27>Զ<EFBFBD><D4B6><EFBFBD>'+Trim(flag),TV1,<><C4A3>˵<EFBFBD><CBB5>');
ModalResult:=1;
end;
procedure TfrmModuleNote.TBEditClick(Sender: TObject);
begin
TV1.OptionsData.Editing:=True;
TV1.OptionsSelection.CellSelect:=True;
end;
procedure TfrmModuleNote.TV1CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
begin
if TV1.OptionsData.Editing=False then
begin
ModalResult:=1;
end;
end;
procedure TfrmModuleNote.V1NamePropertiesEditValueChanged(Sender: TObject);
var
maxno,mvalue:string;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
if Trim(mvalue)='' then
begin
//Application.MessageBox('<27><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
with ClientDataSet1 do
begin
Edit;
FieldByName('MNNote').Value:=Trim(mvalue);
//Post;
end;
try
ADOQueryCmd.Connection.BeginTrans;
if Trim(ClientDataSet1.FieldByName('MNID').AsString)='' then
begin
if GetLSNo(ADOQueryCmd,maxno,'SY','SY_Module_Note',3,1)=False then
begin
ADOQueryCmd.Connection.RollbackTrans;
//ClientDataSet1.EnableControls;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
end else
begin
maxno:=Trim(ClientDataSet1.fieldbyname('MNID').AsString);
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.add('select * from SY_Module_Note ');
sql.Add(' where MNID='''+Trim(ClientDataSet1.fieldbyname('MNID').AsString)+'''');
Open;
end;
with ADOQueryCmd do
begin
if Trim(ClientDataSet1.fieldbyname('MNID').AsString)='' then
begin
Append;
FieldByName('Filler').Value:=Trim(DName);
FieldByName('FillTime').Value:=Now;
end
else begin
Edit;
FieldByName('Editer').Value:=Trim(DName);
FieldByName('EditTime').Value:=Now;
end;
FieldByName('MNDate').Value:=ClientDataSet1.fieldbyname('MNDate').Value;
FieldByName('MNID').Value:=Trim(maxno);
FieldByName('MNNote').Value:=ClientDataSet1.fieldbyname('MNNote').AsString;
FieldByName('MNType').Value:=flag;
Post;
end;
ADOQueryCmd.Connection.CommitTrans;
ClientDataSet1.Edit;
ClientDataSet1.FieldByName('MNID').Value:=Trim(maxno);
except
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
end;
end;
end.