/// <summary> /// 修改销售员的信息 /// </summary> /// <param name="Salesman"></param> /// <returns></returns> public static bool UpdateSaleman(Saleman Salesman) { string sql = string.Format("update Saleman set SalesmanName='{0}' , Pwd='{1}' ,Gender='{2}',BaseSalary={3},CommissionRate={4},work='{5}' where Mobile='{6}' ", Salesman.SalesmanName, Salesman.Pwd, Salesman.Gender, Salesman.BaseSalary, Salesman.CommissionRate, Salesman.Work, Salesman.Mobile); return(DBHelper.ExecuteNonQuery(sql)); }
/// <summary> /// 添加员工 /// </summary> /// <param name="Salesman"></param> /// <returns></returns> public static bool InsertSalesman(Saleman Salesman) { string sql1 = string.Format("insert Saleman values ('{0}','{1}','{2}','{3}',{4},{5},'{6}')" , Salesman.SalesmanName, Salesman.Mobile, Salesman.Pwd, Salesman.Gender, Salesman.BaseSalary, Salesman.CommissionRate, Salesman.Work); return(DBHelper.ExecuteNonQuery(sql1)); }
/// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_xiugai_Click(object sender, EventArgs e) { try { if (id != 0) { if (TextBoxBll.Intextnull(this.txt_mobile.Text, 3)) { MessageBox.Show("请输入正确的电话号码", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (TextBoxBll.Intextnull(this.txt_commissionRate.Text, 4))//验证提成是否为1~0之间的数字 { MessageBox.Show("提成必须是0~1的数字", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (TextBoxBll.Intextnull(this.txt_name.Text, 1)) { MessageBox.Show("姓名格式错误", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { Saleman saleman = new Saleman() { SalesmanName = this.txt_name.Text, Mobile = this.txt_mobile.Text, Pwd = this.txt_pwd.Text, Gender = this.cbo_gander.Text, BaseSalary = this.txt_basesalary.Text, CommissionRate = this.txt_commissionRate.Text, Work = this.cbo_work.Text }; if (SalemanBll.UpdateSaleman(saleman)) { MessageBox.Show("修改成功", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("修改失败", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } } else { MessageBox.Show("请选择员工", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.dgv_renyuan.DataSource = SalemanBll.GetSaleman(); this.txt_basesalary.Text = ""; this.txt_commissionRate.Text = ""; this.txt_mobile.Text = ""; this.txt_name.Text = ""; this.txt_pwd.Text = ""; } }
public void Test_School() { IVisitorSchool doctor = new Doctor("Doctor Strange"); IVisitorSchool saleman = new Saleman("Jordan Belfort"); School school = new School(); school.PerformExamination(doctor); school.PerformSaling(saleman); foreach (Kid kid in school.GetKids) { Assert.That(kid.GetGift, Is.EqualTo(GiftType.Toys)); Assert.That(kid.GetMedicine, Is.EqualTo(MedicineType.ForKid)); } foreach (Teacher teacher in school.GetTeachers) { Assert.That(teacher.GetGift, Is.EqualTo(GiftType.Laptop)); Assert.That(teacher.GetMedicine, Is.EqualTo(MedicineType.ForAdult)); } }
/// <summary> /// 添加员工 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_zengjia_Click(object sender, EventArgs e) { try { if (this.txt_basesalary.Text == "" || this.txt_commissionRate.Text == "" || this.txt_mobile.Text == "" || this.txt_name.Text == "" || this.txt_pwd.Text == "") { MessageBox.Show("信息不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } if (TextBoxBll.Intextnull(this.txt_mobile.Text, 3)) { MessageBox.Show("请输入正确的电话号码", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (TextBoxBll.Intextnull(this.txt_commissionRate.Text, 4))//验证提成是否为1~0之间的数字 { MessageBox.Show("提成必须是0~1的数字", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (TextBoxBll.Intextnull(this.txt_name.Text, 1)) { MessageBox.Show("姓名格式错误", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (SalemanBll.SelectSalemanByMobile(this.txt_mobile.Text)) { MessageBox.Show("电话号码已存在", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { Saleman saleman = new Saleman() { SalesmanName = this.txt_name.Text, Mobile = this.txt_mobile.Text, Pwd = this.txt_pwd.Text, Gender = this.cbo_gander.Text, BaseSalary = this.txt_basesalary.Text, CommissionRate = this.txt_commissionRate.Text, Work = this.cbo_work.Text }; if (SalemanBll.InsertSalesman(saleman)) { MessageBox.Show("添加成功", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("添加失败", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } flag = true; } } catch (Exception) { MessageBox.Show("请正确填写信息", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } finally { this.dgv_renyuan.DataSource = SalemanBll.GetSaleman(); this.txt_basesalary.Text = ""; this.txt_commissionRate.Text = ""; this.txt_mobile.Text = ""; this.txt_name.Text = ""; this.txt_pwd.Text = ""; } }
/// <summary> /// 添加员工 /// </summary> /// <param name="Salesman"></param> /// <returns></returns> public static bool InsertSalesman(Saleman Salesman) { return(SalemanDAL.InsertSalesman(Salesman)); }
/// <summary> /// 修改销售员的信息 /// </summary> /// <param name="Salesman"></param> /// <returns></returns> public static bool UpdateSaleman(Saleman Salesman) { return(SalemanDAL.UpdateSaleman(Salesman)); }
public ActionResult NewItems() { // get categories List <Item_type> obj = new List <Item_type>(); List <Karigar> kobj = new List <Karigar>(); List <Saleman> sobj = new List <Saleman>(); // New_Item tobj = new New_Item(); New_Item Parent = new New_Item(); string karigarqery = "Select * from [Karigar]"; string itemquery = "Select * from [Item_type]"; string salemanquery = "Select * from [Saleman]"; string tagquery = "SELECT TOP 1 [I_tag_no] FROM [Items] ORDER BY [I_id] DESC"; using (SqlConnection con = new SqlConnection(cs)) { using (SqlCommand cmd = new SqlCommand(itemquery)) { cmd.Connection = con; // opening connection con.Open(); cs = con.State.ToString(); SqlDataReader sdr = cmd.ExecuteReader(); while (sdr.Read()) { Item_type np = new Item_type(); np.I_type_id = (int)sdr["I_type_id"]; np.I_type_name = (string)sdr["I_type_name"]; obj.Add(np); } con.Close(); } using (SqlCommand cmd = new SqlCommand(salemanquery)) { cmd.Connection = con; // opening connection con.Open(); cs = con.State.ToString(); SqlDataReader sdr = cmd.ExecuteReader(); while (sdr.Read()) { Saleman snp = new Saleman(); snp.S_id = (int)sdr["S_id"]; snp.S_name = (string)sdr["S_name"]; sobj.Add(snp); } con.Close(); } using (SqlCommand cmd = new SqlCommand(karigarqery)) { cmd.Connection = con; // opening connection con.Open(); cs = con.State.ToString(); SqlDataReader sdr = cmd.ExecuteReader(); while (sdr.Read()) { Karigar knp = new Karigar(); knp.K_id = (int)sdr["K_id"]; knp.K_name = (string)sdr["K_name"]; kobj.Add(knp); } con.Close(); } using (SqlCommand cmd = new SqlCommand(tagquery)) { cmd.Connection = con; con.Open(); cs = con.State.ToString(); SqlDataReader tdr = cmd.ExecuteReader(); New_Item tnp = new New_Item(); if (tdr.Read()) { tnp.I_tag_no = (int)tdr["I_tag_no"] + 1; temptag = tnp.I_tag_no.ToString(); } else { tnp.I_tag_no = 5000; temptag = tnp.I_tag_no.ToString(); } Parent.I_tag_no = tnp.I_tag_no; con.Close(); } } Parent.Iobj = obj; Parent.Kobj = kobj; Parent.Sobj = sobj; return(View(Parent)); }
/// <summary> /// 添加员工 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { Saleman saleman = new Saleman() { SalesmanName = this.txt_name.Text, Mobile = this.txt_mobile.Text, Pwd = this.txt_pwd.Text, Gender = this.cbo_sex.Text, BaseSalary = this.txt_money.Text, CommissionRate = this.txt_ticheng.Text, Work = this.cbo_work.Text }; if (saleman.SalesmanName == "" && TextBoxBll.Intextnull(this.txt_name.Text, 1)) { MessageBox.Show("姓名格式不正确", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (saleman.Mobile == "") { MessageBox.Show("电话号码不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (TextBoxBll.Intextnull(this.txt_name.Text, 1)) { MessageBox.Show("姓名格式错误", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (TextBoxBll.Intextnull(this.txt_mobile.Text, 3)) { MessageBox.Show("请输入正确的电话号码", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (saleman.Pwd == "") { MessageBox.Show("密码不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (saleman.Gender == "") { MessageBox.Show("性别不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (saleman.BaseSalary == "") { MessageBox.Show("底薪不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (saleman.CommissionRate == "") { MessageBox.Show("提成不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (TextBoxBll.Intextnull(this.txt_ticheng.Text, 4)) { MessageBox.Show("提成必须是0~1的小数!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (TextBoxBll.Intextnull(this.txt_money.Text, 2)) { MessageBox.Show("工资必须为正整数", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { //判断是否存在 if (SalemanBll.SelectSalemanByMobile(saleman.Mobile)) { MessageBox.Show("员工以存在 请勿重复添加 如需修改请至管理界面", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { //添加员工 //如果添加成功则初始化数据 if (SalemanBll.InsertSalesman(saleman)) { this.txt_name.Text = ""; this.txt_mobile.Text = ""; this.txt_pwd.Text = ""; this.cbo_sex.SelectedIndex = 0; this.txt_money.Text = ""; this.txt_ticheng.Text = ""; this.cbo_work.SelectedIndex = 0; MessageBox.Show("添加成功", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } } }