【delphi开源代码栏目提醒】:网学会员在delphi开源代码频道为大家收集整理了others.pas提供大家参考,希望对大家有所帮助!
unit others;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
DBTables, Db, ExtCtrls, StdCtrls, Buttons, Printers;
type
Tfrm_other = class(TForm)
pe_edit: TPanel;
Panel4: TPanel;
cmd_new: TBitBtn;
cmd_edit: TBitBtn;
cmd_save: TBitBtn;
cmd_cancel: TBitBtn;
cmd_del: TBitBtn;
Label2: TLabel;
txt_unit: TEdit;
Label3: TLabel;
txt_fk: TEdit;
Label4: TLabel;
combo_fs: TComboBox;
Label5: TLabel;
txt_text: TEdit;
Label6: TLabel;
cmd_print: TBitBtn;
Panel1: TPanel;
Image1: TImage;
qe_other: TQuery;
sp_update_mode_for_others: TStoredProc;
txt_memo: TMemo;
qe_jy: TQuery;
sp_del_from_other: TStoredProc;
sp_insert_into_day: TStoredProc;
sp_insert_into_sj: TStoredProc;
combo_p: TComboBox;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure ControlChange(Sender: TObject);
procedure controlKeyPress1(Sender: TObject; var Key: Char);
procedure controlKeyPress2(Sender: TObject; var Key: Char);
procedure cmd_newClick(Sender: TObject);
procedure cmd_editClick(Sender: TObject);
procedure cmd_cancelClick(Sender: TObject);
procedure cmd_saveClick(Sender: TObject);
procedure cmd_delClick(Sender: TObject);
procedure cmd_printClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
OT_BH: string;
//
procedure EnabledComponent(intState: TDataSetState);
procedure controlSetFocus(intpos: integer);
function RuleCheck: integer;
procedure controlDj(intState: TDataSetState);
procedure NewInit;
procedure EditInit;
procedure CancelInit;
procedure SaveInit;
procedure ExeDelAndInit;
//
function SetNewBH1(intKind: integer): string;
public
{ Public declarations }
end;
var
frm_other: Tfrm_other;
implementation
{$R *.DFM}
uses
log, main, print;
function Tfrm_other.SetNewBH1(intKind: integer): string;
var
intR_m, intR_d: integer;
stryear, strmonth, strday: string;
year1, month1, day1: Word;
strm, strd: string;
strResult: string;
begin
DecodeDate(Now, year1, month1, day1);
stryear := IntToStr(year1);
strmonth := Format('%2.2d', [month1]);
strday := Format('%2.2d', [day1]);
//
qe_jy.Close;
qe_jy.SQL.Clear;
qe_jy.SQL.Add('SELECT * FROM SJ_SUM WHERE SJ_YEAR = ' + IntToStr(year1) + ' AND SJ_MONTH = ' + IntToStr(month1) + ' AND SJ_DAY = ' + IntToStr(day1) + ' AND SJ_KIND = ' + IntToStr(intKind) + ' ');
qe_jy.Open;
qe_jy.Last;
intR_d := qe_jy.RecordCount;
//
qe_jy.Close;
qe_jy.SQL.Clear;
qe_jy.SQL.Add('SELECT * FROM SJ_SUM WHERE SJ_YEAR = ' + IntToStr(year1) + ' AND SJ_MONTH = ' + IntToStr(month1) + ' AND SJ_KIND = ' + IntToStr(intKind) + ' ');
qe_jy.Open;
qe_jy.Last;
intR_m := qe_jy.RecordCount;
qe_jy.Close;
//
if (intR_m = 0) and (intR_d = 0) then begin
strResult := stryear + strmonth + strday + '-' + '001' + '-' + '001';
end else if intR_m = 0 then begin
strResult := stryear + strmonth + strday + '-' + '001' + '-' + '001';
end else if intR_d = 0 then begin
intR_m := intR_m + 1;
strm := Format('%3.3d', [intR_m]);
strResult := stryear + strmonth + strday + '-' + strm + '-' + '001';
end else begin
intR_m := intR_m + 1;
intR_d := intR_d + 1;
strm := Format('%3.3d', [intR_m]);
strd := Format('%3.3d', [intR_d]);
strResult := stryear + strmonth + strday + '-' + strm + '-' + strd;
end;
//
sp_insert_into_sj.ParamByName('@iyear').Value := year1;
sp_insert_into_sj.ParamByName('@imonth').Value := month1;
sp_insert_into_sj.ParamByName('@iday').Value := day1;
sp_insert_into_sj.ParamByName('@ikind').Value := intKind;
sp_insert_into_sj.ExecProc;
//
Result := strResult;
end;
procedure Tfrm_other.ExeDelAndInit;
begin
if MessageBox(Handle, '确实要删除当前记录?', '沈阳信德', MB_ICONQUESTION or MB_OKCANCEL) = ID_OK then begin
sp_del_from_other.ParamByName('@ibh').Value := qe_other.FieldByName('o_bh').AsInteger;
sp_del_from_other.ExecProc;
//
qe_other.Close;
qe_other.Open;
qe_other.First;
//
EnabledComponent(dsBrowse);
//
txt_text.Text := '';
txt_unit.Text := '';
txt_fk.Text := '';
combo_fs.ItemIndex := -1;
txt_memo.Text := '';
end;
end;
procedure Tfrm_other.SaveInit;
var
intResult: integer;
begin
intResult := RuleCheck;
if intResult = 1 then
Exit
else begin
if qe_other.State = dsInsert then begin
controlDj(dsInsert);
qe_other.Post;
qe_other.Close;
qe_other.Open;
qe