//public void BindAcceptMessage2() //{ // sqlHelper helper = new sqlHelper(); // StringBuilder sSql = new StringBuilder(); // //ssql.Append("select MessageId,DeptName,positionName,EpName,MessageContent,SendTime,"); // //ssql.Append(" case IsRead when 0 then '未读' when 1 then '已读' end as IsRead"); // //ssql.Append(" from(select EpId,EpName,DeptName,positionName,em.DptId as Dept,em.PId as PId "); // //ssql.Append(" from Emploryee em,Depart de,Position po "); // //ssql.Append(" where em.DptId=de.DeptId and em.PId=po.pId) newEm,Message me"); // //ssql.Append(" where newEm.EpId=me.SendEmploryId "); // sSql.AppendFormat(" where AceptEmploryId= {0}", Common.EpId); // if (cmbDept.SelectedValue != null) // { // if ((int)cmbDept.SelectedValue != -1 && (int)cmbDept.SelectedValue != 0) // { // sSql.Append(" and DeptId= "); // sSql.Append(cmbDept.SelectedValue.ToString().Trim()); // try // { // if ((int)helper.ExecuteNonQuery(helper.connectionStr, sSql.ToString()) <= 0) // { // MessageBox.Show("没有您要查询的消息!"); return; // } // } // catch (Exception ex) // { // MessageBox.Show(ex.Message); // } // } // } // if (cmbPosition.SelectedValue != null) // { // if ((int)cmbPosition.SelectedValue != -1 && (int)cmbPosition.SelectedValue != 0) // { // sSql.AppendFormat(" and em.PId={0} ", cmbPosition.SelectedValue.ToString().Trim()); // } // } // if (txtSendName.Text.Trim() != string.Empty) // { // sSql.AppendFormat(" and EpName like '%{0}%' ", txtSendName.Text.ToString().Trim()); // } // sSql.Append(" order by SendTime desc "); // try // { // DataSet ds = helper.ExecuteDataSet(helper.connectionStr, sSql.ToString(), "AMessage"); // dgvMessage.AutoGenerateColumns = false; // dgvMessage.DataSource = ds.Tables["AMessage"]; // } // catch (Exception ex) // { // MessageBox.Show("电脑已经疯了,请稍后再试!"+"\t"+ex.Message, Common.APTION); // } //} #endregion #region 方法:删除消息 private void DeleteMessage() { StringBuilder sSql = new StringBuilder(); sSql.Append("delete Message where "); sSql.Append(" MessageId in("); foreach (DataGridViewRow row in dgvMessage.SelectedRows) { if (row.Cells[0].Value != null) { sSql.Append(Convert.ToInt32(row.Cells[0].Value)); sSql.Append(","); } } sSql.Remove(sSql.Length - 1, 1); sSql.Append(")"); //sSql.Append(" MessageId =");//删除一条消息 //if (this.dgvMessage.SelectedRows.Count > 0) //{ // sSql.Append(Convert.ToInt32(this.dgvMessage.SelectedRows[0].Cells[0].Value)); //} sqlHelper helper = new sqlHelper(); int number = helper.ExecuteNonQuery(helper.connectionStr, sSql.ToString()); if (number > 0) { MessageBox.Show("成 功 删 除 " + number + " 条 消 息!", Common.APTION); } else { MessageBox.Show("删除失败!"); } }
public void BindEmploryeeinfo() { StringBuilder sb = new StringBuilder(); sb.Append("select EpId,EpName,case gender when '1' then '男' when '0' then '女' end gender,officePhone,MobilePhone,de.DeptName,po.positionName "); sb.Append(" from Emploryee em ,Depart de,Position po "); sb.Append("where em.DptId=de.DeptId and em.PId=po.pId "); if (txtEmploryeeName.Text.Trim() != string.Empty) { sb.AppendFormat(" and EpName like '%{0}%' ", txtEmploryeeName.Text.Trim()); } if (rbtBoy.Checked) { sb.Append(" and [gender]='1' "); } if (rbtGirl.Checked) { sb.Append(" and [gender]='0' "); } if (Convert.ToInt32(cmbDepart.SelectedValue) != 0 && Convert.ToInt32(cmbDepart.SelectedValue) != -1) { sb.AppendFormat(" and em.DptId={0}", (int)cmbDepart.SelectedValue); // } if (Convert.ToInt32(cmbPosition.SelectedValue) != -1 && Convert.ToInt32(cmbPosition.SelectedValue) != 0) { sb.AppendFormat(" and em.PId={0}", (int)cmbPosition.SelectedValue); } sb.Append(" and flag= 0 "); sqlHelper helper = new sqlHelper(); dsStu = helper.ExecuteDataSet(helper.connectionStr, sb.ToString(), null); dgvEmploryeeInfo.AutoGenerateColumns = false; dgvEmploryeeInfo.DataSource = dsStu.Tables[0]; }
private void EditDepart() { StringBuilder sSql = new StringBuilder(); sSql.AppendFormat("update Depart set DeptName= '{0}', ", txtDeptName.Text.Trim()); sSql.AppendFormat(" parentId={0} ", (int)cmbDepartFather.SelectedValue); sSql.AppendFormat(" where DeptId={0}", Convert.ToInt32(txtDepartId.Text.Trim())); sqlHelper helper = new sqlHelper(); try { if (helper.ExecuteNonQuery(helper.connectionStr, sSql.ToString()) > 0) { MessageBox.Show("修改成功!", Common.APTION); fdm.QueryDepart(); this.Close(); } else { MessageBox.Show("修改失败!", Common.APTION); } } catch (Exception) { MessageBox.Show("系统维护,请稍后再试!", Common.APTION); } }
private void btnSave_Click(object sender, EventArgs e) { if (CheckInput_EditPwd()) { StringBuilder sSql = new StringBuilder(); sSql.Append("update Users set "); sSql.AppendFormat("LoginPwd='{0}' ", txtNewPwd.Text.Trim()); sSql.AppendFormat("where LoginId='{0}' and LoginPwd='{1}'", Common.UserName, txtOldPwd.Text.Trim()); sqlHelper helper = new sqlHelper(); try { if (helper.ExecuteNonQuery(helper.connectionStr, sSql.ToString()) > 0) { MessageBox.Show("密码修改成功!"); Common.UserPwd = txtNewPwd.Text.Trim(); } else { MessageBox.Show("密码修改失败!"); } } catch (Exception) { MessageBox.Show("系统维护,请稍后再试!", Common.APTION); } } }
protected void showEmploryee() { StringBuilder sSql = new StringBuilder(); sSql.Append(" select * from Emploryee "); sSql.AppendFormat("where EpId={0}", EmpId); sqlHelper helper = new sqlHelper(); SqlDataReader dr = helper.ExecuteRead(helper.connectionStr, sSql.ToString()); if (dr.Read()) { txtEmploryeeName.Text = dr["EpName"].ToString().Trim(); switch (dr["gender"].ToString().Trim()) { case "1": this.rbtBoy.Checked = true; break; case "0": this.rbtGirl.Checked = true; break; } txtCellPhoneNum.Text = dr["MobilePhone"].ToString().Trim(); txtTelephoneNum.Text = dr["officePhone"].ToString().Trim(); txtAddress.Text = dr["Address"].ToString().Trim(); cmbDepart.SelectedValue = (int)dr["DptId"]; cmbPosition.SelectedValue = (int)dr["PId"]; } dr.Close(); }
public static void BindPosition(ComboBox cmbPos, int DeptId) { string sSql = "select pId,positionName from Position "; if (DeptId != 0) { sSql = sSql + " where DeptId=" + DeptId; } sqlHelper helper = new sqlHelper(); DataSet ds = helper.ExecuteDataSet(sSql, helper.connectionStr, "position"); if (DeptId == 0) { DataRow row = ds.Tables["position"].NewRow(); row[0] = 0; row[1] = "所有职位"; ds.Tables["position"].Rows.InsertAt(row, 0); } DataRow row1 = ds.Tables["position"].NewRow(); row1[0] = -1; row1[1] = "请选择"; ds.Tables["position"].Rows.InsertAt(row1, 0); cmbPos.DisplayMember = "positionName"; cmbPos.ValueMember = "pId"; cmbPos.DataSource = ds.Tables["position"]; }
private void AddDepart() { StringBuilder sSql = new StringBuilder(); sSql.Append("insert into Depart (DeptName,parentId) "); sSql.AppendFormat("values ('{0}',{1})", txtDeptName.Text.Trim(), cmbDepartFather.SelectedValue.ToString().Trim()); sqlHelper helper = new sqlHelper(); try { if (helper.ExecuteNonQuery(helper.connectionStr, sSql.ToString()) > 0) { MessageBox.Show("添加成功!", Common.APTION); fdm.QueryDepart(); this.Close(); } else { MessageBox.Show("添加失败!", Common.APTION); } } catch (Exception) { MessageBox.Show("系统维护,请稍后再试!", Common.APTION); } }
private void btnSend_Click(object sender, EventArgs e) { sqlHelper helper = new sqlHelper(); string[] Ids = EpIds.Split(','); StringBuilder faulsSend = new StringBuilder(); foreach (string Id in Ids) { int res = 0; StringBuilder sSql = new StringBuilder(); sSql.Append("Insert into Message (MessageContent,SendEmploryId,AceptEmploryId,IsRead)"); sSql.AppendFormat(" values ('{0}'", txtContent.Text.Trim()); sSql.AppendFormat(",{0},{1},0)", Common.EpId, Id); res = helper.ExecuteNonQuery(helper.connectionStr, sSql.ToString()); if (res < 1) { faulsSend.Append(Id); faulsSend.Append(","); } } if (faulsSend.Length == 0) { MessageBox.Show(" 全 部 发 送 成 功 !", "提示"); //new FrmReceiveMessage().BindAcceptMessage(); this.Close(); } else { faulsSend.Remove(faulsSend.Length - 1, 1); MessageBox.Show("以下员工发送失败:" + faulsSend); } }
private void btnLogin_Click(object sender, EventArgs e) { if (CheckInput()) { StringBuilder sSql = new StringBuilder(); sSql.AppendFormat("select LoginPwd from Users where LoginPwd='{0}'", txtUserPwd.Text.ToString().Trim()); sSql.AppendFormat(" and LoginId='{0}'", Common.UserName); sqlHelper helper = new sqlHelper(); SqlDataReader dr = helper.ExecuteRead(helper.connectionStr, sSql.ToString()); if (dr.Read()) { if (dr["LoginPwd"].ToString().Trim() == txtUserPwd.Text.ToString().Trim()) { this.Dispose(); } } else { MessageBox.Show("密码不正确!请重新输入!", Common.APTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); PwdErrorCount++; } if (PwdErrorCount >= 3) { MessageBox.Show("您已连续3次输入密码错误,系统已被完全锁定,请两分钟之后再次重试!"); linkLabel2.Text = "密码输入3次错误,请两分钟之后重试!"; timer1.Enabled = true; //开启计时器 btnLogin.Enabled = false; //禁用解锁按钮 } } }
private void FrmShowMessage_FormClosed(object sender, FormClosedEventArgs e) { string sSql = "update Message set IsRead =1 where MessageId=" + currentRow.Cells["MessageId"].Value.ToString().Trim(); sqlHelper helper = new sqlHelper(); helper.ExecuteNonQuery(helper.connectionStr, sSql); //更新状态 frmmessage.BindAcceptMessage(); //加载刷新 }
private void btnDelete_Click(object sender, EventArgs e) { DialogResult delResult = MessageBox.Show("您确定要删除吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (delResult == DialogResult.Yes) { StringBuilder delSb = new StringBuilder(); foreach (DataGridViewRow row in dgvDepart.SelectedRows) { if (row.Cells["deptId"].Value != null) { delSb.Append(row.Cells["deptId"].Value.ToString().Trim()); delSb.Append(","); } } if (delSb.Length == 0) { MessageBox.Show("您还没有选择删除项"); return; } delSb.Remove(delSb.Length - 1, 1); StringBuilder ExitPoxSb = new StringBuilder(); ExitPoxSb.Append(" select dept.DeptName from Position pos inner join Depart dept on pos.DeptId=dept.DeptId"); ExitPoxSb.Append(" where pos.DeptId in ("); ExitPoxSb.Append(delSb.ToString()); ExitPoxSb.Append(")"); ExitPoxSb.Append(" group by dept.DeptName"); sqlHelper helper = new sqlHelper(); SqlDataReader dr = helper.ExecuteRead(helper.connectionStr, ExitPoxSb.ToString()); StringBuilder DeptNameSb = new StringBuilder(); while (dr.Read()) { DeptNameSb.Append(dr["DeptName"].ToString().Trim()); DeptNameSb.Append(","); } if (DeptNameSb.Length > 0) { DeptNameSb.Remove(DeptNameSb.Length - 1, 1); MessageBox.Show("不能删除!一下的部门正在使用" + DeptNameSb.ToString()); return; } delSb.Insert(0, "delete Depart where DeptId in ("); delSb.Append(")"); int result = helper.ExecuteNonQuery(helper.connectionStr, delSb.ToString()); if (result > 0) { MessageBox.Show("删除成功"); QueryDepart(); } else { MessageBox.Show("删除失败"); } } }
public static string GetEmploryeeNameByEpId(int EpId) { string EmploryeeName = null; string sSql = "select EpName from Emploryee where EpId= " + EpId; sqlHelper helper = new sqlHelper(); SqlDataReader dr = helper.ExecuteRead(helper.connectionStr, sSql); if (dr.Read()) { EmploryeeName = dr["EpName"].ToString().Trim(); } return(EmploryeeName); }
public static void BindAllDepart(ComboBox cmbDepart) { string sSql = "select DeptId,DeptName from Depart "; sqlHelper helper = new sqlHelper(); DataSet ds = helper.ExecuteDataSet(helper.connectionStr, sSql, "Depart"); DataRow row = ds.Tables["Depart"].NewRow(); row[0] = 0; row[1] = "请选择"; ds.Tables["Depart"].Rows.InsertAt(row, 0); cmbDepart.DisplayMember = "DeptName"; cmbDepart.ValueMember = "DeptId"; cmbDepart.DataSource = ds.Tables["Depart"]; }
public void BindAcceptMessage() { StringBuilder sSql = new StringBuilder(); sSql.Append("select MessageId,MessageContent,[AceptEmploryId],[PId],[DptId],EpName,DeptName,positionName,SendTime,[flag], "); sSql.Append("case IsRead when 0 then '未读' when 1 then '已读' end as IsRead from vw_AcceptMessage "); //sSql.Append("select MessageId,DeptName,positionName,EpName,MessageContent,SendTime,"); //sSql.Append("case IsRead when 0 then '未读' when 1 then '已读' end as IsRead "); //sSql.Append("from(select EpId,EpName,DeptName,positionName,em.DptId as Dept,em.PId as PId,flag "); //sSql.Append("from Emploryee em,Depart de,Position po "); //sSql.Append("where em.DptId=de.DeptId and em.PId=po.pId ) newEm,Message me "); //sSql.Append("where newEm.EpId=me.SendEmploryId "); sSql.AppendFormat(" where AceptEmploryId= {0}", Common.EpId); if ((int)cmbDept.SelectedValue != 0 && (int)cmbDept.SelectedValue != -1) { sSql.Append(" and [DptId]= "); sSql.Append((int)cmbDept.SelectedValue); if ((int)cmbPosition.SelectedValue != 0 && (int)cmbPosition.SelectedValue != -1) { sSql.Append(" and [PId]= "); sSql.Append((int)cmbPosition.SelectedValue); } } if ((int)cmbDept.SelectedValue == 0 && (int)cmbPosition.SelectedValue != -1 && (int)cmbPosition.SelectedValue != 0) { sSql.AppendFormat(" and [PId]={0} ", (int)cmbPosition.SelectedValue); } if (txtSendName.Text.Trim() != string.Empty) { sSql.Append(" and EpName like '%"); sSql.Append(txtSendName.Text.Trim()); sSql.Append("%'"); } sSql.Append(" and flag=0 "); sSql.Append(" order by SendTime desc "); sqlHelper helper = new sqlHelper(); try { DataSet ds = helper.ExecuteDataSet(helper.connectionStr, sSql.ToString(), "SendEmp"); dgvMessage.AutoGenerateColumns = false; dgvMessage.DataSource = ds.Tables["SendEmp"]; } catch (Exception) { MessageBox.Show("系统维护!", Common.APTION); } }
/// <summary> /// 已读,并按时间排序 /// </summary> public void BindIsReadMessage() { StringBuilder sSql = new StringBuilder(); sSql.Append("select MessageId,MessageContent,EpName,DeptName,positionName,SendTime, "); sSql.Append("case IsRead when 0 then '未读' when 1 then '已读' end as IsRead from vw_AcceptMessage "); sSql.AppendFormat(" where AceptEmploryId= {0}", Common.EpId); sSql.Append(" and IsRead=1"); sSql.Append(" order by SendTime desc "); sqlHelper helper = new sqlHelper(); DataSet ds = helper.ExecuteDataSet(helper.connectionStr, sSql.ToString(), "IsReadMessage"); dgvMessage.AutoGenerateColumns = false; dgvMessage.DataSource = ds.Tables["ISReadMessage"]; }
protected void BindSendEmplory() { sqlHelper helper = new sqlHelper(); StringBuilder sSql = new StringBuilder(); sSql.Append(" select EpId,EpName,case gender when 0 then '女' when 1 then '男' end as Gender,DeptName,positionName "); sSql.Append(" from Emploryee em,Depart de,Position po "); sSql.Append(" where em.DptId=de.DeptId and em.PId=po.pId "); //sSql.Append(" and po.deptId=de.DeptId "); //sSql.Append("select EpId,EpName,case gender when 0 then '女' when 1 then '男' end as Gender,DeptName,positionName"); //sSql.Append(" FROM [hr].[dbo].[vw_SendEmplory]"); sSql.Append(" and flag=0 "); //分步条件加条件筛选信息 if ((int)cmbDept.SelectedValue != 0 && (int)cmbDept.SelectedValue != -1) { sSql.Append(" and em.DptId= "); sSql.Append((int)cmbDept.SelectedValue); if ((int)cmbPosition.SelectedValue != 0 && (int)cmbPosition.SelectedValue != -1) { sSql.Append(" and em.pId= "); sSql.Append((int)cmbPosition.SelectedValue); } } if ((int)cmbDept.SelectedValue == 0 && (int)cmbPosition.SelectedValue != -1 && (int)cmbPosition.SelectedValue != 0) { sSql.AppendFormat(" and em.pId= {0} ", (int)cmbPosition.SelectedValue); } if (txtEmploryName.Text.Trim() != string.Empty) { sSql.Append(" and EpName like '%"); sSql.Append(txtEmploryName.Text.Trim()); sSql.Append("%'"); } try { DataSet ds = helper.ExecuteDataSet(helper.connectionStr, sSql.ToString(), "SendEmp"); dgvEmplory.AutoGenerateColumns = false; dgvEmplory.DataSource = ds.Tables["SendEmp"]; } catch (Exception) { MessageBox.Show("系统维护!", Common.APTION); } }
public static void BindAllPosition(ComboBox cmbPosition, int DeptId) { StringBuilder sSql = new StringBuilder(); sSql.Append("select pId,positionName from Position "); sSql.AppendFormat(" where DeptId={0}", DeptId); sqlHelper helper = new sqlHelper(); DataSet ds = helper.ExecuteDataSet(helper.connectionStr, sSql.ToString(), "position"); DataRow row = ds.Tables["position"].NewRow(); row[0] = 0; row[1] = "请选择"; ds.Tables["position"].Rows.InsertAt(row, 0); cmbPosition.DisplayMember = "positionName"; cmbPosition.ValueMember = "pId"; cmbPosition.DataSource = ds.Tables["position"]; }
public void BindAssessExample() { StringBuilder sb = new StringBuilder(); sb.Append("select AssesExampleId,Title,TotalScore,case IsPass when 0 then '正在审核' when 1 then '已通过' end as IsPass from AssesExample"); if (txtTitle.Text != string.Empty) { sb.Append(" where Title like '%"); sb.Append(txtTitle.Text.Trim()); sb.Append(" %'"); } sb.Append(" order by AssesExampleId DESC"); sqlHelper helper = new sqlHelper(); DataSet ds = helper.ExecuteDataSet(helper.connectionStr, sb.ToString(), null); dgvAE.AutoGenerateColumns = false; dgvAE.DataSource = ds.Tables[0]; }
public void QueryDepart() { StringBuilder sSql = new StringBuilder(); sSql.Append("select DeptId,DeptName,parentId from Depart "); if (txtDepartName.Text.Trim() != string.Empty) { sSql.Append("where deptName like '%"); sSql.Append(txtDepartName.Text.Trim()); sSql.Append("%' "); } sSql.Append(" order by DeptId DESC"); sqlHelper helper = new sqlHelper(); DataSet ds = helper.ExecuteDataSet(helper.connectionStr, sSql.ToString(), "Depart"); dgvDepart.AutoGenerateColumns = false; dgvDepart.DataSource = ds.Tables["Depart"]; }
private bool CheckAdmin() { bool isValidAdmin = false; Common.UserName = cmbUserName.Text.Trim(); Common.UserPwd = txtUserPwd.Text.Trim(); StringBuilder sSql = new StringBuilder(); sSql.Append("select LoginId,LoginPwd,us.epId,ep.EpName from Users us inner join Emploryee ep on us.epId=ep.epId "); sSql.AppendFormat("where LoginId='{0}' and LoginPwd='{1}'", cmbUserName.Text.Trim(), txtUserPwd.Text.Trim()); sSql.Append(" and ep.flag=0 "); sqlHelper helper = new sqlHelper(); try { SqlDataReader dr = helper.ExecuteRead(helper.connectionStr, sSql.ToString()); if (dr.Read()) { Common.EpId = Convert.ToInt32(dr["epId"]); Common.EpName = dr["EpName"].ToString().Trim(); if (dr["LoginId"].ToString().Trim() == Common.UserName && dr["LoginPwd"].ToString().Trim() == Common.UserPwd) { isValidAdmin = true; } else { Common.Message = "用户名或密码不正确!"; isValidAdmin = false; } } dr.Close(); } catch (Exception) { Common.Message = "系统维护,请稍后再试!"; isValidAdmin = false; } return(isValidAdmin); }
private void btnDelete_Click(object sender, EventArgs e) { if (dgvEmploryeeInfo.SelectedRows.Count > 0) { DialogResult delResult = MessageBox.Show("您确定要删除吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (delResult == DialogResult.Yes) { //删除语句 StringBuilder delSb = new StringBuilder(); sqlHelper helper = new sqlHelper(); delSb.Append(" UPDATE [hr].[dbo].[Emploryee] SET flag=1 "); delSb.Append(" where EpId in ( "); foreach (DataGridViewRow row in dgvEmploryeeInfo.SelectedRows) { if (row.Cells["EpId"].Value != null) { } delSb.Append(row.Cells["EpId"].Value); delSb.Append(","); } delSb.Remove(delSb.Length - 1, 1); delSb.Append(" )"); int result = helper.ExecuteNonQuery(helper.connectionStr, delSb.ToString()); if (result > 0) { MessageBox.Show("删除成功"); BindEmploryeeinfo(); } else { MessageBox.Show("删除失败"); } } } else { MessageBox.Show("请选择一行"); } }
private void updataEmploryee() { StringBuilder sSql = new StringBuilder(); sSql.Append("update Emploryee set "); sSql.AppendFormat(" EpName='{0}',", txtEmploryeeName.Text.Trim()); if (rbtBoy.Checked) { sSql.AppendFormat(" gender={0},", 1); } else { sSql.AppendFormat(" gender={0},", 0); } sSql.AppendFormat(" MobilePhone='{0}', ", txtCellPhoneNum.Text.Trim()); sSql.AppendFormat(" officePhone='{0}',", txtTelephoneNum.Text.Trim()); sSql.AppendFormat(" Address='{0}', ", txtAddress.Text.Trim()); sSql.AppendFormat(" DptId={0},", (int)cmbDepart.SelectedValue); sSql.AppendFormat(" PId={0} ", (int)cmbPosition.SelectedValue); sSql.AppendFormat(" where EpId={0} ", EmpId); sqlHelper helper = new sqlHelper(); try { if (helper.ExecuteNonQuery(helper.connectionStr, sSql.ToString()) > 0) { MessageBox.Show("修改保存成功!", Common.APTION); this.Close(); feb.BindEmploryeeinfo(); } else { MessageBox.Show("修改失败!", Common.APTION); } } catch (Exception) { MessageBox.Show("系统维护!"); } }
private void AddEmploryee() { StringBuilder sSql = new StringBuilder(); sSql.Append("insert Emploryee (EpName,PId,DptId,MobilePhone,officePhone,Address,gender) "); sSql.AppendFormat(" values('{0}',", txtEmploryeeName.Text.Trim()); sSql.AppendFormat("{0},", cmbPosition.SelectedValue); sSql.AppendFormat("{0},", cmbDepart.SelectedValue); sSql.AppendFormat("'{0}',", txtCellPhoneNum.Text.Trim()); sSql.AppendFormat("'{0}',", txtTelephoneNum.Text.Trim()); sSql.AppendFormat("'{0}',", txtAddress.Text.Trim()); if (rbtBoy.Checked) { sSql.AppendFormat("{0}", 1); } else if (rbtGirl.Checked) { sSql.AppendFormat("{0}", 0); } sSql.Append(")"); sqlHelper helper = new sqlHelper(); try { if (helper.ExecuteNonQuery(helper.connectionStr, sSql.ToString()) > 0) { MessageBox.Show("添加成功!"); feb.BindEmploryeeinfo(); this.Close(); } else { MessageBox.Show("添加失败!"); } } catch (Exception) { MessageBox.Show("系统维护!"); } }
private void showDept() { //StringBuilder sSql=new StringBuilder(); //sSql.Append("select de.DeptId,de.DeptName,pn.DeptName "); //sSql.Append(" from(select DeptName from Depart where DeptId= "); //sSql.AppendFormat(" (select parentId from Depart where DeptId={0})) pn, Depart de ",DeptId); //sSql.AppendFormat(" where DeptId={0} ",DeptId); string sSql = "select * from Depart where DeptId=" + DeptId; sqlHelper helper = new sqlHelper(); SqlDataReader dr = helper.ExecuteRead(helper.connectionStr, sSql); if (dr.Read()) { cmbDepartFather.SelectedValue = (int)dr["parentId"]; txtDeptName.Text = dr["DeptName"].ToString().Trim(); if (flag == 2) { txtDepartId.Text = DeptId.ToString().Trim(); } } dr.Close(); }
private void validateMessage() { string sSql = "select count(*) from Message where IsRead=0 and AceptEmploryId=" + Common.EpId; sqlHelper helper = new sqlHelper(); if ((int)helper.ExecuteScalar(helper.connectionStr, sSql) > 0) { if (frmmbox == null) { frmmbox = new FrmMessageBox(); frmmbox.frmadmin = this; frmmbox.frmrm = frm; frmmbox.Show(); } } else { if (frmmbox != null) { frmmbox.Close(); frmmbox = null; } } }