📄 sy_lmndqljh.pas
字号:
BBt_re.Enabled := (state = dsBrowse);
BBt_snd.Enabled := (RG_JB.ItemIndex = 0) and (state = dsBrowse);
BBt_edt.Enabled := state = dsBrowse;
BBt_sav.Enabled := state <> dsBrowse;
BBt_can.Enabled := state <> dsBrowse;
end;
procedure TFrmY_LMNDQLJH.Qry_qljhUpdateError(DataSet: TDataSet;
E: EDatabaseError; UpdateKind: TUpdateKind;
var UpdateAction: TUpdateAction);
begin
if pos('Key violation', e.Message) <> 0 then
vlp_s_errmsg := '该单位的计划内需求已经存在!请重新选择申请单位!'
else if pos('Field value required', e.Message) <> 0 then
vlp_s_errmsg := '申请单位、制表人不能为空!请重新确定再保存!'
else
vlp_s_errmsg := E.Message; // '数据访问错误!';
end;
procedure TFrmY_LMNDQLJH.BBt_savClick(Sender: TObject);
var
v_JHH, v_tx: string;
begin
if (FDataEditState = dsBrowse) then
exit;
v_JHH := Qry_qljh.FieldByName('JHH').AsString;
v_TX := Qry_qljh.FieldByName('TX').AsString;
Qry_qljh.First;
while not Qry_qljh.Eof do
begin
if Qry_qljh.FieldByName('XQZTS').IsNull then
begin
Qry_qljh.Delete;
continue;
end;
if Qry_qljh.FieldByName('XQZTS').AsInteger = 0 then
begin
Qry_qljh.Delete;
continue;
end;
Qry_qljh.Next;
end;
data.DM.StartTransaction;
try
Qry_qljh.ApplyUpdates;
data.DM.Commit;
except
data.DM.Rollback;
raise exception.Create(vlp_s_errmsg);
end;
Qry_qljh.CommitUpdates;
SetDataEdit(dsBrowse);
DBGE_qljh.SumList.Active := false;
DBGE_qljh.SumList.Active := true;
if v_JHH <> '' then
Qry_qljh.Locate('JHH;TX', varArrayOf([v_JHH, v_TX]), [loCaseInsensitive, loPartialKey]);
end;
procedure TFrmY_LMNDQLJH.BBt_canClick(Sender: TObject);
begin
if (FDataEditState = dsBrowse) then
exit;
data.DM.StartTransaction;
try
Qry_qljh.CancelUpdates;
data.DM.Commit;
except
data.DM.Rollback;
raise exception.Create('数据访问错误!');
end;
Qry_qljh.CommitUpdates;
SetDataEdit(dsBrowse);
DBGE_qljh.SumList.Active := false;
DBGE_qljh.SumList.Active := true;
end;
procedure TFrmY_LMNDQLJH.BBt_sndClick(Sender: TObject);
var
vl_s_jsdwdm: string;
begin
if Qry_qljh.IsEmpty then
exit;
if CHQMsgBox('确实要上报<' + SE_year.Text + '年度>请领计划信息吗?', 2) = IDNo then
exit;
with data.qrytmp do
begin
Close;
SQL.Clear;
SQL.Add('select DWDM from TGS_GXDWSJB where ZJSJ=''1''');
Open;
if not IsEmpty then
vl_s_jsdwdm := Fields[0].AsString
else
begin
CHQMsgBox('请先设置上级单位再发送!');
exit;
end;
end;
data.DM.StartTransaction;
try
with data.qrytmp do
begin
Close;
SQL.Clear;
SQL.Add('insert into TY_JJNXQB_LM_CACO(JHH, TX, SQDWDM, ND, PPMC, XQZTS, ZT, ZBR, PZR, ZDRQ, BZ, SDATE, COMM_DEPT) ' +
'select JHH,TX,SQDWDM,ND,PPMC,XQZTS,''0'',ZBR,PZR,ZDRQ,BZ,sysdate,''' + vl_s_jsdwdm + ''' from TY_JJNXQB_LM ' +
'where XQZTS>0 and ND=''' + Qry_qljh.FieldByName('ND').AsString + ''' and SQDWDM=''' + VG_UnitID + '''');
ExecSQL;
Close;
SQL.Clear;
SQL.Add('update TY_JJNXQB_LM set SDATE = sysdate ' +
'where XQZTS>0 and ND=''' + Qry_qljh.FieldByName('ND').AsString + ''' and SQDWDM=''' + VG_UnitID + '''');
ExecSQL;
end;
data.DM.Commit;
CHQMsgBox('请领计划信息发送成功!');
except
data.DM.RollBack;
raise exception.Create('数据访问错误!');
end;
Qry_qljh.Close;
Qry_qljh.Open;
end;
procedure TFrmY_LMNDQLJH.FormShow(Sender: TObject);
begin
DWMC.Caption := '使用单位:' + VG_UnitName;
Qry_dw.AfterScroll := nil;
Qry_dw.Close;
Qry_dw.Open;
DBLCBo_dw.KeyValue := Qry_dw.FieldByName('DWDM').Value;
Qry_qljh.ParamByName('SQDWDM').AsString := DBLCBo_dw.KeyValue;
Qry_dw.AfterScroll := Qry_dwAfterScroll;
SE_year.value := VG_Year;
SetDataEdit(dsBrowse);
end;
procedure TFrmY_LMNDQLJH.DBGE_qljhDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumnEh;
State: TGridDrawState);
begin
if Qry_qljhXQZTS.AsInteger > 0 then
if (gdSelected in State) and (TDBGridEh(Sender).Focused = True) then
TDBGridEh(Sender).Canvas.Font.Color := clWhite
else
TDBGridEh(Sender).Canvas.Font.Color := clBlack; //$00A56E3A;
TDBGridEh(Sender).DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
procedure TFrmY_LMNDQLJH.DBGE_qljhGetFooterParams(Sender: TObject; DataCol,
Row: Integer; Column: TColumnEh; AFont: TFont; var Background: TColor;
var Alignment: TAlignment; State: TGridDrawState; var Text: string);
begin
try
if (UpperCase(Column.FieldName) = 'XQZTS') then
if Text = '' then
Text := '0'
else
Text := FormatFloat('#,##', StrToFloat(Text))
except
end;
if (UpperCase(Column.FieldName) = 'PPMC') then
Text := '合 计: ' + Text;
end;
procedure TFrmY_LMNDQLJH.BBt_rtnClick(Sender: TObject);
begin
Close;
end;
procedure TFrmY_LMNDQLJH.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
CanCLose := CheckExit;
end;
function TFrmY_LMNDQLJH.CheckExit(): boolean;
begin
result := true;
if (FDataEditState <> dsBrowse) then
case CHQMsgBox('数据已经被更改,是否保存所做修改?', 3) of
IDYes:
begin
BBt_savClick(nil);
Qry_qljh.Close;
close;
end;
IDNo:
begin
BBt_canClick(nil);
Qry_qljh.Close;
close;
end;
IDCancel:
result := false;
end
else
begin
Qry_qljh.Close;
close;
end;
end;
procedure TFrmY_LMNDQLJH.Qry_qljhFilterRecord(DataSet: TDataSet;
var Accept: Boolean);
begin
accept := false;
if (V_S_locPPMC <> '') then
if (pos(V_S_locPPMC, DataSet.fieldbyname('PPMC').asstring) <> 0) then
accept := true;
end;
procedure TFrmY_LMNDQLJH.Edt_ypmcKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key <> 13 then
exit;
if (trim(Edt_ypmc.Text) = '') then
exit;
DBGE_qljh.SelectedIndex := 2;
if (trim(Edt_ypmc.Text) <> V_S_locPPMC) then
begin
V_S_locPPMC := trim(Edt_ypmc.Text);
Qry_qljh.First;
Qry_qljh.Filter := 'JHH<>''''';
Qry_qljh.FindFirst;
end
else
Qry_qljh.FindNext;
end;
procedure TFrmY_LMNDQLJH.Qry_qljhXQZTSSetText(Sender: TField;
const Text: string);
var
TextValue: Integer;
begin
try
TextValue := StrToInt(Text);
if TextValue < 0 then
begin
CHQMsgBox('非法数值!');
abort;
end;
Sender.AsInteger := TextValue;
except
if not (TextValue < 0) then
chqmsgbox('非法数值');
abort;
end;
end;
procedure TFrmY_LMNDQLJH.Qry_qljhBeforeInsert(DataSet: TDataSet);
begin
Abort;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -