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

📄 modifypassword.pas

📁 《Delphi 2005数据库系统开发与应用》源代码
💻 PAS
字号:
unit ModifyPassword;

interface

uses
  System.Drawing, System.Collections, System.ComponentModel,
  System.Windows.Forms, System.Data, Borland.Data.Provider;

type
  FrmModifyPassword = class(System.Windows.Forms.Form)
  {$REGION 'Designer Managed Code'}
  strict private
    /// <summary>
    /// Required designer variable.
    /// </summary>
    Components: System.ComponentModel.Container;
    Label1: System.Windows.Forms.Label;
    Label2: System.Windows.Forms.Label;
    Label3: System.Windows.Forms.Label;
    ErrorProvider1: System.Windows.Forms.ErrorProvider;
    TxtUserName: System.Windows.Forms.TextBox;
    TxtUserPassword: System.Windows.Forms.TextBox;
    TxtNewPassword: System.Windows.Forms.TextBox;
    BtOK: System.Windows.Forms.Button;
    BtCancel: System.Windows.Forms.Button;
    BdpConnection1: Borland.Data.Provider.BdpConnection;
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    procedure InitializeComponent;
    procedure BtCancel_Click(sender: System.Object; e: System.EventArgs);
    procedure BtOK_Click(sender: System.Object; e: System.EventArgs);
  {$ENDREGION}
  strict protected
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    procedure Dispose(Disposing: Boolean); override;
  private
    { Private Declarations }
  public
    constructor Create;
  end;

  [assembly: RuntimeRequiredAttribute(TypeOf(FrmModifyPassword))]

implementation

{$REGION 'Windows Form Designer generated code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure FrmModifyPassword.InitializeComponent;
begin
  Self.Label1 := System.Windows.Forms.Label.Create;
  Self.Label2 := System.Windows.Forms.Label.Create;
  Self.Label3 := System.Windows.Forms.Label.Create;
  Self.ErrorProvider1 := System.Windows.Forms.ErrorProvider.Create;
  Self.TxtUserName := System.Windows.Forms.TextBox.Create;
  Self.TxtUserPassword := System.Windows.Forms.TextBox.Create;
  Self.TxtNewPassword := System.Windows.Forms.TextBox.Create;
  Self.BtOK := System.Windows.Forms.Button.Create;
  Self.BtCancel := System.Windows.Forms.Button.Create;
  Self.BdpConnection1 := Borland.Data.Provider.BdpConnection.Create;
  Self.SuspendLayout;
  // 
  // Label1
  // 
  Self.Label1.Location := System.Drawing.Point.Create(8, 24);
  Self.Label1.Name := 'Label1';
  Self.Label1.Size := System.Drawing.Size.Create(80, 23);
  Self.Label1.TabIndex := 0;
  Self.Label1.Text := '用户名';
  Self.Label1.TextAlign := System.Drawing.ContentAlignment.MiddleCenter;
  // 
  // Label2
  // 
  Self.Label2.Location := System.Drawing.Point.Create(8, 64);
  Self.Label2.Name := 'Label2';
  Self.Label2.Size := System.Drawing.Size.Create(80, 23);
  Self.Label2.TabIndex := 1;
  Self.Label2.Text := '密码 ';
  Self.Label2.TextAlign := System.Drawing.ContentAlignment.MiddleCenter;
  // 
  // Label3
  // 
  Self.Label3.Location := System.Drawing.Point.Create(8, 104);
  Self.Label3.Name := 'Label3';
  Self.Label3.Size := System.Drawing.Size.Create(80, 23);
  Self.Label3.TabIndex := 2;
  Self.Label3.Text := '新密码';
  Self.Label3.TextAlign := System.Drawing.ContentAlignment.MiddleCenter;
  // 
  // ErrorProvider1
  // 
  Self.ErrorProvider1.ContainerControl := Self;
  // 
  // TxtUserName
  // 
  Self.TxtUserName.Location := System.Drawing.Point.Create(88, 24);
  Self.TxtUserName.Name := 'TxtUserName';
  Self.TxtUserName.TabIndex := 3;
  Self.TxtUserName.Text := '';
  // 
  // TxtUserPassword
  // 
  Self.TxtUserPassword.Location := System.Drawing.Point.Create(88, 64);
  Self.TxtUserPassword.Name := 'TxtUserPassword';
  Self.TxtUserPassword.TabIndex := 4;
  Self.TxtUserPassword.Text := '';
  // 
  // TxtNewPassword
  // 
  Self.TxtNewPassword.Location := System.Drawing.Point.Create(88, 104);
  Self.TxtNewPassword.Name := 'TxtNewPassword';
  Self.TxtNewPassword.TabIndex := 5;
  Self.TxtNewPassword.Text := '';
  // 
  // BtOK
  // 
  Self.BtOK.Location := System.Drawing.Point.Create(24, 144);
  Self.BtOK.Name := 'BtOK';
  Self.BtOK.TabIndex := 6;
  Self.BtOK.Text := '确定';
  Include(Self.BtOK.Click, Self.BtOK_Click);
  // 
  // BtCancel
  // 
  Self.BtCancel.Location := System.Drawing.Point.Create(120, 144);
  Self.BtCancel.Name := 'BtCancel';
  Self.BtCancel.TabIndex := 7;
  Self.BtCancel.Text := '取消';
  Include(Self.BtCancel.Click, Self.BtCancel_Click);
  // 
  // BdpConnection1
  // 
  Self.BdpConnection1.ConnectionOptions := 'transaction isolation=ReadCommitted;blob size=1024';
  Self.BdpConnection1.ConnectionString := 'assembly=Borland.Data.Mssql,Version=1.5.0.0,Culture=neutral,PublicKeyToken=91d6'+ 
  '2ebb5b0d1b1b;vendorclient=sqloledb.dll;database=教务信息管理系统;username=sa;hostname='+ 
  'storm;password=sa;provider=MSSQL';
  // 
  // FrmModifyPassword
  // 
  Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 14);
  Self.ClientSize := System.Drawing.Size.Create(224, 182);
  Self.Controls.Add(Self.BtCancel);
  Self.Controls.Add(Self.BtOK);
  Self.Controls.Add(Self.TxtNewPassword);
  Self.Controls.Add(Self.TxtUserPassword);
  Self.Controls.Add(Self.TxtUserName);
  Self.Controls.Add(Self.Label3);
  Self.Controls.Add(Self.Label2);
  Self.Controls.Add(Self.Label1);
  Self.Name := 'FrmModifyPassword';
  Self.Text := '修改密码';
  Self.ResumeLayout(False);
end;
{$ENDREGION}

procedure FrmModifyPassword.Dispose(Disposing: Boolean);
begin
  if Disposing then
  begin
    if Components <> nil then
      Components.Dispose();
  end;
  inherited Dispose(Disposing);
end;

constructor FrmModifyPassword.Create;
begin
  inherited Create;
  //
  // Required for Windows Form Designer support
  //
  InitializeComponent;
  //
  // TODO: Add any constructor code after InitializeComponent call
  //
end;

procedure FrmModifyPassword.BtOK_Click(sender: System.Object; e: System.EventArgs);
var
  cda:BdpDataAdapter;
  slc:string;
  newDataRow:DataRow;
  cmdb:BdpCommandBuilder;
  ds:DataSet;
  myDataRow:DataRow;
begin
  slc:='Select * From user_Info Where user_ID='+''''+TxtUserName.Text+'''';    //构造查询
  cda:=BdpDataAdapter.Create(slc,bdpConnection1);
  ds:=DataSet.Create;
  cda.Fill(ds,'user_Info');
  myDataRow:=ds.Tables[0].Rows[0];
if TxtUserPassword.Text=myDataRow[1].ToString then
begin
  myDataRow[1]:=TxtNewPassword.Text;
  ds.Tables[0].GetChanges;
  cmdb:=BdpCommandBuilder.Create(cda);
  bdpConnection1.Open ;
  cda.Update(ds,'user_Info');
  bdpConnection1.Close ;
  MessageBox.Show('修改成功');
  self.Hide;
end
else
MessageBox.Show('密码不正确');
end;

procedure FrmModifyPassword.BtCancel_Click(sender: System.Object; e: System.EventArgs);
begin
  self.Close;
end;

end.

⌨️ 快捷键说明

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