コード例 #1
0
 protected void imgbtnThem_Click(object sender, ImageClickEventArgs e)
 {
     if (txtTenDangNhap.Text == "")
     {
         lblErrMatKhau.Visible = true;
     }
     else if (lblErrMatKhau.Text == "")
     {
         lblErrMatKhau.Visible = true;
     }
     else
     {
         //them moi chung loại san pham
         LinQtoSQLDataContext tam_context = new LinQtoSQLDataContext();
         Nguoi_Dung           obj         = new Nguoi_Dung
         {
             Ten_Nguoi_Dung = txtTenDangNhap.Text,
             Mat_Khau       = txtMatKhau.Text,
             Admin          = int.Parse(ddlAdmin.SelectedItem.Value),
             Ho_Ten         = txtHoTen.Text,
             Gioi_Tinh      = ddlGioiTinh.Text,
             Dia_Chi        = txtDiaChi.Text,
             CMND           = txtCMND.Text,
             Email          = txtEmail.Text,
             SDT            = txtSDT.Text,
         };
         tam_context.Nguoi_Dungs.InsertOnSubmit(obj);
         tam_context.SubmitChanges();
     }
     show_chungloai();
     show_chungloai1();
 }
コード例 #2
0
    protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        //TextBox txt_HoTen = GridView2.Rows[e.RowIndex].Cells[4].Controls[0] as TextBox;
        //DropDownList txt_GioiTinh = GridView2.Rows[e.RowIndex].Cells[5].Controls[0] as DropDownList;
        //TextBox txt_DiaChi = GridView2.Rows[e.RowIndex].Cells[6].Controls[0] as TextBox;
        //TextBox txt_CMND = GridView2.Rows[e.RowIndex].Cells[7].Controls[0] as TextBox;
        //TextBox txt_Email = GridView2.Rows[e.RowIndex].Cells[8].Controls[0] as TextBox;
        //TextBox txt_SDT = GridView2.Rows[e.RowIndex].Cells[9].Controls[0] as TextBox;

        TextBox      txt_HoTen    = GridView2.Rows[e.RowIndex].Cells[3].Controls[0] as TextBox;
        DropDownList ddl_GioiTinh = GridView2.Rows[e.RowIndex].FindControl("ddlGioiTinh") as DropDownList;
        TextBox      txt_DiaChi   = GridView2.Rows[e.RowIndex].Cells[5].Controls[0] as TextBox;
        TextBox      txt_CMND     = GridView2.Rows[e.RowIndex].Cells[6].Controls[0] as TextBox;
        TextBox      txt_Email    = GridView2.Rows[e.RowIndex].Cells[7].Controls[0] as TextBox;
        TextBox      txt_SDT      = GridView2.Rows[e.RowIndex].Cells[8].Controls[0] as TextBox;
        //chuan bi
        int Ma_Nguoi_Dung_dangsua        = (int)GridView2.DataKeys[e.RowIndex].Value;
        LinQtoSQLDataContext tam_context = new LinQtoSQLDataContext();
        Nguoi_Dung           obj         = tam_context.Nguoi_Dungs.SingleOrDefault(Nguoi_Dung => Nguoi_Dung.Ma_Nguoi_Dung == Ma_Nguoi_Dung_dangsua);

        obj.Ma_Nguoi_Dung = Ma_Nguoi_Dung_dangsua;
        obj.Ho_Ten        = txt_HoTen.Text;
        obj.Gioi_Tinh     = ddl_GioiTinh.SelectedItem.Value;
        obj.Dia_Chi       = txt_DiaChi.Text;
        obj.CMND          = txt_CMND.Text;
        obj.Email         = txt_Email.Text;
        obj.SDT           = txt_SDT.Text;
        //thuc hien
        tam_context.SubmitChanges();
        GridView2.EditIndex = -1;
        show_chungloai();
        show_chungloai1();
    }
コード例 #3
0
 public UserViewModel(Nguoi_Dung obj)
 {
     Email      = obj.Email;
     MatKhau    = obj.MatKhau;
     Ho_TenLot  = obj.Ho_TenLot;
     Ten        = obj.Ten;
     SDT        = obj.SDT;
     NoiLamViec = obj.NoiLamViec;
     ThanhPho   = obj.ThanhPho;
     HinhAnh    = obj.HinhAnh;
     Quyen      = obj.Quyen;
 }
コード例 #4
0
        public ActionResult Post_Register(FormCollection form)
        {
            string ho_tenlot = form["FirstName"];
            string ten       = form["LastName"];
            string email     = form["Email"];
            string matkhau   = form["Password"];
            string quyen     = "user";

            Nguoi_Dung user = new Nguoi_Dung()
            {
                Email     = email,
                MatKhau   = matkhau,
                Ho_TenLot = ho_tenlot,
                Ten       = ten,
                Quyen     = quyen
            };

            _db.Nguoi_Dungs.InsertOnSubmit(user);
            _db.SubmitChanges();

            return(RedirectToAction("Index", "Home"));
        }
コード例 #5
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int Ma_Nguoi_Dung_canxoa         = (int)GridView1.DataKeys[e.RowIndex].Value;
        LinQtoSQLDataContext tam_context = new LinQtoSQLDataContext();
        Nguoi_Dung           obj         = tam_context.Nguoi_Dungs.SingleOrDefault(Nguoi_Dung => Nguoi_Dung.Ma_Nguoi_Dung == Ma_Nguoi_Dung_canxoa);
        string    sql = "select * from Don_Dat_Hang where Ma_KH = " + Ma_Nguoi_Dung_canxoa;
        DataTable DDH = DataProvider.getData(sql);

        if (DDH.Rows.Count > 0)
        {
            for (int i = 0; i < DDH.Rows.Count; i++)
            {
                int    Ma_DDH         = int.Parse(DDH.Rows[i]["Ma_DDH"].ToString());
                string sqldeleteCTDDH = "delete from Chi_Tiet_DDH where Ma_DDH = " + Ma_DDH;
                DataProvider.runSQL(sqldeleteCTDDH);
            }
            string sqldeleteDDH = "delete from Don_Dat_Hang where Ma_KH = " + Ma_Nguoi_Dung_canxoa;
            DataProvider.runSQL(sqldeleteDDH);
        }
        tam_context.Nguoi_Dungs.DeleteOnSubmit(obj);
        tam_context.SubmitChanges();
        show_chungloai();
        show_chungloai1();
    }
コード例 #6
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        //tham chieu den các đối tượng tai dong hieu chinh hien tai
        // TextBox txt_MaNguoiDung = GridView1.Rows[e.RowIndex].Cells[0].Controls[0] as TextBox;
        Label        lblTenNguoiDung = GridView1.Rows[e.RowIndex].Cells[3].FindControl("lblTenNguoiDung") as Label;
        TextBox      txt_MatKhau     = GridView1.Rows[e.RowIndex].Cells[4].Controls[0] as TextBox;
        DropDownList ddlAdmin        = GridView1.Rows[e.RowIndex].FindControl("ddlAdmin") as DropDownList;

        //chuan bi
        int Ma_Nguoi_Dung_dangsua        = (int)GridView1.DataKeys[e.RowIndex].Value;
        LinQtoSQLDataContext tam_context = new LinQtoSQLDataContext();
        Nguoi_Dung           obj         = tam_context.Nguoi_Dungs.SingleOrDefault(Nguoi_Dung => Nguoi_Dung.Ma_Nguoi_Dung == Ma_Nguoi_Dung_dangsua);

        obj.Ma_Nguoi_Dung  = Ma_Nguoi_Dung_dangsua;
        obj.Ten_Nguoi_Dung = lblTenNguoiDung.Text;
        obj.Mat_Khau       = txt_MatKhau.Text;
        obj.Admin          = int.Parse(ddlAdmin.SelectedItem.Value);

        //thuc hien
        tam_context.SubmitChanges();
        GridView1.EditIndex = -1;
        show_chungloai();
        show_chungloai1();
    }
コード例 #7
0
    protected void imgbtnDangKy_Click(object sender, ImageClickEventArgs e)
    {
        string match = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
        Regex  reg   = new Regex(match);
        string email = txtEmail.Text;

        if (txtTenDangNhap.Text == "")
        {
            lblErrTenDangNhap_DangKy.Visible = true;
        }
        else if (txtMatKhau.Text == "")
        {
            lblErrMatKhauDK.Visible = true;
        }
        else if (txtXacNhanMK.Text != txtMatKhau.Text)
        {
            lblErrXacNhanMK.Visible = true;
        }
        else if (txtHoTen.Text == "")
        {
            lblErrTenKH.Visible = true;
        }
        else if (txtDiaChi.Text == "")
        {
            lblErrDiaChi.Visible = true;
        }
        else if (txtCMND.Text == "")
        {
            lblErrSoCMND.Visible = true;
        }
        else if (txtEmail.Text == "")
        {
            lblErrEmail.Visible = true;
        }
        else if (txtSDT.Text == "")
        {
            lblErrSDT.Visible = true;
        }
        else if (!reg.IsMatch(email))
        {
            lblErrEmail.Visible = true;
        }
        else
        {
            try
            {
                var qrkiemtra = from m in db.Nguoi_Dungs
                                where m.Ten_Nguoi_Dung == txtTenDangNhap.Text
                                select m;
                if (qrkiemtra.Count() == 0)
                {
                    Nguoi_Dung user = new Nguoi_Dung();
                    user.Admin          = 0;
                    user.Ten_Nguoi_Dung = txtTenDangNhap.Text;
                    user.Mat_Khau       = txtMatKhau.Text;
                    user.Ho_Ten         = txtHoTen.Text;
                    user.Gioi_Tinh      = ddlGioiTinh.SelectedItem.Value;
                    user.Dia_Chi        = txtDiaChi.Text;
                    user.CMND           = txtCMND.Text;
                    user.Email          = txtEmail.Text;
                    user.SDT            = txtSDT.Text;
                    db.Nguoi_Dungs.InsertOnSubmit(user);
                    db.SubmitChanges();
                    //Session["dangky"] = "1";
                    Response.Redirect("~/Thanh_Cong.aspx?capnhattt=&capnhatmk=&dangky=1&thanhtoan=");
                }
                else
                {
                    lbErr.Text = "Tên Đăng Nhập đã có người sử dụng";
                    //Session["dangky"] = "0";
                }
            }
            catch (Exception ex)
            {
                lbErr.Text = ex.Message;
            }
        }
    }