Beispiel #1
0
 /// <summary>
 /// 添加营业员
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSure_Click(object sender, EventArgs e)
 {
     if (txtAdmName.CheckNullOrEmpty() * txtAdmPwd.CheckData(@"^\w{6,}$", "密码必须为6位字母、数字、下划线组合") == 0)
     {
         return;
     }
     else
     {
         SelesPersonSModel person = new SelesPersonSModel()
         {
             LoginPwd = txtAdmPwd.Text.Trim(),
             SPName   = txtAdmName.Text.Trim()
         };
         //添加营业员的方法
         person = adminManager.InsertSales(person);
         if (person == null)
         {
             MessageBox.Show("添加营业员失败!", "提示");
         }
         else
         {
             if (MessageBox.Show($"添加营业员成功!\r\n编号:【{person.SalesPersonId}】\r\n是否继续添加", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 txtAdmName.Text = "";
                 txtAdmPwd.Text  = "123456";
                 return;
             }
             else
             {
                 this.DialogResult = DialogResult.OK;
                 this.Close();
             }
         }
     }
 }
Beispiel #2
0
        //登录收银员的方法
        public SelesPersonSModel SelesLogin(SelesPersonSModel seles)
        {
            string str = "SelesLogeIn";

            SqlParameter[] sp =
            {
                new SqlParameter("@LoginId",  SqlDbType.Int),
                new SqlParameter("@LoginPwd", SqlDbType.NVarChar, 50)
            };
            sp[0].Value = seles.SalesPersonId;
            sp[1].Value = seles.LoginPwd;
            SqlDataReader     reader = SQLHelper.GetDataReader(str, sp);
            SelesPersonSModel model  = null;

            while (reader.Read())//reader拿到数据库里面的值
            {
                model = new SelesPersonSModel()
                {
                    SalesPersonId = Convert.ToInt32(reader["SalesPersonId"]),//reader里面对应的值是数据库里面的值
                    LoginPwd      = int.Parse(reader["LoginPwd"].ToString()),
                    SPName        = reader["SPName"].ToString()
                };
            }
            return(model);
        }
Beispiel #3
0
 public FrmUpdateSale(SelesPersonSModel person)
 {
     InitializeComponent();
     this.StartPosition = FormStartPosition.CenterScreen;
     Sales           = person;
     txtAdmName.Text = person.SPName;
     txtAdmPwd.Text  = person.LoginPwd.ToString();
 }
Beispiel #4
0
 public SelesPersonSModel UpdateSales(SelesPersonSModel person)
 {
     if (adminServer.UpdateSales(person) > 0)
     {
         return(person);
     }
     else
     {
         return(null);
     }
 }
        public int UpdateSales(SelesPersonSModel person)
        {
            string procName = "UpdateSaleInfor";

            SqlParameter[] sp =
            {
                new SqlParameter("@saleName", person.SPName),
                new SqlParameter("@loginPwd", person.LoginPwd),
                new SqlParameter("@loginId",  person.SalesPersonId)
            };
            return(SQLHelper.ExecuteNonQuery(procName, sp));
        }
Beispiel #6
0
        /* //写入日志
         * Log4net类 log4Net = new Log4net类();*/

        //登录
        private void button1_Click(object sender, EventArgs e)
        {
            //【一】文本框的数据验证
            //如果为0则有必须项未填写
            if (txtLogId.CheckData(@"^[1-9]\d*$", "账户格式为纯数字") * txtLogPwd.CheckNullOrEmpty() != 0)
            {
                //【二】登录账号和密码封装成收银员对象
                SelesPersonSModel model = new SelesPersonSModel()
                {
                    SalesPersonId = int.Parse(txtLogId.Text),
                    LoginPwd      = txtLogPwd.Text
                };
                //【三】数据库中查询
                //记录一下不等于null的数据(就是获取到收银员的数据了)
                SelesPersonSModel JL = manager.SelesLogin(model);
                if (JL != null)
                {
                    //在主入口函数地方Sale声明一个属性记录数据,相当于全局变量拿到了
                    //【1】将登录对象保存到全局
                    Program.Seles = JL;

                    //【2】将登录信息记录到系统日志里面
                    int LogId = manager.BllWriteSelesLog(new LoginLogsModel()
                    {
                        LoginId    = JL.SalesPersonId,
                        SPName     = JL.SPName,
                        ServerName = Dns.GetHostName(),
                    });
                    Program.Seles.LogId = LogId;


                    this.DialogResult = DialogResult.OK;


                    //写入日志
                    Log4net类.WriteInfo(string.Format("" + JL + ""));

                    this.Close();//关掉登录窗口
                }
                else
                {
                    Log4net类.WriteError(string.Format("" + JL + ""));
                    MessageBox.Show("登录失败", "登录提示");
                }
            }
        }
        public SelesPersonSModel InsertSales(SelesPersonSModel person)
        {
            string procName = "InsertSales";

            SqlParameter[] sp =
            {
                new SqlParameter("@spName",   person.SPName),
                new SqlParameter("@loginPwd", person.LoginPwd)
            };
            object res = SQLHelper.ExecuteScalar(procName, sp);

            if (res != null)
            {
                person.SalesPersonId = Convert.ToInt32(res);
            }
            else
            {
                person = null;
            }
            return(person);
        }
        public List <SelesPersonSModel> GetSales()
        {
            string procName = "GetAllTables";

            SqlParameter[] sp =
            {
                new SqlParameter("@tableName", "SalesPerson")
            };
            SqlDataReader            reader = SQLHelper.GetDataReader(procName, sp);
            List <SelesPersonSModel> list   = new List <SelesPersonSModel>();

            while (reader.Read())
            {
                SelesPersonSModel admins = new SelesPersonSModel();
                admins.SalesPersonId = Convert.ToInt32(reader["SalesPersonId"]);
                admins.LoginPwd      = Convert.ToInt32(reader["LoginPwd"].ToString());
                admins.SPName        = reader["SPName"].ToString();
                list.Add(admins);
            }
            reader.Close();
            return(list);
        }
Beispiel #9
0
 private void Source_CurrentChanged(object sender, EventArgs e)
 {
     Person = source.Current as SelesPersonSModel;
 }
        SuperMarketIDAL.前台SuperMarketCashier.ISelesPersonServer server = new SuperMarketDAL.前台SuperMarketCashier.SelesPersonServer();//SuperMarketDAL这个的方法DAL

        /// <summary>
        /// 收银员登录信息
        /// </summary>
        /// <param name="seles"></param>
        /// <returns></returns>
        public SelesPersonSModel SelesLogin(SelesPersonSModel seles)
        {
            return(server.SelesLogin(seles));
        }
Beispiel #11
0
 public SelesPersonSModel InsertSales(SelesPersonSModel person)
 {
     return(adminServer.InsertSales(person));
 }