public KhachHang getby_tk_khachhang(string _tentaikhoan, ref string errMsg) { try { string sqlstr = "select * from khachhang where tendangnhap like N'" + _tentaikhoan + "'"; IDataReader dr = SQLExecute.getIDataReader(sqlstr, ref errMsg); KhachHang obj = new KhachHang(); obj = (KhachHang)CBO.FillObject(dr, typeof(KhachHang)); return obj; } catch (Exception ex) { throw ex; } }
public int save_khachhang(KhachHang vkhachhang, ref string errMsg) { try { errMsg = ""; int i = 0; int result = 0; SqlParameter[] prms = new SqlParameter[12]; prms[i] = new SqlParameter("@khachhangid", vkhachhang.MaKH); i = i + 1; prms[i] = new SqlParameter("@tendangnhap", vkhachhang.Tendangnhap); i = i + 1; prms[i] = new SqlParameter("@matkhau", vkhachhang.Matkhau); i = i + 1; prms[i] = new SqlParameter("@hoten", vkhachhang.Hoten); i = i + 1; prms[i] = new SqlParameter("@gioitinh", vkhachhang.Gioitinh); i = i + 1; prms[i] = new SqlParameter("@diachi", vkhachhang.Diachi); i = i + 1; prms[i] = new SqlParameter("@emai", vkhachhang.Email); i = i + 1; prms[i] = new SqlParameter("@sodienthoai", vkhachhang.Sodienthoai); i = i + 1; prms[i] = new SqlParameter("@laadmin", vkhachhang.Laadmin); i = i + 1; prms[i] = new SqlParameter("@trangthai", vkhachhang.Trangthai); i = i + 1; prms[i] = new SqlParameter("@outreturn", SqlDbType.Int, 1); prms[i].Direction = ParameterDirection.Output; result = SQLExecute.ExcuteSPOutput("dbo.sp_save_khachhang", ref prms, 11, ref errMsg, "@outreturn"); return result; } catch (Exception ex) { errMsg = ex.Message; return 0; } }