Пример #1
0
        public bool KhachHang_Update(KhachHangObj data)
        {
            bool check = false;

            try
            {
                using (SqlCommand dbCmd = new SqlCommand("sp_KhachHang_Update", openConnection()))
                {
                    dbCmd.CommandType = CommandType.StoredProcedure;
                    dbCmd.Parameters.Add(new SqlParameter("@MaKH", data.MaKH));
                    dbCmd.Parameters.Add(new SqlParameter("@TenKH", data.TenKH));
                    dbCmd.Parameters.Add(new SqlParameter("@DiaChi", data.DiaChi));
                    dbCmd.Parameters.Add(new SqlParameter("@SDT", data.SDT));
                    int r = dbCmd.ExecuteNonQuery();
                    if (r > 0)
                    {
                        check = true;
                    }
                }
            }
            catch
            {
            }
            return(check);
        }
Пример #2
0
        public List <KhachHangObj> KhachHang_GetByTop(string Top, string Where, string Order)
        {
            List <KhachHangObj> list = new List <KhachHangObj>();

            using (SqlCommand dbCmd = new SqlCommand("sp_KhachHang_getByTop", openConnection()))
            {
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@Top", Top));
                dbCmd.Parameters.Add(new SqlParameter("@Where", Where));
                dbCmd.Parameters.Add(new SqlParameter("@Order", Order));
                SqlDataReader dr = dbCmd.ExecuteReader();
                dr.Close();
                dr = dbCmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        KhachHangObj obj = new KhachHangObj();
                        obj.KhachHangIDataReader(dr);
                        list.Add(obj);
                    }
                }
                dr.Close();
            }
            return(list);
        }