⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit_setupfeast.pas

📁 delphi开发的中国移动大客户管理系统,后台数据库为oracle
💻 PAS
字号:
unit Unit_SetupFeast;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Unit_Config, DBTables, Db, StdCtrls, TFlatEditUnit, TFlatButtonUnit,
  ExtCtrls, Grids, DBGrids, ComCtrls, crypt, Procedurep,
  TFlatRadioButtonUnit, TFlatSpinEditUnit, TFlatComboBoxUnit;

type
  TFrm_SetupFeast = class(TFrm_Config)
    Label1: TLabel;
    FlatRadioButton_Date: TFlatRadioButton;
    FlatRadioButton_ODate: TFlatRadioButton;
    Label2: TLabel;
    Label4: TLabel;
    FlatComboBox_Month: TFlatComboBox;
    FlatComboBox_Day: TFlatComboBox;
    Label5: TLabel;
    Label6: TLabel;
    UpdateSQL1: TUpdateSQL;
    procedure BitBtnAddClick(Sender: TObject);
    procedure BitBtnAlterClick(Sender: TObject);
    procedure BitBtnSaveClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Query_PUBAfterScroll(DataSet: TDataSet);
    procedure BitBtnDelClick(Sender: TObject);
    procedure BitBtnCancelClick(Sender: TObject);
    procedure FlatRadioButton_ODateClick(Sender: TObject);
    procedure FlatRadioButton_DateClick(Sender: TObject);
  private
    { Private declarations }
    //当前的节日编码
    P_CurrentCode :string;
    //判断是否为插入状态
    P_Insert :boolean;
    //设置编辑框的灰和不灰Lflag为true,可编辑
    procedure ProcSetPanel(Lflag:boolean);
  public
    { Public declarations }
  end;

var
  Frm_SetupFeast: TFrm_SetupFeast;

implementation
uses main,dmmain,unit_public;

 //按钮控制
  function Fun_ButtonStatus(pFormName:TForm;pStatus:Boolean=False):Boolean;stdcall;export;external'winfun.dll';
  //输框状态控制
  //Function Fun_ComponentStatus(pFormName:TForm;pStatusStyle:Integer=0;pStatus:Boolean=False):Integer;stdCall;external'winfun.dll';
    Function Fun_ComponentStatus(pFormName:TForm;pStatusStyle:Integer=0;pStatus:Boolean=False;pObject:TObject=Nil):Integer;stdCall;external'winfun.dll';


{$R *.DFM}


procedure TFrm_SetupFeast.BitBtnAddClick(Sender: TObject);
begin
  inherited;
  kk:=1;
  Fun_ButtonStatus(Self,True);
  FlatRadioButton_Date.Checked :=true;
  FlatComboBox_Month.ItemIndex :=0;
  FlatComboBox_Day.ItemIndex :=0;
  FlatEdit1.Text :='';
  ProcSetPanel(true);
  Fun_ComponentStatus(self,0,True);  //--可输入-- 使输入框有效,用户可以输入数值
  DBGrid_PUB.Enabled:=False;

end;

procedure TFrm_SetupFeast.BitBtnAlterClick(Sender: TObject);
begin
  inherited;
  kk:=2;
  Fun_ButtonStatus(Self,True);
  ProcSetPanel(true);
  Fun_ComponentStatus(self,0,True);  //--可输入-- 使输入框有效,用户可以输入数值
  DBGrid_PUB.Enabled:=False;
end;

procedure TFrm_SetupFeast.BitBtnSaveClick(Sender: TObject);
var
   ODate,NDate:String;
   DateStyle:String;
   MyDate: TDateTime;
   LYear,Lstr :string;
   SQL:String;

begin
  inherited;
  //***********验证时间是否正确*******************
  //得到后台数据库系统时间
  Query_Tmp.close;
  Query_Tmp.sql.text :='select sysdate from dual';
  Query_Tmp.open;
  LYear :=copy(Query_Tmp.fields[0].asstring,1,4);
  try
    MyDate := EncodeDate(strtoint(LYear),strtoint(FlatComboBox_Month.text),
                      strtoint(FlatComboBox_Day.text));
  except
    MessageDlg('输入时间有误',mtConfirmation, [mbYes], 0);
    exit;
  end;
  if trim(FlatEdit1.Text) ='' then
  begin
    MessageDlg('节日内容字段不能为空!',mtConfirmation, [mbYes], 0);
    exit;
  end;

  if length(FlatEdit1.Text) >30 then
  begin
    MessageDlg('节日内容字段超过长度!',mtConfirmation, [mbYes], 0);
    exit;
  end;
  //提示是否更新
  if kk=2 then
  if MessageDlg('是否要更新该记录?',mtConfirmation, [mbYes,mbNo], 0)=mrNo then  exit;
  //if (Application.MessageBox('是否要更新该记录?',
  //                       '提示',MB_OKCANCEL)=IDCANCEL)  then exit;
  //**********************************************

  If FlatRadioButton_Date.Checked Then
     Begin
        ODate:='';
        NDate:=FlatComboBox_Month.Text+FlatComboBox_Day.Text;
        DateStyle:='0';
     End
  Else
     Begin
        NDate:='';
        ODate:=FlatComboBox_Month.Text+FlatComboBox_Day.Text;
        DateStyle:='1';
     End;
  //

  case kk of
  1:  // add
     Begin
         SQL :='Insert Into T_D_HoliDay Values(Seq_HoliDay_Code.Nextval,'''
          +Trim(FlatEdit1.Text)+''','''+NDate+''','''+ODate+''','+DateStyle+')';
          if AnalyzeSql(SQL)=1 then exit;
     end;
  2:  // edit
     begin
         Sql :='Update T_D_HoliDay Set HOLIDAY_CONTENT='''
         +Trim(FlatEdit1.Text)+''',HOLIDAY_DATE='''+NDate+''',HOLIDAY_ODATE='''
         +ODate+''',HOLIDAY_FLAG='+DateStyle+' Where HOLIDAY_CODE='+Query_PUB.FieldByName('HOLIDAY_CODE').AsString;
         if AnalyzeSql(SQL)=1 then exit;
     end;
  end;
  //Query_Pub.Close;
  //Query_Pub.Open;SERVER NAME=doone03
  //*************数据同步********************
  case kk of
  1:  // add
     Begin
       P_Insert :=true;
       Query_Pub.insert;
       Query_Tmp.close;
       Query_Tmp.sql.text :='select nvl(max(HOLIDAY_CODE),0) from T_D_HoliDay';
       Query_Tmp.open;
       P_CurrentCode :=Query_Tmp.fields[0].asstring;
     end;
  2:  // edit
     begin
       P_Insert :=true;
       Query_Pub.Edit;
     end;
  end;
  if FlatRadioButton_Date.Checked then
  begin
    Query_Pub.FieldByName('HOLIDAY').asstring :='新历';
    Query_PUB.fieldbyname('HOLIDAY_FLAG').AsString :='0';
  end;
  if FlatRadioButton_ODate.Checked then
  begin
    Query_Pub.FieldByName('HOLIDAY').asstring :='农历';
    Query_PUB.fieldbyname('HOLIDAY_FLAG').AsString :='1';
  end;
  Lstr :=FlatEdit1.text;
  Query_Pub.FieldByName('HOLIDAY_CONTENT').asstring :=Lstr;
  if NDate<>'' then
  begin
    Lstr :=copy(NDate,1,2)+'月'+copy(NDate,3,2)+'日';
    Query_Pub.FieldByName('NDAY').asstring :=Lstr;
    Query_Pub.FieldByName('HOLIDAY_DATE').asstring :=NDate;
  end
  else
  Query_Pub.FieldByName('NDAY').asstring :='';
  if ODate<>'' then
  begin
    Lstr :=copy(ODate,1,2)+'月'+copy(ODate,3,2)+'日';
    Query_Pub.FieldByName('ODAY').asstring :=Lstr;
    Query_Pub.FieldByName('HOLIDAY_ODATE').asstring :=ODate;

  end
    else
    Query_Pub.FieldByName('ODAY').asstring :='';
  Query_PUB.FieldByName('HOLIDAY_CODE').AsString :=P_CurrentCode;
  P_Insert :=false;
  Query_Pub.Post;
  //*****************************************
  Fun_ButtonStatus(Self,False);
  Fun_ComponentStatus(self,0,False);  //--可输入-- 使输入框有效,用户可以输入数值
  Query_PUB.AfterScroll(nil);
  DBGrid_PUB.Enabled:=True;
end;

procedure TFrm_SetupFeast.FormShow(Sender: TObject);
begin
  inherited;
  crypt.UserEnter_Log(Caption, '浏览', -1, Gh, '登入窗体');

  P_Insert :=false;

  Fun_ButtonStatus(Self,False);
  Fun_ComponentStatus(self,0,False);  //--可输入-- 使输入框有效,用户可以输入数值


  //Query_PUB.AfterScroll(nil);
  //修改部分       2001-07-10         ChenQingBo
  BitBtnAdd.Enabled:=(JBDM<=2);
  BitBtnAlter.Enabled:=(JBDM<=2);
  BitBtnDel.Enabled:=(JBDM<=2);
  Query_PUBAfterScroll(nil);
//  FlatEdit1.Enabled:=(JBDM<=2);
  //设置编辑框的状态
  ProcSetPanel(false);
end;

procedure TFrm_SetupFeast.Query_PUBAfterScroll(DataSet: TDataSet);
Var
  Holiday :String;
begin
  inherited;
  if P_Insert then exit;
  If  not(Query_PuB.bof and Query_PuB.eof) Then
   Begin
    If Query_PUB.fieldbyname('HOLIDAY_FLAG').AsString='0' Then
      Begin
       FlatRadioButton_Date.Checked:=True;
       Holiday:=Query_PUB.fieldbyname('HOLIDAY_DATE').AsString;
      End
    Else
      Begin
       FlatRadioButton_ODate.Checked:=True;
       Holiday:=Query_PUB.fieldbyname('HOLIDAY_ODATE').AsString;
      End;

    FlatCombobox_Month.ItemIndex:=FlatCombobox_Month.Items.IndexOf(Copy(Holiday,1,2));
    FlatCombobox_Day.ItemIndex:=FlatCombobox_Day.Items.IndexOf(Copy(Holiday,3,2));
    FlatEdit1.Text := Query_PUB.fieldbyname('HOLIDAY_CONTENT').AsString;
    P_CurrentCode := Query_PUB.fieldbyname('HOLIDAY_CODE').AsString;
   End;
   //***********当没有记录时要控制按钮及权限************
  If  not(Query_PuB.bof and Query_PuB.eof) Then
  begin
    //
    BitBtnAdd.Enabled:=true;
    BitBtnAlter.Enabled:=true;
    BitBtnDel.Enabled:=true;
    //权限
    BitBtnAdd.Enabled:=(JBDM<=2);
    BitBtnAlter.Enabled:=(JBDM<=2);
    BitBtnDel.Enabled:=(JBDM<=2);
  end
    else
      begin
        //BitBtnAdd.Enabled:=false;
        BitBtnAlter.Enabled:=false;
        BitBtnDel.Enabled:=false;
      end;
   //*******************************************
   ProcSetPanel(false);
end;

procedure TFrm_SetupFeast.BitBtnDelClick(Sender: TObject);
var
  sql :string;
begin
  inherited;
  if MessageDlg('是否要删除该记录?',mtConfirmation, [mbYes,mbNo], 0)=mrNo then  exit;
  //if (Application.MessageBox('是否要删除该记录?',
  //                       '提示',MB_OKCANCEL)=IDCANCEL)  then exit;

  Sql:='Delete T_D_HOLIDAY where HOLIDAY_CODE='+#39+
  Query_PUB.FieldByName('HOLIDAY_CODE').AsString+#39;

  if AnalyzeSql(SQL)=1 then exit;
  FlatEdit1.text :='';
  Query_Pub.Delete;
  //Query_Pub.Close;
  //Query_Pub.Open;
  Query_PUB.AfterScroll(nil);
end;

procedure TFrm_SetupFeast.BitBtnCancelClick(Sender: TObject);
begin
  inherited;
  Fun_ButtonStatus(Self,False);
  Fun_ComponentStatus(self,0,False);  //--可输入-- 使输入框有效,用户可以输入数值
  DBGrid_PUB.Enabled:=True;
  Query_PUB.AfterScroll(nil);
end;

procedure TFrm_SetupFeast.FlatRadioButton_ODateClick(Sender: TObject);
begin
  Label1.Caption:='农历日期';
end;

procedure TFrm_SetupFeast.FlatRadioButton_DateClick(Sender: TObject);
begin
  Label1.Caption:='新历日期';
end;

procedure TFrm_SetupFeast.ProcSetPanel(Lflag: boolean);
var
  li:integer;
begin
  for li:=1 to Frm_SetupFeast.ComponentCount -1  do
  begin
    if Frm_SetupFeast.Components[li]  is TFlatComboBox then
    TFlatComboBox(Frm_SetupFeast.Components[li]).enabled :=Lflag;

    if Frm_SetupFeast.Components[li]  is TFlatRadioButton then
    TFlatRadioButton(Frm_SetupFeast.Components[li]).enabled :=Lflag;

    if Frm_SetupFeast.Components[li]  is TFlatEdit then
    TFlatEdit(Frm_SetupFeast.Components[li]).enabled :=Lflag;
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -