示例#1
0
        // phuong thuc them user
        public bool AddUser(ClsUser us)
        {
            string        sql = "usp_AddUser";
            SqlConnection con = cndb.getConnect();

            try
            {
                con.Open();
                var cmd = new SqlCommand(sql, con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@username", SqlDbType.NVarChar).Value = us.Username;
                cmd.Parameters.Add("@password", SqlDbType.NVarChar).Value = us.password;
                cmd.Parameters.Add("@phone", SqlDbType.NVarChar).Value    = us.Phone;
                cmd.Parameters.Add("@address", SqlDbType.NVarChar).Value  = us.Address;


                cmd.ExecuteNonQuery();
                con.Close();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
示例#2
0
        private void btndeleteuser_Click(object sender, EventArgs e)
        {
            ClsUser us = new ClsUser();

            us.ID = ID;
            if (MessageBox.Show("Bạn có muốn chắc muốn xóa hay không?", "Cảnh Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                if (clsbill.DeleteUser(us))
                {
                    MessageBox.Show("Delete User thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    ShowAddUser();
                }
                else
                {
                    MessageBox.Show("Delete User không thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#3
0
 private void btnlogin_Click(object sender, EventArgs e)
 {
     if (CheckData())
     {
         ClsUser us = new ClsUser();
         us.Username = txtusername.Text;
         us.password = txtpassword.Text;
         if (clbill.LoginUser(us))
         {
             MessageBox.Show("Đăng Nhập Thành Công:", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             this.Hide();
             MainForm mf = new MainForm();
             mf.Show();
         }
         else
         {
             MessageBox.Show("Đăng Nhập Thất Bại:", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
示例#4
0
 private void btnadduser_Click(object sender, EventArgs e)
 {
     if (CheckData())
     {
         ClsUser us = new ClsUser();
         us.Username = txtusername.Text;
         us.password = txtpassword.Text;
         us.Phone    = txtphone.Text;
         us.Address  = txtaddress.Text;
         if (clsbill.AddUser(us))
         {
             MessageBox.Show("Thêm User thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             ShowAddUser();
         }
         else
         {
             MessageBox.Show("Thêm User không công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
示例#5
0
        // phuong thuc xoa user
        public bool DeleteUser(ClsUser us)
        {
            string        sql  = "usp_DeleteUser";
            SqlConnection conn = cndb.getConnect();

            try
            {
                conn.Open();
                var cmd = new SqlCommand(sql, conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@id", SqlDbType.Int).Value = us.ID;
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
示例#6
0
        public bool LoginUser(ClsUser us)
        {
            string        sql = "usp_LoginUser";
            SqlConnection con = cndb.getConnect();

            con.Open();
            var cmd = new SqlCommand(sql, con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@username", SqlDbType.NVarChar).Value = us.Username;
            cmd.Parameters.Add("@password", SqlDbType.NVarChar).Value = us.password;
            da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();

            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                return(true);
            }
            return(false);
        }
示例#7
0
 public bool LoginUser(ClsUser us)
 {
     return(clsdal.LoginUser(us));
 }
示例#8
0
 public bool RegisterUser(ClsUser us)
 {
     return(clsdal.RegisterUser(us));
 }
示例#9
0
 public bool DeleteUser(ClsUser us)
 {
     return(clsdal.DeleteUser(us));
 }
示例#10
0
 public bool UpdateUser(ClsUser us)
 {
     return(clsdal.UpdateUser(us));
 }
示例#11
0
 public bool AddUser(ClsUser us)
 {
     return(clsdal.AddUser(us));
 }