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


C# Users.CreateUsers方法代码示例

本文整理汇总了C#中Users.CreateUsers方法的典型用法代码示例。如果您正苦于以下问题:C# Users.CreateUsers方法的具体用法?C# Users.CreateUsers怎么用?C# Users.CreateUsers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Users的用法示例。


在下文中一共展示了Users.CreateUsers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ChangePassword

        //public ActionResult GoogleUser()
        //{
        //    // string txtEMailId = (string)this.RouteData.Values["id"].ToString();
        //    // return CheckUserLogin(txtEMailId, null);
        //    ViewBag.EMailId= Request.QueryString["id"].ToString();
        //    Response.Redirect("../Account/ForgotPassword");
        //    return null;
        //}
        public ActionResult ChangePassword(string txtNewPassword)
        {
            if (Request.Form["Cancel"] == null)
            {
                if (Session["User"] != null && !string.IsNullOrEmpty(txtNewPassword))
                {
                    user = (Users)Session["User"];
                    double dblUserID = 0;
                    SqlConnection LclConn = new SqlConnection();
                    SqlTransaction SetTransaction = null;
                    bool IsinTransaction = false;
                    if (LclConn.State != ConnectionState.Open)
                    {
                        user.SetConnection = user.OpenConnection(LclConn);
                        SetTransaction = LclConn.BeginTransaction(IsolationLevel.ReadCommitted);
                        IsinTransaction = true;
                    }
                    else
                    {
                        user.SetConnection = LclConn;
                    }
                    user.OptionID = 5;
                    user.Password = txtNewPassword;
                    user.ModifiedDateTime = DateTime.Now;
                    dblUserID = user.UserId;

                    bool result = user.CreateUsers(ref dblUserID, SetTransaction);
                    if (IsinTransaction && result)
                    {
                        SetTransaction.Commit();
                    }
                    else
                    {
                        SetTransaction.Rollback();
                    }

                    user.CloseConnection(LclConn);
                    //lblUserRegMsg.Visible = true;
                    ViewBag.Ack = "Password changed successfully";
                    //txtPassword.Text = "";
                    //txtConfirmPassword.Text = "";

                    ViewBag.OldPassword = txtNewPassword;
                }
                return View(user);
            }
            else
            {
                if (Session["User"] != null)
                {
                    user = (Users)Session["User"];
                }
                return View("../Account/ViewUser", user);
            }
        }
开发者ID:joinpramod,项目名称:MyBlogWebsiteMVC2015,代码行数:63,代码来源:AccountController.cs

示例2: CreateEditUser

        public ActionResult CreateEditUser(Users user, HttpPostedFileBase fileUserPhoto, string txtPassword)
        {
            string activationCode = Guid.NewGuid().ToString();
            //AddEdit user
            if (Request.Form["Cancel"] == null)
            {
                if (ModelState.IsValid)
                {
                    if (fileUserPhoto != null && fileUserPhoto.ContentLength > 1048576)
                    {
                        ViewBag.Ack = "Image file size should be less than 1 mb";
                        //return;
                    }
                    else
                    {
                        //try
                        //{
                        ConnManager con = new ConnManager();
                        DataSet dsUser = con.GetData("Select * from Users where Email = '" + user.Email + "'");
                        con.DisposeConn();
                        if (dsUser.Tables[0].Rows.Count > 0)
                        {
                            ViewBag.Ack = "EMail id already exists. If you have forgotten password, please click forgot password link on the Sign In page.";
                            return View("Users", user);
                        }

                        DataTable dtUserActivation = con.GetDataTable("select * from UserActivation where  Email = '" + user.Email + "'");
                        if (dtUserActivation.Rows.Count > 0)
                        {
                            ViewBag.lblAck = "User activation pending";
                            ViewBag.Activation = "Resend Activation Code?";
                            return View("../Account/Login");
                        }

                        double dblUserID = 0;
                        SqlConnection LclConn = new SqlConnection();
                        SqlTransaction SetTransaction = null;
                        bool IsinTransaction = false;
                        if (LclConn.State != ConnectionState.Open)
                        {
                            user.SetConnection = user.OpenConnection(LclConn);
                            SetTransaction = LclConn.BeginTransaction(IsolationLevel.ReadCommitted);
                            IsinTransaction = true;
                        }
                        else
                        {
                            user.SetConnection = LclConn;
                        }

                        if (fileUserPhoto != null && fileUserPhoto.FileName != "")
                        {
                            try
                            {
                                string fileName = System.IO.Path.GetFileNameWithoutExtension(fileUserPhoto.FileName);
                                string fileExt = System.IO.Path.GetExtension(fileUserPhoto.FileName);
                                string fullFileName = System.IO.Path.GetFileName(fileUserPhoto.FileName);

                                if (!System.IO.File.Exists(Server.MapPath("~\\Images\\") + fullFileName))
                                {
                                    fileUserPhoto.SaveAs(Server.MapPath("~\\Images\\") + fullFileName);
                                }
                                else
                                {
                                    fullFileName = fileName + DateTime.Now.ToString("HHmmss") + fileExt;
                                    while (System.IO.File.Exists(fullFileName))
                                    {
                                        fileName = fileName + DateTime.Now.ToString("HHmmss");
                                        fullFileName = fileName + fileExt;
                                    }
                                    fileUserPhoto.SaveAs(Server.MapPath("~\\Images\\") + fullFileName);
                                }
                                user.ImageURL = "~/Images/" + fullFileName;
                            }
                            catch (Exception ex)
                            {
                                //ViewBag.Ack = "Please try again";
                                user.ImageURL = "~/Images/Person.JPG";
                            }
                        }
                        else
                        {
                            user.ImageURL = "~/Images/Person.JPG";
                        }

                        user.OptionID = 1;
                        user.CreatedDateTime = DateTime.Now;
                        user.Password = txtPassword;

                        bool result = user.CreateUsers(ref dblUserID, SetTransaction);
                        if (IsinTransaction && result)
                        {
                            SetTransaction.Commit();
                        }
                        else
                        {
                            SetTransaction.Rollback();
                        }

                        using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCON"].ToString()))
                        {
//.........这里部分代码省略.........
开发者ID:joinpramod,项目名称:MyBlogWebsiteMVC2015,代码行数:101,代码来源:AccountController.cs

示例3: EditUser

        public ActionResult EditUser(Users user, HttpPostedFileBase fileUserPhoto)
        {
            //AddEdit user
            if (Request.Form["Cancel"] == null)
            {
                if (ModelState.IsValid)
                {
                    if (fileUserPhoto != null && fileUserPhoto.ContentLength > 1048576)
                    {
                        ViewBag.Ack = "Image file size should be less than 1 mb";
                        //return;
                    }
                    else
                    {
                        //try
                        //{
                            ConnManager con = new ConnManager();
                            DataSet dsUser = con.GetData("Select * from Users where Email = '" + user.Email + "'");
                            con.DisposeConn();
                            if (dsUser.Tables[0].Rows.Count > 0)
                            {
                                //if (Session["User"] == null)
                                //{
                                //    ViewBag.Ack = "EMail id already exists. If you have forgotten password, please click forgot password link on the Sign In page.";
                                //    //return;
                                //}
                                user.UserId = double.Parse(dsUser.Tables[0].Rows[0]["UserId"].ToString());
                            }

                            double dblUserID = 0;
                            SqlConnection LclConn = new SqlConnection();
                            SqlTransaction SetTransaction = null;
                            bool IsinTransaction = false;
                            if (LclConn.State != ConnectionState.Open)
                            {
                                user.SetConnection = user.OpenConnection(LclConn);
                                SetTransaction = LclConn.BeginTransaction(IsolationLevel.ReadCommitted);
                                IsinTransaction = true;
                            }
                            else
                            {
                                user.SetConnection = LclConn;
                            }

                            if (fileUserPhoto != null && fileUserPhoto.FileName != "")
                            {
                                try
                                {
                                    string fileName = System.IO.Path.GetFileNameWithoutExtension(fileUserPhoto.FileName);
                                    string fileExt = System.IO.Path.GetExtension(fileUserPhoto.FileName);
                                    string fullFileName = System.IO.Path.GetFileName(fileUserPhoto.FileName);

                                    if (!System.IO.File.Exists(Server.MapPath("~\\Images\\") + fullFileName))
                                    {
                                        fileUserPhoto.SaveAs(Server.MapPath("~\\Images\\") + fullFileName);
                                    }
                                    else
                                    {
                                        fullFileName = fileName + DateTime.Now.ToString("HHmmss") + fileExt;
                                        while (System.IO.File.Exists(fullFileName))
                                        {
                                            fileName = fileName + DateTime.Now.ToString("HHmmss");
                                            fullFileName = fileName + fileExt;
                                        }
                                        fileUserPhoto.SaveAs(Server.MapPath("~\\Images\\") + fullFileName);
                                    }
                                    user.ImageURL = "~/Images/" + fullFileName;
                                }
                                catch (Exception ex)
                                {
                                //ViewBag.Ack = "Please try again";
                                user.ImageURL = "~/Images/Person.JPG";
                            }
                                user.OptionID = 5;
                            }
                            else
                            {
                                user.OptionID = 7;
                                Users tempUser = new CodeAnalyzeMVC2015.Users();
                                tempUser = (Users)Session["User"];
                                user.ImageURL = tempUser.ImageURL;
                            }

                            user.ModifiedDateTime = DateTime.Now;
                            dblUserID = user.UserId;

                            bool result = user.CreateUsers(ref dblUserID, SetTransaction);
                            if (IsinTransaction && result)
                            {
                                SetTransaction.Commit();
                            }
                            else
                            {
                                SetTransaction.Rollback();
                            }
                            user.CloseConnection(LclConn);

                            ViewBag.Ack = "User Updated Successfully.";
                        //}
                        //catch
//.........这里部分代码省略.........
开发者ID:joinpramod,项目名称:MyBlogWebsiteMVC2015,代码行数:101,代码来源:AccountController.cs


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