コード例 #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string username = this.txtUsername.Text;
            string password = this.txtPassword.Text;

            if (username != "" && password != "")
            {
                try
                {
                    DataRow dr;
                    dt        = us.login(username, password);
                    dr        = dt.Rows[0];
                    MyProfile = new Entity_User(dr);

                    MainForm frmMain = new MainForm();
                    this.Hide();
                    frmMain.Show();
                }
                catch
                {
                    MessageBox.Show("Sai tài khoản hoặc mật khẩu!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("Vui lòng điền đầy đủ thông tin!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #2
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            string userName = this.txtUsername.Text;
            string pass = this.txtPass.Text;
            string comfirm = this.txtComfirm.Text;
            string email = this.txtEmail.Text;
            string name = this.txtName.Text;
            DateTime dob = this.dtDoB.Value;
            bool gender = this.rdNam.Checked ? true : false;
            string sdt = this.txtPhone.Text;
            string address = this.txtAddress.Text;
            string role = this.cbbRole.SelectedValue.ToString();
            if (userName == "" || pass == "" || comfirm == "" || email == "" || name == "")
            {
                MessageBox.Show("Vui lòng điền đầy đủ thông tin!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (new EmailAddressAttribute().IsValid(email))
            {
                // check email exists
            }
            else
            {
                MessageBox.Show("E-mail nhập vào chưa chính xác!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (pass != comfirm)
            {
                MessageBox.Show("Vui lòng điền xác nhận lại mật khẩu!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtPass.Text = "";
                this.txtComfirm.Text = "";
                return;
            }

            int idUser = Utility.Instance.autoKey(gvUsers);

            Entity_User _us = new Entity_User(idUser, userName, email, pass, Int32.Parse(role), gender, dob, name, sdt, address);
            if (us.insertUser(_us) == true)
            {
                MessageBox.Show("Lưu thành công!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                gvUsers.DataSource = us.GetData();
                afterAdd();
            }
            else
            {
                MessageBox.Show("Không thể thêm!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #3
0
        private void setupView()
        {
            this.pnl = this.pnlProfile;

            Entity_User getUser = LoginForm.MyProfile;

            this.txtUsername.Text = getUser.Username;
            this.txtEmail.Text    = getUser.Email;
            this.txtName.Text     = getUser.FullName;

            BUS_ROLES rl = new BUS_ROLES();

            this.cbbQuyenHan.DataSource    = rl.GetData();
            this.cbbQuyenHan.DisplayMember = "ROLE_NAME";
            this.cbbQuyenHan.ValueMember   = "ROLE_ID";
            this.cbbQuyenHan.SelectedValue = getUser.Role;
            this.dtDob.Text      = getUser.Birthday.ToString();
            this.txtAddress.Text = getUser.Direction;
            this.txtPhone.Text   = getUser.Phone;
        }
コード例 #4
0
 public bool updateProfile(Entity_User _us)
 {
     try
     {
         const string strSQL  = "SP_UPDATE_PROFILE";
         string[]     pNames  = { "@id", "@email", "@sdt", "@pass", "@direction" };
         object[]     pValues = { _us.id, _us.Email, _us.Phone, _us.Pass, _us.Direction };
         int          count   = con.ExecuteStoredProcedure(strSQL, pNames, pValues);
         if (count >= 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         return(false);
     }
 }
コード例 #5
0
 public bool insertUser(Entity_User us)
 {
     try
     {
         string   strSQL  = "SP_REGISTER";
         string[] pNames  = { "@username", "@email", "@pass", "@role", "@gender", "@birthday", "@full_name", "@phone", "@direction" };
         object[] pValues = { us.Username, us.Email, us.Pass, us.Role, us.Gender, us.Birthday, us.FullName, us.Phone, us.Direction };
         int      count   = con.ExecuteStoredProcedure(strSQL, pNames, pValues);
         if (count >= 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         return(false);
     }
 }
コード例 #6
0
ファイル: BUS_Users.cs プロジェクト: ngocphuc1612/QLGara_2016
 public bool updateProfile(Entity_User _us)
 {
     return(us.updateProfile(_us));
 }
コード例 #7
0
ファイル: BUS_Users.cs プロジェクト: ngocphuc1612/QLGara_2016
 public bool insertUser(Entity_User _us)
 {
     return(us.insertUser(_us));
 }