Ejemplo n.º 1
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            // Bắt lỗi nhập thông tin.
            try
            {
                if (txtUser.Text == "" || txtPass.Text == "" || txtRePass.Text == "" ||
                    txtHoTen.Text == "")
                {
                    throw new Exception("Bạn phải nhập đầy đủ thông tin!");
                }
                if (txtDiaChi.Text == "")
                {
                    txtDiaChi.Text = null;
                }
                if (txtEmail.Text == "")
                {
                    txtEmail.Text = null;
                }
                if (dateNgaySinh.Text == "")
                {
                    dateNgaySinh.Text = null;
                }
                if (txtSoDienThoai.Text == "")
                {
                    txtSoDienThoai.Text = null;
                }
                if (txtRePass.Text != txtPass.Text)
                {
                    throw new Exception("Mật khẩu xác nhận không đúng!");
                }
                if (!UserUtilizes.IsValidEmail(txtEmail.Text) && txtEmail.Text != "")
                {
                    throw new Exception("Hãy nhập một email hợp lệ");
                }

                if (!UserUtilizes.IsPhoneNumber(txtSoDienThoai.Text) && txtSoDienThoai.Text != "")
                {
                    throw new Exception("Hãy nhập vào số điện thoại đúng");
                }
                if (!UserUtilizes.IsValidDay(dateNgaySinh.DateTime.Date) && dateNgaySinh.Text != "")
                {
                    throw new Exception("Hãy nhập vào ngày sinh đúng");
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return;
            }

            //// Đăng kí tài khoản
            ///

            DangKy(txtUser.Text.ToLower(), txtPass.Text.ToLower(), txtHoTen.Text,
                   txtEmail.Text, txtSoDienThoai.Text, txtDiaChi.Text, dateNgaySinh.DateTime, comboBoxEditChucVu.Text);
        }
Ejemplo n.º 2
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (txtOldPass.Text == "" || txtNewPass.Text == "" || txtReNewPass.Text == "")
     {
         XtraMessageBox.Show("Bạn phải nhập đầy đủ thông tin!", "Error???");
     }
     else if (txtReNewPass.Text != txtNewPass.Text)
     {
         XtraMessageBox.Show("Mật khẩu xác nhận không đúng!", "Error???");
     }
     else if (Program.lg.UserLogin.MatKhau != UserUtilizes.GetHashString(txtOldPass.Text))
     {
         XtraMessageBox.Show("Mật khẩu cũ không đúng!", "Error???");
     }
     else
     {
         if (Program.ndSql.UpdatePass(Program.lg.UserLogin, UserUtilizes.GetHashString(txtNewPass.Text)) == true)
         {
             XtraMessageBox.Show("Đổi mật khẩu thành công!");
         }
     }
 }
Ejemplo n.º 3
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (luu == 1)
            {
                try
                {
                    if (txtTenNCC.Text == "" | txtDiachi.Text == "" | txtDienthoai.Text == "" | txtEmail.Text == "")
                    {
                        MessageBox.Show("Nhập đầy đủ thông tin sản phẩm.", "Lỗi");
                    }
                    if (!UserUtilizes.IsValidEmail(txtEmail.Text) && txtEmail.Text != "")
                    {
                        throw new Exception("Hãy nhập một email hợp lệ");
                    }

                    if (!UserUtilizes.IsPhoneNumber(txtDienthoai.Text) && txtDienthoai.Text != "")
                    {
                        throw new Exception("Hãy nhập vào số điện thoại đúng");
                    }
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.Message);
                    return;
                }

                ncc.Add(txtTenNCC.Text, txtDiachi.Text, txtDienthoai.Text, txtEmail.Text);
                MessageBox.Show("Thêm thành công");
                ncc.ViewAll();
                Start();
            }
            else if (luu == 2)
            {
                try
                {
                    if (txtTenNCC.Text == "" | txtDiachi.Text == "" | txtDienthoai.Text == "" | txtEmail.Text == "")
                    {
                        MessageBox.Show("Nhập đầy đủ thông tin nhà cung cấp.", "Lỗi");
                    }
                    if (!UserUtilizes.IsValidEmail(txtEmail.Text) && txtEmail.Text != "")
                    {
                        throw new Exception("Hãy nhập một email hợp lệ");
                    }

                    if (!UserUtilizes.IsPhoneNumber(txtDienthoai.Text) && txtDienthoai.Text != "")
                    {
                        throw new Exception("Hãy nhập vào số điện thoại đúng");
                    }
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.Message);
                    return;
                }

                ncc.Update(int.Parse(txtNCCID.Text), txtTenNCC.Text, txtDiachi.Text, txtDienthoai.Text, txtEmail.Text);
                MessageBox.Show("Sửa thành công");
                ncc.ViewAll();
                Start();
            }
        }