示例#1
0
        protected bool UpdateData()
        {
            bool result = false;

            try
            {
                User users = new User();
                users.UserId = new Guid(this.hdnUserId.Value);
                users.UserName = txtUserName.Text.Trim();
                users.FirstName = txtFirstName.Text.Trim();
                users.LastName = txtLastName.Text.Trim();
                users.EmailAddress = txtEmail.Text.Trim();
                users.Password = txtPassword.Text.Trim();
                users.UpdatedBy = Master.LoggedUser.UserId.Value;

                users.RoleId = new Guid(ddlRoles.Value.ToString());
                users.JobId = Convert.ToInt32(ddlJob.Value);
                users.LocationId = Convert.ToInt32(ddlLocation.Value);
                users.GradeId = Convert.ToInt32(ddlGrade.Value);

                if (users.Save())
                {
                    this.ClearFormData();
                }

            }
            catch (System.Exception)
            {

            }

            return result;
        }
示例#2
0
        protected bool SaveData()
        {
            bool result = false;

            try
            {
                User users = new User();

                ////Check for existing uername
                users.UserName = txtUserName.Text.Trim();

                if (!users.IsUserIsDuplicateUserName(users.UserName))
                {
                    users.EmailAddress = txtEmail.Text.Trim();

                    if (!users.IsDuplicateEmail(users.EmailAddress))
                    {
                        users.FirstName = txtFirstName.Text.Trim();
                        users.LastName = txtLastName.Text.Trim();

                        users.Password = txtPassword.Text.Trim();
                        users.RoleId = new Guid(ddlRoles.Value.ToString());
                        users.LocationId = Convert.ToInt32(ddlLocation.Value);
                        users.GradeId = Convert.ToInt32(ddlGrade.Value);
                        users.JobId = Convert.ToInt32(ddlJob.Value);
                        users.Contact = txtContact.Text.Trim();

                        users.CreatedBy = Master.LoggedUser.UserId.Value;

                        if (users.Save())
                        {
                            System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowSuccessMessage('" + Messages.Save_Success + "')", true);
                            this.ClearFormData();
                        }
                    }
                    else
                    {
                        System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowInfoMessage('" + Messages.Duplicate_Email + "')", true);
                    }
                }
                else
                {
                    System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowInfoMessage('" + Messages.Duplicate_Username + "')", true);
                }

            }
            catch (System.Exception)
            {

            }

            return result;
        }