毕业论文论文范文课程设计实践报告法律论文英语论文教学论文医学论文农学论文艺术论文行政论文管理论文计算机安全
您现在的位置: 毕业论文 >> 论文 >> 正文

Delphi学生学籍管理系统 第7页

更新时间:2008-7-30:  来源:毕业论文

Delphi学生学籍管理系统 第7页
DataDAHelper数据库单元文件
uses
  SysUtils, Classes, DB, ADODB,Config;
//执行没有返回值的sql语句,如果正确执行则返回true,否则返回false
function ExeSqlNoQuery(sql:string):boolean;
// 执行有返回值的sql语句,返回得到的ADOQuery;
function ExeSqlQuery(sql:string):TADOQuery;
implementation
function ExeSqlQuery(sql:string):TADOQuery;
var
  query:TADOQuery;
begin
  try
  //判断连接状态是否关闭, 若关闭则打开
    if stClosed in Config.ADOCon.State then
      Config.ADOCon.Open;
    query:=TADOQuery.Create(nil);
    query.Connection:=Config.ADOCon;
    query.Close;
    query.SQL.Clear;
    query.SQL.Add(sql);
    query.Open;
  except
    result:=nil;
  end;
  result:=query;
end;
function ExeSqlNoQuery(sql:string):boolean;
var
  query:TADOQuery;
  ref:integer;
begin
  ref:=0;
  //判断连接状态是否关闭, 若关闭则打开
  if stClosed in Config.ADOCon.State then
      Config.ADOCon.Open;
    query:=TADOQuery.Create(nil);
    query.Connection:=Config.ADOCon;
    query.Close;
    Config.ADOCon.BeginTrans;
    try
      query.SQL.Clear;
      query.SQL.Add(sql);
      ref:=query.ExecSQL;//影响的行数
      Config.ADOCon.CommitTrans;
    except
      Config.ADOCon.RollbackTrans;
      query:=nil;
      result:=false;
    end;
  if ref>0 then
    result:=true
  else
    result:=false;
end;frm_changePwdU更改密码界面
public
    currentUser:TOperator;
end;

procedure Tfrm_changePwd.btn_cancelClick(Sender: TObject);
begin
close;
end;

procedure Tfrm_changePwd.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
action:=cafree;
end;

procedure Tfrm_changePwd.btn_okClick(Sender: TObject);
begin
if(self.edt_oldpwd.Text<>currentUser.pwd) then
  begin
    MessageBox(Handle, '原密码不正确!', '信息', MB_ICONEXCLAMATION);
    exit;
  end;
if(self.edt_newpwd.Text <>self.edt_newpwd1.Text) then
  begin
    MessageBox(Handle, '新密码不统一!', '信息', MB_ICONEXCLAMATION);
    exit;
  end;
if(trim(self.edt_newpwd.Text)='') then
  begin
    MessageBox(Handle, '密码不能为空!', '信息', MB_ICONEXCLAMATION);
    exit;
  end;
if Control_OperatorU.ChangePwd(trim(self.edt_newpwd.Text),currentUser.id)then
  begin
    MessageBox(Handle, '修改成功!', '信息', MB_ICONASTERISK);
  end
else
  MessageBox(Handle, '更改失败!', '信息', MB_ICONEXCLAMATION);
end;frm_classU院系管理界面
procedure Tfrm_class.FillData;
begin
  DataSource_info.DataSet:=Control_classU.GetclassesArray;
  self.DBGrid_info.Columns[0].Visible  :=false;
  self.DBGrid_info.Columns[2].Visible  :=false;
  self.FillCbx;
end;
procedure Tfrm_class.FillCbx;
var
  query:TADOQuery;
begin
  query:=TADOQuery.Create(nil);
  query:=Control_classU.GetclassesArray;
  self.cbx_class.Items.Clear;
  cbx_class.Items.Add('本校');
  cbx_class.Tag:=0;
  while not query.Eof do
    begin
      self.cbx_class.Items.Add(query.Fields[1].Value );
      query.Next;
    end;
  cbx_class.ItemIndex:=0;
  query:=nil;
end;
procedure Tfrm_class.btn_addClick(Sender: TObject);
var
  Classes:TClasses;
  fatherID:integer;
begin
  inherited;
     if((edt_Name.Text='')) then
        begin
           MessageBox(Handle, '内容填写不正确!', '信息', MB_ICONEXCLAMATION);
           exit;
        end;
       //查找是否存在重复
      if (GetclassesByName(trim(edt_name.Text)))<>nil then
        begin
          MessageBox(Handle, '该院系已经存在,请重新设置!', '信息', MB_ICONEXCLAMATION);
          exit;
        end;
      classes:=Tclasses.Create;
      classes.id:=edt_name.Tag;
      classes.className:=edt_name.Text;
      classes.fatherID:=self.cbx_class.Tag;

      if(Control_classU.Addclasses(classes)) then
        begin
          MessageBox(Handle, '添加成功!', '信息', MB_ICONASTERISK);
          self.edt_name.Tag:=0;
          self.edt_name.Text:='';
          self.cbx_class.ItemIndex:=0;

          //刷新内容
          FillData;
        end
      else
        begin
          MessageBox(Handle, '添加失败!', '信息', MB_ICONEXCLAMATION);
          exit;
        end;
end;

procedure Tfrm_class.cbx_classChange(Sender: TObject);
var
  Classes:TClasses;
begin
  inherited;
  Classes:=TClasses.Create;
  Classes:=GetclassesByName(self.cbx_class.Text);
  if Classes<>nil then
    self.cbx_class.Tag:=Classes.id;
end;

procedure Tfrm_class.btn_delClick(Sender: TObject);
var
  Classes:TClasses;
begin
  inherited;
  if MessageBox(Handle, '您确定要删除该院系信息', '信息',
     MB_ICONQUESTION or MB_OKCANCEL) = IDOK then
    begin
      Control_ClassU.DelClasses(self.edt_name.Tag);
      FillData;
      if self.DBGrid_info.Fields[0].IsNull then
        exit;
      self.edt_name.Tag:=self.DBGrid_info.Fields[0].Value;//保存id
      self.edt_name.Text :=self.DBGrid_info.Fields[1].Value;
      self.cbx_class.Tag:=self.DBGrid_info.Fields[2].Value;
      self.cbx_class.Text:=self.DBGrid_info.Fields[3].Value;
    end;
end;

procedure Tfrm_class.btn_editClick(Sender: TObject);
var
  Classes:TClasses;
begin
inherited;
  if edt_name.Text ='' then
    begin
       MessageBox(Handle, '没有可以修改的数据!', '信息', MB_ICONEXCLAMATION);
      exit;
    end;
  //查找是否存在重复
  Classes:=TClasses.Create;
  Classes:=GetclassesByName(trim(edt_name.Text));
  if(Classes<>nil) then
    begin
      if(Classes.id<>edt_name.Tag) then
        begin
          MessageBox(Handle, '该院系已经存在,请重新设置!', '信息', MB_ICONEXCLAMATION);
          exit;
        end;
    end;
  Classes:=TClasses.Create;
  Classes.id:=edt_name.Tag;
  Classes.className:=edt_name.Text;
  Classes.fatherID:=self.cbx_class.Tag;
  if(Control_ClassU.EditClasses(Classes)) then
    begin
      MessageBox(Handle, '修改成功!', '信息', MB_ICONASTERISK);
      //刷新内容
      FillData;
    end
  else
     begin
      MessageBox(Handle, '修改失败!', '信息', MB_ICONEXCLAMATION);
      exit;
     end;
  self.edt_name.SetFocus;
end;

procedure Tfrm_class.DBGrid_infoCellClick(Column: TColumn);
begin
  inherited;
self.edt_name.Tag:=self.DBGrid_info.Fields[0].Value;//保存id
self.edt_name.Text :=self.DBGrid_info.Fields[1].Value;
self.cbx_class.Tag:=self.DBGrid_info.Fields[2].Value;
self.cbx_class.Text:=self.DBGrid_info.Fields[3].Value;
end;

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] 下一页

Delphi学生学籍管理系统 第7页下载如图片无法显示或论文不完整,请联系qq752018766
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©751com.cn 辣文论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。