159 lines
3.8 KiB
ObjectPascal
159 lines
3.8 KiB
ObjectPascal
unit U_BatchEdit;
|
||
|
||
interface
|
||
|
||
uses
|
||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
|
||
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics,
|
||
cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit,
|
||
Vcl.Menus, Vcl.StdCtrls, cxButtons, cxLabel, cxTextEdit, cxMaskEdit,
|
||
cxDropDownEdit, dxSkinsCore, dxSkinWXI, Data.DB, Data.Win.ADODB, U_BaseInput;
|
||
|
||
type
|
||
TfrmBatchEdit = class(TfrmBaseInput)
|
||
price: TcxTextEdit;
|
||
btnOK: TcxButton;
|
||
btnCancel: TcxButton;
|
||
cxLabel2: TcxLabel;
|
||
ADOConnection1: TADOConnection;
|
||
ADOQuery1: TADOQuery;
|
||
priceGW: TcxTextEdit;
|
||
cxLabel1: TcxLabel;
|
||
procedure btnOKClick(Sender: TObject);
|
||
procedure btnCancelClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
|
||
public
|
||
FBCIOID: string;
|
||
FStkId: string;
|
||
FIOID: string;
|
||
Fflag: Integer;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmBatchEdit: TfrmBatchEdit;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink;
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmBatchEdit.btnCancelClick(Sender: TObject);
|
||
begin
|
||
close;
|
||
end;
|
||
|
||
procedure TfrmBatchEdit.btnOKClick(Sender: TObject);
|
||
begin
|
||
if (Fflag = 0) or (Fflag = 1) then
|
||
begin
|
||
if price.Text = '' then
|
||
price.Text := 'null';
|
||
if FBCIOID = '' then
|
||
exit;
|
||
try
|
||
with ADOQuery1 do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add(' update bs_cloth_io set price = ' + price.Text + ' where BCIOID in (' + FBCIOID + ')');
|
||
ExecSQL;
|
||
end;
|
||
finally
|
||
ModalResult := 1;
|
||
;
|
||
end;
|
||
end
|
||
else if Fflag = 2 then
|
||
begin
|
||
if price.Text = '' then
|
||
price.Text := 'null';
|
||
if FStkId = '' then
|
||
exit;
|
||
try
|
||
with ADOQuery1 do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add(' update Trade_Cloth_Stock_ZD set ZDprice = ' + price.Text + ' where StkId in (' + FStkId + ')');
|
||
ExecSQL;
|
||
end;
|
||
finally
|
||
ModalResult := 1;
|
||
;
|
||
end;
|
||
end
|
||
else if Fflag = 3 then
|
||
begin
|
||
if (price.Text <> '') and (priceGW.Text <> '') then
|
||
begin
|
||
Application.MessageBox('ֻ<><D6BB><EFBFBD><EFBFBD>дһ<D0B4><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
Exit;
|
||
end;
|
||
|
||
if FIOID = '' then
|
||
exit;
|
||
try
|
||
with ADOQuery1 do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
if (price.Text = '') and (priceGW.Text = '') then
|
||
begin
|
||
sql.Add(' update Trade_Cloth_IO set price = ' + price.Text + ' where IOID in (' + FIOID + ')');
|
||
sql.Add(' update Trade_Cloth_IO set Amount = ' + price.Text + ' where IOID in (' + FIOID + ')');
|
||
end
|
||
else if (price.Text <> '') and (priceGW.Text = '') then
|
||
begin
|
||
sql.Add(' update Trade_Cloth_IO set price = ' + price.Text + ' where IOID in (' + FIOID + ')');
|
||
sql.Add(' update Trade_Cloth_IO set Amount = ' + price.Text + ' * meter where IOID in (' + FIOID + ')');
|
||
end
|
||
else if (price.Text = '') and (priceGW.Text <> '') then
|
||
begin
|
||
sql.Add(' update Trade_Cloth_IO set price = ' + priceGW.Text + ' where IOID in (' + FIOID + ')');
|
||
sql.Add(' update Trade_Cloth_IO set Amount = ' + priceGW.Text + ' * NetWeight where IOID in (' + FIOID + ')');
|
||
end;
|
||
|
||
|
||
// ShowMessage(sql.Text);
|
||
ExecSQL;
|
||
end;
|
||
finally
|
||
ModalResult := 1;
|
||
;
|
||
end;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmBatchEdit.FormShow(Sender: TObject);
|
||
begin
|
||
try
|
||
with ADOConnection1 do
|
||
begin
|
||
if not Connected then
|
||
begin
|
||
Connected := false;
|
||
ConnectionString := DConString;
|
||
LoginPrompt := false;
|
||
Connected := true;
|
||
end;
|
||
end;
|
||
except
|
||
application.MessageBox('<27><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><><EFBFBD><EFBFBD>', mb_Ok + MB_ICONERROR);
|
||
end;
|
||
if FFlag = 3 then
|
||
begin
|
||
priceGW.Visible := true;
|
||
cxLabel1.Visible := True;
|
||
cxLabel2.Caption := '<27><><EFBFBD><EFBFBD><EFBFBD>۸<EFBFBD>';
|
||
end;
|
||
end;
|
||
|
||
end.
|
||
|