📄 newemployee.cs
字号:
this.sqlUpdateCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_gender", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "gender", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_salary", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "salary", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_staffkind", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "staffkind", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_staffname", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "staffname", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_staffphone", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "staffphone", System.Data.DataRowVersion.Original, null));
//
// sqlDeleteCommand3
//
this.sqlDeleteCommand3.CommandText = @"DELETE FROM Staff WHERE (staffid = @Original_staffid) AND (branch = @Original_branch OR @Original_branch IS NULL AND branch IS NULL) AND (branchid = @Original_branchid OR @Original_branchid IS NULL AND branchid IS NULL) AND (gender = @Original_gender OR @Original_gender IS NULL AND gender IS NULL) AND (salary = @Original_salary OR @Original_salary IS NULL AND salary IS NULL) AND (staffkind = @Original_staffkind OR @Original_staffkind IS NULL AND staffkind IS NULL) AND (staffname = @Original_staffname OR @Original_staffname IS NULL AND staffname IS NULL) AND (staffphone = @Original_staffphone OR @Original_staffphone IS NULL AND staffphone IS NULL)";
this.sqlDeleteCommand3.Connection = this.sqlConnection_Staff;
this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_staffid", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "staffid", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_branch", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "branch", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_branchid", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "branchid", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_gender", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "gender", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_salary", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "salary", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_staffkind", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "staffkind", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_staffname", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "staffname", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_staffphone", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "staffphone", System.Data.DataRowVersion.Original, null));
//
// sqlSelectCommand3
//
this.sqlSelectCommand3.CommandText = "SELECT branchid, ip FROM Branch";
this.sqlSelectCommand3.Connection = this.sqlConnection_Staff;
//
// sqlInsertCommand3
//
this.sqlInsertCommand3.CommandText = "INSERT INTO Branch(branchid, ip) VALUES (@branchid, @ip); SELECT branchid, ip FRO" +
"M Branch WHERE (branchid = @branchid)";
this.sqlInsertCommand3.Connection = this.sqlConnection_Staff;
this.sqlInsertCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@branchid", System.Data.SqlDbType.VarChar, 10, "branchid"));
this.sqlInsertCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ip", System.Data.SqlDbType.VarChar, 10, "ip"));
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = "UPDATE Branch SET branchid = @branchid, ip = @ip WHERE (branchid = @Original_bran" +
"chid) AND (ip = @Original_ip OR @Original_ip IS NULL AND ip IS NULL); SELECT bra" +
"nchid, ip FROM Branch WHERE (branchid = @branchid)";
this.sqlUpdateCommand1.Connection = this.sqlConnection_Staff;
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@branchid", System.Data.SqlDbType.VarChar, 10, "branchid"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ip", System.Data.SqlDbType.VarChar, 10, "ip"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_branchid", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "branchid", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ip", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ip", System.Data.DataRowVersion.Original, null));
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = "DELETE FROM Branch WHERE (branchid = @Original_branchid) AND (ip = @Original_ip O" +
"R @Original_ip IS NULL AND ip IS NULL)";
this.sqlDeleteCommand1.Connection = this.sqlConnection_Staff;
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_branchid", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "branchid", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ip", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ip", System.Data.DataRowVersion.Original, null));
//
// NewEmployee
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(720, 453);
this.Controls.Add(this.bExit);
this.Controls.Add(this.bNew);
this.Controls.Add(this.gbInput);
this.ForeColor = System.Drawing.Color.Magenta;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "NewEmployee";
this.Text = "增添新员工_总部";
this.Load += new System.EventHandler(this.NewEmployee_Load);
this.gbInput.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataSet_Staff)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.Staff)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet_SysUser)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void bExit_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void bNew_Click(object sender, System.EventArgs e)
{
int id;
String name=tbName.Text.ToString().Trim();
String kind=cbKind.Text.ToString().Trim();
String gender=cbGender.Text.ToString().Trim();
String phone=tbPhone.Text.ToString().Trim();
if(kind.Length==0)
{
MessageBox.Show("没有选择职位");
return;
}
//本地:增加Staff表中员工信息
try
{
sqlDataAdapter_Staff.SelectCommand.CommandText=
"select * from Staff ";
sqlDataAdapter_Staff.Fill(dataSet_Staff);
int k=(int)Staff.Rows[Staff.Rows.Count-1]["staffid"];
k++;
id=k;
DataRow newRow=Staff.NewRow();
newRow[0]=id;
newRow[1]=cbBranch.SelectedIndex.ToString();
newRow[2]=id;
newRow[3]=name;
newRow[4]=gender;
newRow[5]=kind;
if(cbKind.SelectedIndex==1)
newRow[6]="4000";
else
newRow[6]="10000";
newRow[7]=phone;
Staff.Rows.Add(newRow);
sqlDataAdapter_Staff.Update(Staff);
//增加SystemUser表中员工信息
sqlDataAdapter_SysUser.SelectCommand.CommandText=
"select * from SystemUser";
sqlDataAdapter_SysUser.Fill(dataSet_SysUser);
DataTable User=dataSet_SysUser.Tables[0];
newRow=User.NewRow();
newRow[0]=id;
newRow[1]="111111";
newRow[2]=kind;
;
User.Rows.Add(newRow);
sqlDataAdapter_SysUser.Update(User);
//
sqlDataAdapter_Branch.SelectCommand.CommandText="select * from Branch where branchid= '"+cbBranch.SelectedIndex+"'";
DataSet dataset_branch=new DataSet();
sqlDataAdapter_Branch.Fill(dataset_branch);
DataRow row=dataset_branch.Tables[0].Rows[0];
string branchid=cbBranch.SelectedIndex.ToString();
string ip=(string)row["ip"];
//远程调用
int m=int.Parse(branchid);
m += 8084;
Change obj = (Change)Activator.GetObject(typeof(Change), "tcp://"+ ip.Trim() +":"+ m.ToString() +"/remotingChange");
if(cbBranch.SelectedIndex==1)
obj.SetSQL("7B1EE60547FB453","branchlww");
else if(cbBranch.SelectedIndex==2)
obj.SetSQL("7B1EE60547FB453","branchyf");
else
{
MessageBox.Show("添加成功!");
return;
}
obj.NewEmpolyee(id,branchid,name,gender,kind,"",phone);
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
MessageBox.Show("添加成功!");
cbKind.SelectedIndex=-1;
tbName.Text="";
cbGender.SelectedIndex=-1;
tbPhone.Text="";
}
private void NewEmployee_Load(object sender, System.EventArgs e)
{
// TcpClientChannel chan = new TcpClientChannel();
// //注册通道
// IDictionary properties = new Hashtable();
// properties["name"] = "centerNewEmployee";
// //properties["name"] = "tcp1";
// properties["port"] = "8001";
// properties["priority"] = "20";
// //MessageBox.Show("tcp"+branch.Trim());
//
// BinaryClientFormatterSinkProvider provider = new BinaryClientFormatterSinkProvider();
//
// TcpClientChannel chan = new TcpClientChannel(properties,provider);
// ChannelServices.RegisterChannel(chan);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -