예제 #1
0
 //点击登录
 protected void BtnLogin_Click(object sender, EventArgs e)
 {
     //判断输入是否为空
     if (tbName.Text == string.Empty && tbPwd.Text == string.Empty)
     {
         Response.Write("<script>alert('请输入用户名或密码!');</script>");
     }
     //用户输入不为空
     else
     {
         //判断输入的字符串是否匹配正则
         if (Regex.IsMatch(tbName.Text, "^[A-Za-z]{1,10}$"))
         {
             //调用查询方法
             if (BLLCustomer.BLLSelectCustomer(tbName.Text, tbPwd.Text))
             {
                 //存储该用户
                 MODCustomer Customer = new MODCustomer();
                 Session["CustomerName"] = Customer.UserID;
                 Response.Redirect("/load.aspx");
             }
             else
             {
                 //不存在该用户
                 Response.Write("<script>alert('用户名或密码错误');</script>");
             }
         }
         else
         {
             Response.Write("<script>alert('用户名或密码错误');</script>");
         }
     }
 }
예제 #2
0
 //新增用户
 public static bool DALInsertCustomer(MODCustomer customer)
 {
     string insertsql = string.Format("insert Customer(UserName,Login,Pwd,Address,Phone,Email) values('{0}','{1}','{2}','{3}','{4}','{5}')",customer.UserName,customer.Login,customer.Pwd,customer.Address,customer.Phone,customer.Email);
     //新增数据判断
     if (DBHelper.ExecuteNonQuery(insertsql))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
예제 #3
0
        //编辑之后更新事件
        protected void gvUser_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            MODCustomer customer = new MODCustomer();

            customer.UserID   = (int)gvUser.DataKeys[e.RowIndex].Value;
            customer.UserName = ((TextBox)(gvUser.Rows[e.RowIndex].Cells[2].Controls[0])).Text;
            customer.Login    = ((TextBox)(gvUser.Rows[e.RowIndex].Cells[3].Controls[0])).Text;
            customer.Pwd      = ((TextBox)(gvUser.Rows[e.RowIndex].Cells[4].Controls[0])).Text;
            customer.Address  = ((TextBox)(gvUser.Rows[e.RowIndex].Cells[5].Controls[0])).Text;
            customer.Phone    = ((TextBox)(gvUser.Rows[e.RowIndex].Cells[6].Controls[0])).Text;
            customer.Email    = ((TextBox)(gvUser.Rows[e.RowIndex].Cells[7].Controls[0])).Text;
            if (BLLCustomer.Uptade(customer))
            {
                gvUser.EditIndex = -1;
                Response.Write("<script>alert('修改成功')</script>");
                gvUser.DataSource = BLLCustomer.BLLSelectCustomerAll();
                gvUser.DataBind();
            }
        }
예제 #4
0
        //确认修改数据
        protected void Button1_Click1(object sender, EventArgs e)
        {
            //实例化数据类
            MODCustomer customer = new MODCustomer();

            customer.UserName = TextBox1.Text;
            customer.Login    = TextBox2.Text;
            customer.Pwd      = TextBox3.Text;
            customer.Address  = TextBox4.Text;
            customer.Phone    = TextBox5.Text;
            customer.Email    = TextBox6.Text;
            //调用新增方法
            if (BLLCustomer.BLLAddCustomer(customer))
            {
                Response.Write("<script>alert('新增成功')</script>");
                //刷新数据
                gvUser.DataSource = BLLCustomer.BLLSelectCustomerAll();
                gvUser.DataBind();
            }
            else
            {
                Response.Write("<script>alert('新增失败')</script>");
            }
        }
예제 #5
0
 //查询所有用户
 public static List<MODCustomer> DALSelectCustomerAll()
 {
     string selCustomerSql = string.Format("select * from Customer");
     DataTable dt = DBHelper.GetDataTable(selCustomerSql);
     
     //实例化泛型集合
     List<MODCustomer> listCustomer = new List<MODCustomer>();
     //模型类获取值
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         //实例化模型类
         MODCustomer customer = new MODCustomer();
         customer.UserID = int.Parse(dt.Rows[i][0].ToString());
         customer.UserName = dt.Rows[i][1].ToString();
         customer.Login = dt.Rows[i][2].ToString();
         customer.Pwd = dt.Rows[i][3].ToString();
         customer.Address = dt.Rows[i][4].ToString();
         customer.Phone = dt.Rows[i][5].ToString();
         customer.Email = dt.Rows[i][6].ToString();
         //填充
         listCustomer.Add(customer);
     }
     return listCustomer;
 }
예제 #6
0
 //新增用户
 public static bool BLLAddCustomer(MODCustomer customer)
 {
     return(DALCustomer.DALInsertCustomer(customer));
 }
예제 #7
0
 //编辑更新
 public static bool Uptade(MODCustomer modcustomer)
 {
     return(DALCustomer.Uptade(modcustomer));
 }
예제 #8
0
 //编辑更新
 public static bool Uptade(MODCustomer modcustomer)
 {
     string sql = string.Format("update Customer set  UserName='******',Login='******',Pwd='{2}',Address='{3}',Phone='{4}',Email='{5}'where UserID='{6}'"
         ,modcustomer.UserName, modcustomer.Login,modcustomer.Pwd,modcustomer.Address,modcustomer.Phone,modcustomer.Email,modcustomer.UserID);
     return DBHelper.ExecuteNonQuery(sql);
 }