/// <summary> /// 用YGB Model更新一个员工 /// </summary> /// <param name="yg">YGB Model</param> /// <returns>bool</returns> public bool Update_YG(YGB yg) { string sql = "update YGB set YGXM=@YGXM,DHHM=@DHHM,YGZWBH=@YGZWBH,YGSFZ=@YGSFZ,YGZT=@YGZT,USER_NAME=@USER_NAME,PASSWORD=@PASSWORD where ygbh=@ygbh"; SqlParameter[] spr = { new SqlParameter("@YGXM", yg.YGXM), new SqlParameter("@DHHM", yg.DHHM), new SqlParameter("@YGZWBH", yg.YGZWBH), new SqlParameter("@YGSFZ", yg.YGSFZ), new SqlParameter("@YGZT", yg.YGZT), new SqlParameter("@USER_NAME", yg.User_Name), new SqlParameter("@PASSWORD", yg.Password), new SqlParameter("@ygbh", yg.YGBH) }; try { if (DBHelperSQL.Execute(sql, spr) > 0) { return(true); } else { return(false); } } catch (Exception) { throw; } }
/// <summary> /// 用YGB Model保存一个员工 /// </summary> /// <param name="yg">YGB Model</param> /// <returns>bool</returns> public bool Save_YG(YGB yg) { string sql = "insert into YGB values(@ygxm,@dhhm,@ygzwbh,@ygsfz,@ygzt,@user_name,@password)"; SqlParameter[] spr = { new SqlParameter("@ygxm", yg.YGXM), new SqlParameter("@dhhm", yg.DHHM), new SqlParameter("@ygzwbh", yg.YGZWBH), new SqlParameter("@ygzt", yg.YGZT), new SqlParameter("@ygsfz", yg.YGSFZ), new SqlParameter("@user_name", yg.User_Name), new SqlParameter("@password", yg.Password) }; try { int i = DBHelperSQL.Execute(sql, spr); if (i > 0) { return(true); } else { return(false); } } catch (Exception) { throw; } }
private void deleteSelectedCars(object sender, EventArgs e) { if (dataGrid_waitcar.SelectedRows.Count > 0) { for (int i = 0; i < dataGrid_waitcar.SelectedRows.Count; i++) { ygb = ygbdal.Get_ygxx_by_bh(dataGrid_waitcar.SelectedRows[i].Cells["员工编号"].Value.ToString()); ygbdal.deleteThisUser(ygb.YGBH); } ref_WaitCar(); } }
private void simpleButtonSave_Click(object sender, EventArgs e) { if (textBoxYgbh.Text == "" || textBoxYgxm.Text == "" || textBoxPassword.Text == "" || textBoxYgsfz.Text == "" || textBoxSecPassword.Text == "" || textBoxUsername.Text == "" || textBoxYgdh.Text == "") { MessageBox.Show("资料不完整,请填写完整", "系统提示"); return; } if (mainPanelForm.ygbdal.checkUserNameIsAlive(textBoxUsername.Text.Trim())) { MessageBox.Show("用户名已经存在,请重新填写", "系统提示"); return; } if (mainPanelForm.ygbdal.checkYgbhIsAlive(textBoxYgbh.Text.Trim())) { MessageBox.Show("员工编号已经存在,请重新填写", "系统提示"); return; } if (textBoxPassword.Text != textBoxSecPassword.Text) { MessageBox.Show("两次密码输入不一致,请重新输入", "系统提示"); textBoxPassword.Text = ""; textBoxSecPassword.Text = ""; return; } YGB newyg = new YGB(); newyg.YGBH = textBoxYgbh.Text.Trim(); newyg.YGXM = textBoxYgxm.Text.Trim(); newyg.YGSFZ = textBoxYgsfz.Text.Trim(); newyg.YGZT = "正常"; newyg.YGZWBH = mainPanelForm.zwbdal.getZwbhbyZwmc(comboBoxYgzwbh.Text.Trim()); newyg.User_Name = textBoxUsername.Text.Trim(); newyg.Password = textBoxPassword.Text.Trim(); newyg.DHHM = textBoxYgdh.Text.Trim(); if (mainPanelForm.ygbdal.AddNewUser(newyg)) { if (staffpic == true) { System.IO.File.Copy(picfile.FileName, ".\\staffpic\\" + newyg.YGBH + ".jpg", true); } MessageBox.Show("员工添加成功,用户名:" + newyg.User_Name + ",密码:" + newyg.Password, "系统提示"); } else { MessageBox.Show("操作失败,员工" + newyg.User_Name + "添加过程出现异常", "系统提示"); } staffpic = false; }
private void dataGrid_waitcar_SelectionChanged_1(object sender, EventArgs e) { if (ref_zt) { if (dataGrid_waitcar.SelectedRows.Count > 0) { if (dataGrid_waitcar.SelectedRows.Count == 1) { //ToolStripMenuItem_fc.Enabled = true; ToolStripMenuItemqx.Enabled = true; selectID = new string[1024]; for (int i = 0; i < dataGrid_waitcar.SelectedRows.Count; i++) { selectID[i] = dataGrid_waitcar.SelectedRows[i].Cells["员工编号"].Value.ToString(); } ygb = ygbdal.Get_ygxx_by_bh(dataGrid_waitcar.SelectedRows[0].Cells["员工编号"].Value.ToString()); pictureBox1.ImageLocation = ".\\staffpic\\" + ygb.YGBH + ".jpg"; } else if (dataGrid_waitcar.SelectedRows.Count > 1) { //ToolStripMenuItem_fc.Enabled = false; ToolStripMenuItemqx.Enabled = true; selectID = new string[1024]; for (int i = 0; i < dataGrid_waitcar.SelectedRows.Count; i++) { selectID[i] = dataGrid_waitcar.SelectedRows[i].Cells["员工编号"].Value.ToString(); } } else { //ToolStripMenuItem_fc.Enabled = false; selectID = new string[1024]; for (int i = 0; i < dataGrid_waitcar.SelectedRows.Count; i++) { selectID[i] = dataGrid_waitcar.SelectedRows[i].Cells["员工编号"].Value.ToString(); } } } else { selectID = new string[1024]; for (int i = 0; i < dataGrid_waitcar.SelectedRows.Count; i++) { selectID[i] = dataGrid_waitcar.SelectedRows[i].Cells["员工编号"].Value.ToString(); } } } }