如何在C#中添加用户信息修改
添加用户,其它的类似
unit Sadd;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ImgList, Mask, DBCtrls, Grids, DBGrids, DB, ADODB, Buttons;
type
TaddS = class(TForm)
Bevel1: TBevel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
ComboBox1: TComboBox;
ComboBox3: TComboBox;
ComboBox4: TComboBox;
ComboBox5: TComboBox;
ComboBox6: TComboBox;
ImageList1: TImageList;
UListview: TListView;
Label10: TLabel;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
RadioButton1: TRadioButton;
Edit5: TEdit;
procedure Edit4Enter(Sender: TObject);
procedure UListviewSelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
procedure Edit2Exit(Sender: TObject);
procedure Edit1Exit(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
public
end;
var
addS: TaddS;
implementation
uses sum;
procedure TaddS.Edit4Enter(Sender: TObject);
var
i:integer;
begin
Ulistview.Show;
if ulistview.Items.Count = 0 then
begin
for i := 0 to 29 do
begin
Ulistview.Items.Add;
Ulistview.Items[i].ImageIndex:=i;
end;
end;
end;
procedure TaddS.UListviewSelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
begin
Ulistview.Hide;
if Ulistview.Selected <> nil then
edit4.Text:=inttostr(Ulistview.ItemIndex);
edit4.Refresh;
end;
procedure TaddS.Edit2Exit(Sender: TObject);
begin
if (sysuserm.adoquery1.Locate('用户姓名',trim(edit2.Text),[locaseinsensitive])) then
begin
showmessage('该用户名已经存在,不能添加!');
edit2.Clear;
edit2.SetFocus;
exit;
end;
end;
procedure TaddS.Edit1Exit(Sender: TObject);
begin
if sysuserm.adoquery1.Locate('用户编号',trim(edit1.Text),[locaseinsensitive]) then
begin
showmessage('该用户已经存在,不能添加!');
edit1.Clear;
edit1.SetFocus;
exit;
end;
end;
procedure TaddS.Button1Click(Sender: TObject);
begin
if (trim(edit1.Text)<>'')and (trim(edit2.Text)<>'') and (trim(edit3.Text)<>'')and
(trim(edit4.Text)<>'')and (trim(edit5.Text)<>'')and(trim(combobox1.Text)<>'')and
(trim(combobox4.Text)<>'')and(trim(combobox3.Text)<>'')and(trim(combobox5.Text)<>'')
and(trim(combobox6.Text)<>'') then
begin
with sysuserm do
begin
ADOQuery1.Append;
uid.Text:=edit1.Text;
uname.Text:= edit2.text;
pwd.Text := edit3.text;
kind.Text:=combobox1.Text;
dpt.Text:= edit5.Text;
dbedit1.Text:=combobox3.Text;
dbedit2.Text:=combobox4.Text;
dbedit3.Text:=combobox5.Text;
dbedit4.Text:=combobox6.Text;
uico.Text:=edit4.Text;
end;
sysuserm.adoquery1.Edit;
sysuserm.adoquery1.Post;
showmessage('保存成功!');
end
else
begin
application.MessageBox('请把内容填完整!','提示',mb_ok);
exit;
end;
if radiobutton1.Checked then
begin
edit1.Clear;
edit2.Clear;
edit3.Clear;
edit4.Clear;
edit5.Clear;
combobox1.text:='';
combobox3.Text:='';
combobox4.Text:='';
combobox5.Text:='';
combobox6.Text:='';
end
else
adds.Close;
end;
procedure TaddS.Button2Click(Sender: TObject);
begin
edit1.Clear;
edit2.Clear;
edit3.Clear;
edit4.Clear;
edit5.Clear;
combobox1.text:='';
combobox3.Text:='';
combobox4.Text:='';
combobox5.Text:='';
combobox6.Text:='';
end;
procedure TaddS.FormCreate(Sender: TObject);
begin
Ulistview.Hide;
end;
end.