当前位置: 首页>>代码示例>>C#>>正文


C# DataProvider.ExecuteProcQuery方法代码示例

本文整理汇总了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");
        }
开发者ID:nqtuan164,项目名称:dbQLBDS,代码行数:91,代码来源:DangNhapController.cs


注:本文中的DataProvider.ExecuteProcQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。