本文整理汇总了C#中DataProvider.ExecuteProcQuery方法的典型用法代码示例。如果您正苦于以下问题:C# DataProvider.ExecuteProcQuery方法的具体用法?C# DataProvider.ExecuteProcQuery怎么用?C# DataProvider.ExecuteProcQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataProvider
的用法示例。
在下文中一共展示了DataProvider.ExecuteProcQuery方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Index
public ActionResult Index(TaiKhoan taikhoan, string chkSuaLoi)
{
try
{
ViewBag.chkSuaLoi = chkSuaLoi;
if (taikhoan.Email != null && taikhoan.MatKhau != null)
{
DataProvider dp = new DataProvider();
using (MD5 md5hash = MD5.Create())
{
string hash = GetMd5Hash(md5hash, taikhoan.MatKhau);
taikhoan.MatKhau = hash;
}
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@email", SqlDbType.NVarChar);
param[0].Value = taikhoan.Email;
param[1] = new SqlParameter("@matkhau", SqlDbType.NVarChar);
param[1].Value = taikhoan.MatKhau;
DataTable dt = null;
if (chkSuaLoi != null)
{
//Set level = Repeatable Read để giải quyết Unrepeatable Read
dt = dp.ExecuteProcQuery("sp_DangNhapTaiKhoan_Fixed", ref param);
}
else
{
//Set level = ReadCommitted mức mặc định
dt = dp.ExecuteProcQuery("sp_DangNhapTaiKhoan", ref param);
}
if (dt.Rows.Count > 0)
{
ViewBag.Result = true;
ViewBag.ErrorMessage = "Đăng nhập thành công";
TaiKhoan tk = new TaiKhoan();
tk.MaTaiKhoan = (int)dt.Rows[0]["mataikhoan"];
tk.Email = (string)dt.Rows[0]["email"];
tk.Ten = (string)dt.Rows[0]["ten"];
if (dt.Rows[0]["ngaysinh"] != DBNull.Value) tk.NgaySinh = (DateTime)dt.Rows[0]["ngaysinh"];
if (dt.Rows[0]["diachi"] != DBNull.Value) tk.DiaChi = (string)dt.Rows[0]["diachi"];
if (dt.Rows[0]["dienthoai"] != DBNull.Value) tk.DienThoai = (string)dt.Rows[0]["dienthoai"];
tk.MaLoaiTaiKhoan = (int)dt.Rows[0]["maloaitaikhoan"];
switch (tk.MaLoaiTaiKhoan)
{
case 1:
tk.LoaiTaiKhoan = LoaiTaiKhoan.Admin;
Session.Add("taikhoan", tk);
return Redirect("/Admin/CanHo");
case 2:
tk.LoaiTaiKhoan = LoaiTaiKhoan.Member;
Session.Add("taikhoan", tk);
break;
case 3:
tk.LoaiTaiKhoan = LoaiTaiKhoan.Sales;
Session.Add("taikhoan", tk);
return Redirect("/Admin/");
};
switch ((int)dt.Rows[0]["trangthai"])
{
case 0:
tk.TrangThai = TrangThaiTaiKhoan.Deactive;
break;
case 1:
tk.TrangThai = TrangThaiTaiKhoan.Active;
break;
}
}
else
{
ViewBag.Result = false;
ViewBag.ErrorMessage = "Đăng nhập thất bại";
}
}
}
catch (Exception ex)
{
ViewBag.Result = false;
ViewBag.ErrorMessage = ex.Message;
}
return View("~/Views/Login/DangNhap.cshtml");
}