//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit9.h"
#include "Unit1.h"
#include "Unit11.h"
#include "string.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TModify *Modify;
//---------------------------------------------------------------------------
__fastcall TModify::TModify(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TModify::BitBtn1Click(TObject *Sender)
{
String strSQL;
ModifyQuery->SQL->Clear();
strSQL="select * from 员工信息表 where 员工账号='"+Edit1->Text+"'";
ModifyQuery->SQL->Text=strSQL;
ModifyQuery->ExecSQL();
ModifyQuery->Active=true;
if(ModifyQuery->RecordCount==0)
//ShowMessage("该员工账号不存在!");
Application->MessageBox("该员工账号不存在","提示信息框",MB_ICONASTERISK);
else
{
Edit3->Text=Edit1->Text;
//Edit2->Text=ModifyQuery->Fields->FieldByName("姓名")->AnsiString;
Edit2->Text=ModifyQuery->FieldByName("姓名")->AsString;
ComboBox1->Text=ModifyQuery->FieldByName("性别")->AsString;
Edit4->Text=ModifyQuery->FieldByName("出生日期")->AsString;
ComboBox2->Text=ModifyQuery->FieldByName("所属部门")->AsString;
Edit6->Text=ModifyQuery->FieldByName("职称")->AsString;
Edit7->Text=ModifyQuery->FieldByName("职务")->AsString;
ComboBox3->Text=ModifyQuery->FieldByName("学历情况")->AsString;
Edit9->Text=ModifyQuery->FieldByName("专业")->AsString;
Edit10->Text=ModifyQuery->FieldByName("毕业时间")->AsString;
Edit11->Text=ModifyQuery->FieldByName("毕业学校")->AsString;
ComboBox4->Text=ModifyQuery->FieldByName("外语情况")->AsString;
ComboBox5->Text=ModifyQuery->FieldByName("婚姻状况")->AsString;
}
}
//---------------------------------------------------------------------------
void __fastcall TModify::BitBtn3Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TModify::BitBtn4Click(TObject *Sender)
{
String strSQL,strSQL2;int i=0,j=0;
ModifyQuery->SQL->Clear();
strSQL="select * from 员工账号表 where 员工账号='"+Edit3->Text+"'";
ModifyQuery->SQL->Text=strSQL;
ModifyQuery->ExecSQL();
ModifyQuery->Active=true;
if(ModifyQuery->RecordCount==0)
{
i=1;
ModifyQuery->SQL->Clear();
strSQL2="select * from 管理员账号表 where 管理员账号='"+Edit3->Text+"'";
ModifyQuery->SQL->Text=strSQL2;
ModifyQuery->ExecSQL();
ModifyQuery->Active=true;
if(ModifyQuery->RecordCount==0)
j=1;
if(i==1&&j==1)
//if(Edit3->Text==Edit1->Text)
Application->MessageBox("修改的员工账号可用","提示信息框",MB_ICONASTERISK);
else
{
Application->MessageBox("修改的账号已存在","提示信息框",MB_ICONASTERISK);
return ;
}
}
else
{
// Application->MessageBox("修改的员工账号可用","提示信息框",MB_ICONASTERISK);
if(Edit3->Text==Edit1->Text)
Application->MessageBox("修改的员工账号可用","提示信息框",MB_ICONASTERISK);
else
{
Application->MessageBox("修改的账号已存在","提示信息框",MB_ICONASTERISK);
return ;
}
}
String no;
ModifyQuery->SQL->Clear();
no="UPDATE 员工账号表 SET 员工账号='"+Edit3->Text+"'";
no=no+"where 员工账号='"+Edit1->Text+"'";
ModifyQuery->SQL->Text=no;
ModifyQuery->ExecSQL();
String number;
ModifyQuery->SQL->Clear();
number="UPDATE 员工信息表 SET 员工账号='"+Edit3->Text+"'";
number=number+"where 员工账号='"+Edit1->Text+"'";
ModifyQuery->SQL->Text=number;
ModifyQuery->ExecSQL();
String name;
ModifyQuery->SQL->Clear();
name="UPDATE 员工信息表 SET 姓名='"+Edit2->Text+"'";
name=name+"where 员工账号='"+Edit3->Text+"'";
ModifyQuery->SQL->Text=name;
ModifyQuery->ExecSQL();
String sex;
ModifyQuery->SQL->Clear();
sex="UPDATE 员工信息表 SET 性别='"+ComboBox1->Text+"'";
sex=sex+"where 员工账号='"+Edit3->Text+"'";
ModifyQuery->SQL->Text=sex;
ModifyQuery->ExecSQL();
String birth;
ModifyQuery->SQL->Clear();
birth="UPDATE 员工信息表 SET 出生日期='"+Edit4->Text+"'";
birth=birth+"where 员工账号='"+Edit3->Text+"'";
ModifyQuery->SQL->Text=birth;
ModifyQuery->ExecSQL();
String bumen;
ModifyQuery->SQL->Clear();
bumen="UPDATE 员工信息表 SET 所属部门='"+ComboBox2->Text+"'";
bumen=bumen+"where 员工账号='"+Edit3->Text+"'";
ModifyQuery->SQL->Text=bumen;
ModifyQuery->ExecSQL();
String zhichen;
ModifyQuery->SQL->Clear();
zhichen="UPDATE 员工信息表 SET 职称='"+Edit6->Text+"'";
zhichen=zhichen+"where 员工账号='"+Edit3->Text+"'";
ModifyQuery->SQL->Text=zhichen;
ModifyQuery->ExecSQL();
String zhiwu;
ModifyQuery->SQL->Clear();
zhiwu="UPDATE 员工信息表 SET 职务='"+Edit7->Text+"'";
zhiwu=zhiwu+"where 员工账号='"+Edit3->Text+"'";
ModifyQuery->SQL->Text=zhiwu;
ModifyQuery->ExecSQL();
String xueli;
ModifyQuery->SQL->Clear();
xueli="UPDATE 员工信息表 SET 学历情况='"+ComboBox3->Text+"'";
xueli=xueli+"where 员工账号='"+Edit3->Text+"'";
ModifyQuery->SQL->Text=xueli;
ModifyQuery->ExecSQL();
String zhuanye;
ModifyQuery->SQL->Clear();
zhuanye="UPDATE 员工信息表 SET 专业='"+Edit9->Text+"'";
zhuanye=zhuanye+"where 员工账号='"+Edit3->Text+"'";
ModifyQuery->SQL->Text=zhuanye;
ModifyQuery->ExecSQL();
String biyesj;
ModifyQuery->SQL->Clear();
biyesj="UPDATE 员工信息表 SET 毕业时间='"+Edit10->Text+"'";
biyesj=biyesj+"where 员工账号='"+Edit3->Text+"'";
ModifyQuery->SQL->Text=biyesj;
ModifyQuery->ExecSQL();
String biyexx;
ModifyQuery->SQL->Clear();
biyexx="UPDATE 员工信息表 SET 毕业学校='"+Edit11->Text+"'";
biyexx=biyexx+"where 员工账号='"+Edit3->Text+"'";
ModifyQuery->SQL->Text=biyexx;
ModifyQuery->ExecSQL();
String waiyu;
ModifyQuery->SQL->Clear();
waiyu="UPDATE 员工信息表 SET 外语情况='"+ComboBox4->Text+"'";
waiyu=waiyu+"where 员工账号='"+Edit3->Text+"'";
ModifyQuery->SQL->Text=waiyu;
ModifyQuery->ExecSQL();
String hunyin;
ModifyQuery->SQL->Clear();
hunyin="UPDATE 员工信息表 SET 婚姻状况='"+ComboBox5->Text+"'";
hunyin=hunyin+"where 员工账号='"+Edit3->Text+"'";
ModifyQuery->SQL->Text=hunyin;
ModifyQuery->ExecSQL();
Application->MessageBox("信息修改成功","提示信息框",MB_ICONASTERISK);
}
//---------------------------------------------------------------------------
评论1