예제 #1
0
 /// <summary>
 /// 删除员工
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_shanchu_Click(object sender, EventArgs e)
 {
     try
     {
         if (id != 0)
         {
             if (SalemanBll.DeleteSaleman(id))
             {
                 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);
         throw;
     }
     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            = "";
     }
 }
예제 #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            string    sql = string.Format("select*from Saleman where Mobile='{0}'", this.txt_mobile.Text);
            DataTable dt  = DBHelper.GetDataTable(sql);

            if (SalemanBll.SelectSalemanByMobile(this.txt_mobile.Text))
            {
                MessageBox.Show("员工已存在", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                this.txt_money.Text   = dt.Rows[0]["BaseSalary"].ToString();
                this.txt_name.Text    = dt.Rows[0]["SalesmanName"].ToString();
                this.txt_pwd.Text     = dt.Rows[0]["Pwd"].ToString();
                this.txt_ticheng.Text = dt.Rows[0]["CommissionRate"].ToString();
                this.cbo_sex.Text     = dt.Rows[0]["Gender"].ToString();
                this.cbo_work.Text    = dt.Rows[0]["Work"].ToString();
                //this.txt_mobile.ReadOnly = true;
                //this.txt_money.ReadOnly = true;
                //this.txt_name.ReadOnly = true;
                //this.txt_pwd.ReadOnly = true;
                //this.txt_ticheng.ReadOnly = true;
            }
            else
            {
                MessageBox.Show("员工不存在,请添加", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
예제 #3
0
 /// <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            = "";
     }
 }
예제 #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         //获取用户输入的用户名和密码
         string userName = this.txt_name.Text;
         string password = this.txt_pwd.Text;
         name.Name = SalemanBll.GetSalemanNameByPhone(userName);
         //职务
         string work = this.rdo_guanli.Checked ? this.rdo_guanli.Text : this.rdo_saler.Text;
         bool   flag = false;//判断是否选择权限
         if (this.rdo_guanli.Checked || this.rdo_saler.Checked)
         {
             flag = true;
         }
         //非空验证
         if (userName != "" && password != "" && flag == true)
         {
             int result = SalemanBll.LoginUserInfo(userName, password, work);
             if (result == 0)
             {
                 //账号不存在
                 MessageBox.Show("账号不存在", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             }
             if (result == 1)
             {
                 //密码错误
                 MessageBox.Show("密码错误", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             }
             if (result == 2)
             {
                 if (this.rdo_saler.Checked)
                 {
                     SalerForm sa = new SalerForm();
                     sa.Show();
                     this.Hide();
                 }
                 else
                 {
                     //登录成功
                     MainForm main = new MainForm();
                     main.Show();
                     this.Hide();
                 }
             }
         }
         else
         {
             MessageBox.Show("请正确填写登录信息", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("请正确填写登录信息", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
 }
예제 #5
0
 private void StaffForm_Load(object sender, EventArgs e)
 {
     cbo_work.SelectedIndex   = 0;
     cbo_gander.SelectedIndex = 0;
     //不允许自动创建列
     this.dgv_renyuan.AutoGenerateColumns = false;
     //绑定数据源
     this.dgv_renyuan.DataSource = SalemanBll.GetSaleman();
     //初始最大化
     this.WindowState = FormWindowState.Maximized;
     //设置为可编辑状态
     dgv_renyuan.BeginEdit(false);
 }
예제 #6
0
        /// <summary>
        /// 根据时间和姓名查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void skinButton1_Click(object sender, EventArgs e)
        {
            int salemanid = SalemanBll.SelectSalemanByName(this.txt_chaxun.Text);

            if (salemanid == 0)
            {
                MessageBox.Show("您查找的员工销售记录不存在", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                this.dgv_xiangqing.DataSource = SaleBll.SelectSale();
            }
            else
            {
                this.dgv_xiangqing.DataSource = SaleBll.SelectSaleByTime(salemanid, this.dateTimePicker1.Text, this.dateTimePicker2.Text);
            }
        }
예제 #7
0
        /// <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            = "";
            }
        }
예제 #8
0
 /// <summary>
 /// 模糊查询员工
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_chaxun_Click(object sender, EventArgs e)
 {
     this.dgv_renyuan.AutoGenerateColumns = false;
     this.dgv_renyuan.DataSource          = SalemanBll.GetSalemanLikeName(this.txt_renyuan.Text);
 }
예제 #9
0
        int stocknum = 0; //库存
        /// <summary>
        /// 确定购买按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_jiezhang_Click(object sender, EventArgs e)
        {
            if (this.lv_sales.Items.Count == 0)
            {
                MessageBox.Show("当前无添加书本", "温馨提示");
                return;
            }
            else
            {
                //检索是否能否成功销售
                int error = 0;
                for (int i = 0; i < this.lv_sales.Items.Count; i++)
                {
                    stocknum = int.Parse(this.lv_sales.Items[i].SubItems[6].Text.ToString());
                    if (!BooksBLL.UpdateBooksStockNum(this.lv_sales.Items[i].SubItems[2].Text.ToString(), stocknum))
                    {
                        error++;
                    }
                }
                if (error > 0)
                {
                    MessageBox.Show("库存数可能不足", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    //存已买的书本的信息
                    string info = "单号:" + lbl_danhao.Text + "\r\n";
                    //将书本信息存入字符变量info
                    for (int i = 0; i < this.lv_sales.Items.Count; i++)
                    {
                        info += "书本名字:" + this.lv_sales.Items[i].SubItems[2].Text + "\r\n书本价格:" + this.lv_sales.Items[i].SubItems[4].Text + "\r\n书本折扣:" + this.lv_sales.Items[i].SubItems[5].Text + "\r\n书本数量:" + this.lv_sales.Items[i].SubItems[6].Text + "\r\n";
                    }
                    info += "总金额:" + lbl_money.Text + "\r\n";
                    info += "购物员:" + lbl_yuangong.Text;
                    //创建打印信息
                    for (int i = 0; i < this.lv_sales.Items.Count; i++)
                    {
                        if (stocknum >= 0)
                        {
                            using (StreamWriter st = new StreamWriter(@"D:\小票.txt", false, Encoding.UTF8))
                            {
                                if (!TextBoxBll.Intextnull(this.txt_shishou.Text, 2) || TextBoxBll.Intextnull(this.txt_shishou.Text, 1))
                                {
                                    if (this.txt_shishou.Text == "")
                                    {
                                        MessageBox.Show("请输入实收金额", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                        return;
                                    }
                                    else if (this.txt_shishou.Text != null && double.Parse(this.txt_shishou.Text.ToString()) >= double.Parse(this.lbl_money.Text.ToString()))
                                    {
                                        this.lbl_zhaoling.Text = (double.Parse(this.txt_shishou.Text.ToString()) - double.Parse(this.lbl_money.Text.ToString())).ToString();
                                        st.Write(info);
                                        st.Flush();
                                        messge = true;
                                    }
                                    else
                                    {
                                        MessageBox.Show("实收金额小于应付金额", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                        return;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("请正确输入预收金额", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                }
                            }
                        }
                    }
                }

                //结算成功
                if (messge)
                {
                    //将信息保存至销售表
                    int      Salesmanid = SalemanBll.SelectSalemanByName(this.lbl_yuangong.Text);
                    DateTime time       = DateTime.Parse(DateTime.Now.ToString("yyyy年MM月dd日"));
                    SaleBll.InsertSale(this.lbl_danhao.Text, time, sum, Salesmanid);
                    for (int j = 0; j < lv_sales.Items.Count; j++)
                    {
                        //将信息保存至销售详情表
                        SalesDetail sale = new SalesDetail()
                        {
                            BooksID     = BooksBLL.GetBooksIDbyBooksName(this.lv_sales.Items[j].SubItems[2].Text),
                            Quantity    = num,
                            SalesID     = SaleBll.GetSDIDByTime(this.lbl_danhao.Text),
                            AloneAmount = decimal.Parse(this.lv_sales.Items[j].SubItems[4].Text) * decimal.Parse(this.lv_sales.Items[j].SubItems[5].Text)
                        };
                        SalesDailBLL.InsertSaleDail(sale);
                    }
                    DataTable dt = VipBll.SetVipByMobile(this.txt_vip.Text);
                    if (isVIP)
                    {
                        if (bijiao == true)                                                                 //总价大于积分,默认为true
                        {
                            double sum2 = sum / 10;                                                         // 1:10积分产生
                            int    sum1 = (int)sum2;                                                        //积分取整
                            if (checkBox1.Checked == true)                                                  //若使用积分抵扣
                            {
                                sum = sum - double.Parse(dt.Rows[0][4].ToString()) * 0.1;                   //真实价格处理
                                VipBll.ClearjifenByPhone(this.txt_vip.Text);                                //积分已抵扣完,现将vip积分清空
                            }
                            VipBll.UpdatejifenByPhone(this.txt_vip.Text, int.Parse(sum1.ToString()));       //正常积分增加
                            this.jifenshu.Text = sum1.ToString();                                           //显示结账后的积分
                        }
                        if (bijiao == false)                                                                //总价小于积分抵扣。积分有剩
                        {
                            double sum2 = sum * 10;                                                         //花费的积分
                            int    sum5 = (int)(double.Parse(dt.Rows[0][4].ToString()) - sum2);             //抵扣后的积分
                            if (checkBox1.Checked == true)                                                  //若使用积分
                            {
                                sum = 0;                                                                    //真实价格处理
                                VipBll.DecreasejifenByPhone(this.txt_vip.Text, int.Parse(sum2.ToString())); //之前积分减去抵扣积分
                            }
                            VipBll.UpdatejifenByPhone(this.txt_vip.Text, int.Parse(sum.ToString()));        //正常积分增加,不过总价以为0,积分不会增加
                            this.jifenshu.Text = sum5.ToString();                                           //显示结账后的积分
                        }
                    }
                    MessageBox.Show("结算成功,祝您生活愉快", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    //信息初始化
                    this.lv_sales.Items.Clear();
                    this.lbl_goods.Text = "0";
                    liushuihao();
                    this.lbl_money.Text = "0.0000";
                    num = 1;
                    this.lbl_zhaoling.Text = "0.0";
                    this.txt_shishou.Text  = "";
                    this.jifenxianshi.Text = "";
                    error  = 0;
                    sum    = 0;
                    sum3   = 0;
                    sum4   = 0;
                    bijiao = true;
                }
            }
        }
예제 #10
0
        /// <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);
                    }
                }
            }
        }