コード例 #1
0
        /// <summary>
        /// This method fires when the user clicks the Send Link button and it
        /// sends the user a reset password link via Email
        /// </summary>
        /// <param name="sender">The btnSendForgotLink DevEx button</param>
        /// <param name="e">The Click event</param>
        protected void btnSendForgotLink_Click(object sender, EventArgs e)
        {
            //Only continue if the page is valid
            if (ASPxEdit.AreEditorsValid(this, btnSendForgotLink.ValidationGroup))
            {
                // Validate the user's email address
                var         manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
                PyramidUser user    = manager.FindByName(txtUsername.Text);

                if (user == null || !manager.IsEmailConfirmed(user.Id))
                {
                    msgSys.ShowMessageToUser("warning", "Email Failure", "The user either does not exist or is not confirmed.", 25000);
                }
                else
                {
                    //Send the reset link to the user
                    string code        = manager.GeneratePasswordResetToken(user.Id);
                    string callbackUrl = IdentityHelper.GetResetPasswordRedirectUrl(code, Request);
                    manager.SendEmail(user.Id, "Reset your password", Utilities.GetEmailHTML(callbackUrl, "Reset Password", true, "Password Reset Requested", "Please reset your password by clicking the Reset Password link below.", Request));

                    //Show the email sent div and hide the forgot div
                    divEmailSent.Visible = true;
                    divForgot.Visible    = false;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// This method executes when the user clicks the send code button
        /// </summary>
        /// <param name="sender">The btnSendCode DevEx button</param>
        /// <param name="e">The Click event</param>
        protected void btnSendCode_Click(object sender, EventArgs e)
        {
            //Only continue if the validation is successful
            if (ASPxEdit.AreEditorsValid(this, btnSendCode.ValidationGroup))
            {
                //Try to send the two factor code
                if (!signinManager.SendTwoFactorCode(ddTwoFactorProviders.Value.ToString()))
                {
                    //Show an error message
                    msgSys.ShowMessageToUser("warning", "Transmission Failed", "Unable to send the two-factor code, please try again.", 25000);
                }

                //Get the user's verified ID
                string userID = signinManager.GetVerifiedUserId <PyramidUser, string>();

                //Get the user
                var user = manager.FindById(userID);
                if (user != null)
                {
                    //Generate the two factor token
                    var code = manager.GenerateTwoFactorToken(user.Id, ddTwoFactorProviders.Value.ToString());
                }

                //Hide the send code section and show the verify code section
                hfSelectedProvider.Value  = ddTwoFactorProviders.Value.ToString();
                divEnterCode.Visible      = true;
                divChooseProvider.Visible = false;

                //Tell the user that the code sent
                msgSys.ShowMessageToUser("success", "Code Sent", "Two-Factor code successfully sent!", 5000);
            }
        }
コード例 #3
0
        public void action()
        {
            switch (ACTION)
            {
            case "Add":
                resetForm();
                initializeInsertingMode();
                break;

            case "Edit":
                resetForm();
                loadForm();
                break;

            case "Save":
                if (!ASPxEdit.AreEditorsValid(popup_PersonEdit))
                {
                    return;
                }
                collectData();
                updatePerson(currentPerson);
                popup_PersonEdit.ShowOnPageLoad = false;
                grdEmailList.UpdateEdit();
                break;

            case "ActivateForm":
                setEnableForForm(true);
                break;

            default:
                break;
            }
        }
コード例 #4
0
 protected void ASPxButton1_Click(object sender, EventArgs e)
 {
     if (ASPxEdit.AreEditorsValid(this, "vgNewTask"))
     {
         ASPxLabel1.Visible = true;
     }
 }
コード例 #5
0
        /// <summary>
        /// This method executes when the user clicks the save button for the cohorts
        /// and it saves the cohort information to the database
        /// </summary>
        /// <param name="sender">The submitCohort control</param>
        /// <param name="e">The Click event</param>
        protected void submitCohort_Click(object sender, EventArgs e)
        {
            if (ASPxEdit.AreEditorsValid(this, submitCohort.ValidationGroup))
            {
                //Get the cohort information
                int      cohortPK   = Convert.ToInt32(hfAddEditCohortPK.Value);
                string   cohortName = txtCohortName.Value.ToString();
                DateTime startDate  = Convert.ToDateTime(deCohortStartDate.Value);
                DateTime?endDate    = (String.IsNullOrWhiteSpace(deCohortEndDate.Value.ToString()) ? (DateTime?)null : Convert.ToDateTime(deCohortEndDate.Value));

                using (PyramidContext context = new PyramidContext())
                {
                    Cohort currentCohort;
                    //Check to see if this is an add or an edit
                    if (cohortPK == 0)
                    {
                        //Add
                        currentCohort            = new Cohort();
                        currentCohort.CohortName = cohortName;
                        currentCohort.StartDate  = startDate;
                        currentCohort.EndDate    = endDate;
                        currentCohort.StateFK    = Convert.ToInt32(ddCohortState.Value);
                        currentCohort.CreateDate = DateTime.Now;
                        currentCohort.Creator    = User.Identity.Name;

                        //Save to the database
                        context.Cohort.Add(currentCohort);
                        context.SaveChanges();

                        //Show a success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully added cohort!", 10000);
                    }
                    else
                    {
                        //Edit
                        currentCohort            = context.Cohort.Find(cohortPK);
                        currentCohort.CohortName = cohortName;
                        currentCohort.StartDate  = startDate;
                        currentCohort.EndDate    = endDate;
                        currentCohort.StateFK    = Convert.ToInt32(ddCohortState.Value);
                        currentCohort.EditDate   = DateTime.Now;
                        currentCohort.Editor     = User.Identity.Name;

                        //Save to the database
                        context.SaveChanges();

                        //Show a success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully edited cohort!", 10000);
                    }

                    //Reset the values in the hidden field and hide the div
                    hfAddEditCohortPK.Value  = "0";
                    divAddEditCohort.Visible = false;

                    //Re-bind the cohort controls
                    BindCohorts();
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// This method executes when the user clicks the verify button in
        /// the verify code section and it attempts to log the user in with
        /// the code they entered
        /// </summary>
        /// <param name="sender">The btnVerifyCode DevEx button</param>
        /// <param name="e">The Click event</param>
        protected void btnVerifyCode_Click(object sender, EventArgs e)
        {
            //Only continue if the validation is successful
            if (ASPxEdit.AreEditorsValid(this, btnVerifyCode.ValidationGroup))
            {
                //Try to sign the user in
                var result = signinManager.TwoFactorSignIn <PyramidUser, string>(hfSelectedProvider.Value, txtCode.Text, isPersistent: false, rememberBrowser: chkRememberBrowser.Checked);
                switch (result)
                {
                case SignInStatus.Success:
                    //Get the user ID
                    string userID = signinManager.GetVerifiedUserId <PyramidUser, string>();

                    //Get the user
                    var user = manager.FindById(userID);

                    //Get the user's program roles
                    List <UserProgramRole> userProgramRoles;
                    using (PyramidContext context = new PyramidContext())
                    {
                        userProgramRoles = context.UserProgramRole.Where(upr => upr.Username == user.UserName).ToList();
                    }

                    //Redirect the user based on the number of roles they have
                    if (userProgramRoles.Count > 1)
                    {
                        //Redirect the user to the select role page
                        Response.Redirect(String.Format("/Account/SelectRole.aspx?ReturnUrl={0}&message={1}",
                                                        (Request.QueryString["ReturnUrl"] != null ? Request.QueryString["ReturnUrl"].ToString() : "/Default.aspx"),
                                                        "TwoFactorVerified"));
                    }
                    else
                    {
                        //Get the UserProgramRole
                        UserProgramRole programRole = userProgramRoles.FirstOrDefault();

                        //Set the session variables
                        Session["CodeProgramRoleFK"] = programRole.CodeProgramRole.CodeProgramRolePK;
                        Session["ProgramRoleName"]   = programRole.CodeProgramRole.RoleName;
                        Session["ProgramFK"]         = programRole.ProgramFK;
                        Session["ProgramName"]       = programRole.Program.ProgramName;

                        //Redirect the user
                        Response.Redirect(Request.QueryString["ReturnUrl"] != null ? Request.QueryString["ReturnUrl"].ToString() : "/Default.aspx?message=TwoFactorVerified");
                    }
                    break;

                case SignInStatus.LockedOut:
                    Response.Redirect("/Account/Lockout");
                    break;

                case SignInStatus.Failure:
                default:
                    msgSys.ShowMessageToUser("danger", "Invalid Code", "The code you entered is invalid!", 25000);
                    break;
                }
            }
        }
コード例 #7
0
ファイル: uPopupUserCreating.ascx.cs プロジェクト: ewin66/dev
        public bool PersonEditing_PreTransitionCRUD(string transition)
        {
            switch (transition)
            {
            case "Save":
                if (!ASPxEdit.AreEditorsValid(popup_PersonCreate))
                {
                    return(false);
                }
                Person person = session.GetObjectByKey <Person>(PersonId);
                {
                    person.Code      = txt_Code.Text;
                    person.Name      = txt_Name.Text;
                    person.RowStatus = Convert.ToInt16(Combo_RowStatus.SelectedItem.Value);
                };
                person.Save();

                var statementLoginAccounts = from la in person.LoginAccounts
                                             where la.RowStatus > 0 &&
                                             la.PersonId == person
                                             select la.LoginAccountId;

                foreach (TMPLoginAccount tmpAccount in Temp_LoginAccount)
                {
                    LoginAccount account;
                    if (statementLoginAccounts.Contains(tmpAccount.LoginAccountId))
                    {
                        account           = session.GetObjectByKey <LoginAccount>(tmpAccount.LoginAccountId);
                        account.Email     = tmpAccount.Email;
                        account.RowStatus = Utility.Constant.ROWSTATUS_ACTIVE;
                        account.Save();
                    }
                    else
                    {
                        account = new LoginAccount(session);
                        account.LoginAccountId       = Guid.NewGuid();
                        account.Email                = tmpAccount.Email;
                        account.RowStatus            = Utility.Constant.ROWSTATUS_ACTIVE;
                        account.RowCreationTimeStamp = DateTime.Now;
                        account.PersonId             = person;
                        account.Save();
                    }
                }

                // update Department
                List <TreeListNode> nodes = ASPxTreeList_OfDepartment.GetSelectedNodes();
                List <NAS.DAL.Nomenclature.Organization.Department> departmentList = new List <NAS.DAL.Nomenclature.Organization.Department>();
                foreach (TreeListNode n in nodes)
                {
                    NAS.DAL.Nomenclature.Organization.Department d = (NAS.DAL.Nomenclature.Organization.Department)n.DataItem;
                    departmentList.Add(d);
                }
                DepartmentBO bo = new DepartmentBO();
                bo.updatePerson(session, departmentList, PersonId, person.Code, person.Name, person.RowStatus);
                return(true);
            }
            return(false);
        }
コード例 #8
0
ファイル: uUnitEdit.ascx.method.cs プロジェクト: ewin66/dev
        public void Action()
        {
            switch (ACTION)
            {
            case "Add":
                resetForm();
                initializeInsertingMode();
                setEnableForForm(true);
                break;

            case "Edit":
                resetForm();
                loadForm();
                setEnableForForm(false);
                break;

            case "Delete":
                if (unitBO.checkIsExistInItemUnit(session, UnitId))
                {
                    throw new Exception("Quy cách này đã được sử dụng trong cấu hình hàng hóa nên không thể xóa!");
                }

                collectData();
                currentUnit.RowStatus = -1;
                UnitEdittingXDS.Session.Save(currentUnit);
                break;

            case "Save":
                ///Issue ERP-956-START
                if (MODE.Equals("Edit"))
                {
                    if (unitBO.checkIsExistInItemUnit(session, UnitId))
                    {
                        throw new Exception("Quy cách này đã được sử dụng trong cấu hình hàng hóa nên không thể sửa!");
                    }
                }
                ///Issue ERP-956-END
                if (!ASPxEdit.AreEditorsValid(pcUnit))
                {
                    return;
                }
                collectData();
                UnitEdittingXDS.Session.Save(currentUnit);
                resetForm();
                formUnitEdit.ShowOnPageLoad = false;
                break;

            case "ActivateForm":
                setEnableForForm(true);
                break;

            default:
                break;
            }
        }
コード例 #9
0
 protected void SubmitButton_Click(object sender, EventArgs e)
 {
     if (ASPxEdit.AreEditorsValid(Page))
     {
         UpdateStatusLabel.Text = string.Format("Submitted value: {0}", ComboBoxInStrictMode.Value);
     }
     else
     {
         UpdateStatusLabel.Text = "Editors are not valid!";
     }
 }
コード例 #10
0
        /// <summary>
        /// This method executes when the user clicks the save button for the hubs
        /// and it saves the hub information to the database
        /// </summary>
        /// <param name="sender">The submitHub control</param>
        /// <param name="e">The Click event</param>
        protected void submitHub_Click(object sender, EventArgs e)
        {
            if (ASPxEdit.AreEditorsValid(this, submitHub.ValidationGroup))
            {
                //Get the hub PK and name
                int    hubPK   = Convert.ToInt32(hfAddEditHubPK.Value);
                string hubName = txtHubName.Value.ToString();

                using (PyramidContext context = new PyramidContext())
                {
                    Hub currentHub;
                    //Check to see if this is an add or an edit
                    if (hubPK == 0)
                    {
                        //Add
                        currentHub            = new Hub();
                        currentHub.Name       = hubName;
                        currentHub.StateFK    = Convert.ToInt32(ddHubState.Value);
                        currentHub.CreateDate = DateTime.Now;
                        currentHub.Creator    = User.Identity.Name;

                        //Save to the database
                        context.Hub.Add(currentHub);
                        context.SaveChanges();

                        //Show a success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully added hub!", 10000);
                    }
                    else
                    {
                        //Edit
                        currentHub          = context.Hub.Find(hubPK);
                        currentHub.Name     = hubName;
                        currentHub.StateFK  = Convert.ToInt32(ddHubState.Value);
                        currentHub.EditDate = DateTime.Now;
                        currentHub.Editor   = User.Identity.Name;

                        //Save to the database
                        context.SaveChanges();

                        //Show a success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully edited hub!", 10000);
                    }

                    //Reset the values
                    hfAddEditHubPK.Value  = "0";
                    divAddEditHub.Visible = false;

                    //Bind the hub controls
                    BindHubs();
                }
            }
        }
コード例 #11
0
        protected void StandardButton_Click(object sender, EventArgs e)
        {
            ASPxEdit.ValidateEditorsInContainer(Page); // Required only for a standard button

            if (ASPxEdit.AreEditorsValid(Page))
            {
                UpdateStatusLabel.Text = string.Format("Submitted value: {0}", spinEdit.Value);
            }
            else
            {
                UpdateStatusLabel.Text = "Editors are not valid!";
            }
        }
コード例 #12
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (ASPxEdit.AreEditorsValid(FormPanel))
        {
            // TODO: Write data to database
            FormPanel.Visible    = false;
            SuccessPanel.Visible = true;
            btnAgain.Focus();

            // Intentionally pauses server-side processing, to demonstrate the Loading Panel functionality.
            Thread.Sleep(2000);
        }
    }
コード例 #13
0
ファイル: uPopupUserCreating.ascx.cs プロジェクト: ewin66/dev
        public bool PersonCreating_PreTransitionCRUD(string transition)
        {
            switch (transition)
            {
            case "Save":
                //session.BeginTransaction();
                if (!ASPxEdit.AreEditorsValid(popup_PersonCreate))
                {
                    return(false);
                }
                Person person = new Person(session)
                {
                    PersonId             = Guid.NewGuid(),
                    Code                 = txt_Code.Text,
                    Name                 = txt_Name.Text,
                    RowCreationTimeStamp = DateTime.Now,
                    RowStatus            = Utility.Constant.ROWSTATUS_ACTIVE
                };
                person.Save();

                foreach (TMPLoginAccount tmpAccount in Temp_LoginAccount)
                {
                    LoginAccount account = new LoginAccount(session);
                    //account.LoginAccountId = Guid.NewGuid();
                    account.Email                = tmpAccount.Email;
                    account.RowStatus            = Utility.Constant.ROWSTATUS_ACTIVE;
                    account.RowCreationTimeStamp = DateTime.Now;
                    account.PersonId             = person;
                    account.Save();
                }

                foreach (TreeListNode node in ASPxTreeList_OfDepartment.GetSelectedNodes())
                {
                    DepartmentPerson dp = new DepartmentPerson(session)
                    {
                        DepartmentId         = session.GetObjectByKey <NAS.DAL.Nomenclature.Organization.Department>(Guid.Parse(node.Key)),
                        DepartmentPersonId   = Guid.NewGuid(),
                        RowCreationTimeStamp = DateTime.Now,
                        PersonId             = person,
                        RowStatus            = Utility.Constant.ROWSTATUS_ACTIVE
                    };
                    dp.Save();
                }

                PersonId = person.PersonId;
                //session.CommitTransaction();
                return(true);
            }
            return(false);
        }
コード例 #14
0
        /// <summary>
        /// This method returns the Classroom object filled with information from
        /// the inputs in this control so that the content page can interact with it
        /// </summary>
        /// <returns>The filled Classroom object if validation succeeds, null otherwise</returns>
        public Models.Classroom GetClassroom()
        {
            if (ASPxEdit.AreEditorsValid(this, ValidationGroup))
            {
                //Get the classroom pk
                int classroomPK = Convert.ToInt32(hfClassroomPK.Value);

                //Get the program fk
                int programFK = Convert.ToInt32(hfProgramFK.Value);

                //To hold the classroom object
                Models.Classroom classroom;

                //Determine if the classroom already exists
                if (classroomPK > 0)
                {
                    using (PyramidContext context = new PyramidContext())
                    {
                        classroom = context.Classroom.AsNoTracking().Where(c => c.ClassroomPK == classroomPK).FirstOrDefault();
                    }
                }
                else
                {
                    classroom = new Models.Classroom();
                }

                //Set the values from the inputs
                classroom.Name = txtName.Value.ToString();
                classroom.ProgramSpecificID     = txtProgramID.Value.ToString();
                classroom.Location              = (txtLocation.Value == null ? null : txtLocation.Value.ToString());
                classroom.IsInfantToddler       = Convert.ToBoolean(ddInfantToddler.Value);
                classroom.IsPreschool           = Convert.ToBoolean(ddPreschool.Value);
                classroom.BeingServedSubstitute = Convert.ToBoolean(ddServedSubstitute.Value);
                classroom.ProgramFK             = programFK;

                //Return the object
                return(classroom);
            }
            else
            {
                if (String.IsNullOrWhiteSpace(ValidationMessageToDisplay))
                {
                    ValidationMessageToDisplay = "Validation failed, see above for details!";
                }
                return(null);
            }
        }
コード例 #15
0
ファイル: Child.ascx.cs プロジェクト: CHSR/PyramidModelWebApp
        /// <summary>
        /// This method returns the ChildProgram object filled with information from
        /// the inputs in this control so that the content page can interact with it
        /// </summary>
        /// <returns>The filled ChildProgram object if validation succeeds, null otherwise</returns>
        public Models.ChildProgram GetChildProgram()
        {
            if (ASPxEdit.AreEditorsValid(this, ValidationGroup))
            {
                //Get the ChildProgram pk
                int childProgramPK = Convert.ToInt32(hfChildProgramPK.Value);

                //To hold the ChildProgram object
                Models.ChildProgram childProgram;

                //Determine if the object already exists
                if (childProgramPK > 0)
                {
                    using (PyramidContext context = new PyramidContext())
                    {
                        childProgram = context.ChildProgram.AsNoTracking().Where(cp => cp.ChildProgramPK == childProgramPK).FirstOrDefault();
                    }
                }
                else
                {
                    childProgram = new Models.ChildProgram();
                }

                //Set the values
                childProgram.ProgramFK              = Convert.ToInt32(hfProgramFK.Value);
                childProgram.EnrollmentDate         = Convert.ToDateTime(deEnrollmentDate.Value);
                childProgram.DischargeDate          = (deDischargeDate.Value == null ? (DateTime?)null : Convert.ToDateTime(deDischargeDate.Value));
                childProgram.DischargeCodeFK        = (ddDischargeReason.Value == null ? (int?)null : Convert.ToInt32(ddDischargeReason.Value));
                childProgram.DischargeReasonSpecify = (txtDischargeReasonSpecify.Value == null ? null : txtDischargeReasonSpecify.Value.ToString());
                childProgram.ProgramSpecificID      = txtProgramID.Value.ToString();
                childProgram.HasIEP = Convert.ToBoolean(ddIEP.Value);
                childProgram.IsDLL  = Convert.ToBoolean(ddDLL.Value);

                //Return the object
                return(childProgram);
            }
            else
            {
                if (String.IsNullOrWhiteSpace(ValidationMessageToDisplay))
                {
                    ValidationMessageToDisplay = "Validation failed, see above for details!";
                }
                return(null);
            }
        }
コード例 #16
0
ファイル: Child.ascx.cs プロジェクト: CHSR/PyramidModelWebApp
        /// <summary>
        /// This method returns the Child object filled with information from
        /// the inputs in this control so that the content page can interact with it
        /// </summary>
        /// <returns>The filled Child object if validation succeeds, null otherwise</returns>
        public Models.Child GetChild()
        {
            if (ASPxEdit.AreEditorsValid(this, ValidationGroup))
            {
                //Get the child pk
                int childPK = Convert.ToInt32(hfChildPK.Value);

                //To hold the child object
                Models.Child child;

                //Determine if the child already exists
                if (childPK > 0)
                {
                    using (PyramidContext context = new PyramidContext())
                    {
                        child = context.Child.AsNoTracking().Where(c => c.ChildPK == childPK).FirstOrDefault();
                    }
                }
                else
                {
                    child = new Models.Child();
                }

                //Set the values from the inputs
                child.FirstName       = txtFirstName.Value.ToString();
                child.LastName        = txtLastName.Value.ToString();
                child.BirthDate       = Convert.ToDateTime(deDOB.Value);
                child.GenderCodeFK    = Convert.ToInt32(ddGender.Value);
                child.EthnicityCodeFK = Convert.ToInt32(ddEthnicity.Value);
                child.RaceCodeFK      = Convert.ToInt32(ddRace.Value);

                //Return the object
                return(child);
            }
            else
            {
                if (String.IsNullOrWhiteSpace(ValidationMessageToDisplay))
                {
                    ValidationMessageToDisplay = "Validation failed, see above for details!";
                }
                return(null);
            }
        }
コード例 #17
0
        /// <summary>
        /// When the user clicks the Save button in the Change Password modal, set the user's password
        /// </summary>
        /// <param name="sender">The btnSavePassword DevExpress Button</param>
        /// <param name="e">The Click event</param>
        protected void btnSavePassword_Click(object sender, EventArgs e)
        {
            //Only continue if the validation group is valid
            if (ASPxEdit.AreEditorsValid(this, btnSavePassword.ValidationGroup))
            {
                //Change the user's password and get the result
                string         resetToken = manager.GeneratePasswordResetToken(currentUser.Id);
                IdentityResult result     = manager.ResetPassword(currentUser.Id, resetToken, Convert.ToString(txtPassword.Value));

                //Show the user a message depending on if the password change succeeded or not
                if (result.Succeeded)
                {
                    msgSys.ShowMessageToUser("success", "Success", "Password successfully updated!", 10000);
                }
                else
                {
                    msgSys.ShowMessageToUser("danger", "Error", result.Errors.FirstOrDefault(), 120000);
                }
            }
        }
コード例 #18
0
 /// <summary>
 /// This is the standard click event for the submit button and
 /// it ensures that the page is valid before calling the method
 /// that was assigned to its event handler
 /// </summary>
 /// <param name="sender">The btnSubmit DevExpress button</param>
 /// <param name="e">The Click event</param>
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     //Only call the assigned event if the validation group is valid
     if (ASPxEdit.AreEditorsValid(this.Page, ValidationGroup))
     {
         //Call the submit method
         if (this.SubmitClick != null)
         {
             this.SubmitClick(sender, e);
         }
     }
     else
     {
         //Call the validation failed method
         if (this.ValidationFailed != null)
         {
             this.ValidationFailed(sender, e);
         }
     }
 }
コード例 #19
0
ファイル: uPopupOrganization.ascx.cs プロジェクト: ewin66/dev
 public bool OrganizationEditting_PreTransitionCRUD(string transition)
 {
     switch (transition)
     {
     case "Save":
         if (!ASPxEdit.AreEditorsValid(popup_Organization))
         {
             return(false);
         }
         // Update data
         NAS.DAL.Nomenclature.Organization.Organization org = session.GetObjectByKey <NAS.DAL.Nomenclature.Organization.Organization>(OrganizationId);
         //org.Name = txt_TenTo
         //Chuc.Text;
         org.Code        = txt_MaToChuc.Text;
         org.TaxNumber   = txt_MaSoThue.Text;
         org.Address     = txt_DiaChi.Text;
         org.Description = txt_MoTa.Text;
         session.Save(org);
         break;
     }
     return(true);
 }
コード例 #20
0
        /// <summary>
        /// This method fires when the user clicks the Add Role button and
        /// it adds the selected Program Role to the user
        /// </summary>
        /// <param name="sender">The btnAddRole DevExpress Bootstrap button</param>
        /// <param name="e">The Click event</param>
        protected void btnAddRole_Click(object sender, EventArgs e)
        {
            //Only continue if the page is valid
            if (ASPxEdit.AreEditorsValid(this, btnAddRole.ValidationGroup))
            {
                int programRoleFK, programFK;

                //Get the program role fk and program fk
                programRoleFK = Convert.ToInt32(ddProgramRole.Value);
                programFK     = Convert.ToInt32(ddProgram.Value);

                //Create the object and fill it
                UserProgramRole newUpr = new UserProgramRole();
                newUpr.Creator           = User.Identity.Name;
                newUpr.CreateDate        = DateTime.Now;
                newUpr.ProgramFK         = programFK;
                newUpr.Username          = currentUser.UserName;
                newUpr.ProgramRoleCodeFK = programRoleFK;

                //Add the object to the database
                using (PyramidContext context = new PyramidContext())
                {
                    //Add the role
                    context.UserProgramRole.Add(newUpr);
                    context.SaveChanges();

                    //Show the changes
                    BindUserProgramRoles(context, currentUser);
                }

                //Clear the inputs
                ddProgramRole.Value = "";
                ddProgram.Value     = "";

                //Show a success message
                msgSys.ShowMessageToUser("success", "Success", "Successfully added program role to user!", 10000);
            }
        }
コード例 #21
0
        /// <summary>
        /// This method fires when the user clicks the Save Changes button
        /// and it changes the user's password
        /// </summary>
        /// <param name="sender">The btnChangePassword DevExpress button</param>
        /// <param name="e">The Click event</param>
        protected void btnChangePassword_Click(object sender, EventArgs e)
        {
            //Only change the password if the validation succeeds
            if (ASPxEdit.AreEditorsValid(this, btnChangePassword.ValidationGroup))
            {
                //Get the user manager and sign in manager
                var manager       = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
                var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>();

                //Change the password and get the result
                IdentityResult result = manager.ChangePassword(User.Identity.GetUserId(), txtCurrentPassword.Text, txtNewPassword.Text);
                if (result.Succeeded)
                {
                    //Redirect the user back to the Manage page on success
                    Response.Redirect("~/Account/Manage?m=ChangePwdSuccess");
                }
                else
                {
                    //Show the user why the change failed
                    msgSys.ShowMessageToUser("danger", "Error", result.Errors.FirstOrDefault(), 120000);
                }
            }
        }
コード例 #22
0
ファイル: uPopupOrganization.ascx.cs プロジェクト: ewin66/dev
        public bool OrganizationCreating_PreTransitionCRUD(string transition)
        {
            switch (transition)
            {
            case "Save":
                if (!ASPxEdit.AreEditorsValid(popup_Organization))
                {
                    return(false);
                }
                // Insert data
                NAS.DAL.Nomenclature.Organization.Organization org = new NAS.DAL.Nomenclature.Organization.Organization(session)
                {
                    OrganizationId       = Guid.NewGuid(),
                    Name                 = txt_TenToChuc.Text,
                    Code                 = txt_MaToChuc.Text,
                    Address              = txt_DiaChi.Text,
                    TaxNumber            = txt_MaSoThue.Text,
                    Description          = txt_MoTa.Text,
                    RowCreationTimeStamp = DateTime.Now,
                    RowStatus            = Utility.Constant.ROWSTATUS_ACTIVE
                };

                org.OrganizationTypeId   = Util.getXPCollection <OrganizationType>(session, "Name", OrganizationTypeConstant.NAAN_CUSTOMER_SUB_ORGANIZATION.Value).FirstOrDefault();
                org.ParentOrganizationId = Util.getXPCollection <NAS.DAL.Nomenclature.Organization.Organization>(session, "OrganizationId", ParentOrganizationId).FirstOrDefault();
                if (org.ParentOrganizationId == null)
                {
                    NAS.DAL.Nomenclature.Organization.Organization Rootorg = session.FindObject <NAS.DAL.Nomenclature.Organization.Organization>(
                        new BinaryOperator("Code", "QUASAPHARCO", BinaryOperatorType.Equal));
                    org.ParentOrganizationId = Rootorg;
                }
                session.Save(org);

                OrganizationId = org.OrganizationId;
                return(true);
            }
            return(false);
        }
コード例 #23
0
        /// <summary>
        /// This method fires when the user clicks the Verify Code button
        /// and it tries to verify the code that the user put in
        /// </summary>
        /// <param name="sender">The btnVerifyCode DevEx button</param>
        /// <param name="e">The Click event</param>
        protected void btnVerifyCode_Click(object sender, EventArgs e)
        {
            //Only continue if the validation is successful
            if (ASPxEdit.AreEditorsValid(this, "vgVerifyCode"))
            {
                //Get the user manager
                ApplicationUserManager manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();

                //Try to change the phone number
                IdentityResult result = manager.ChangePhoneNumber(User.Identity.GetUserId(), hfPhoneNumber.Value, txtCode.Text);

                //Check to see if the change succeeded
                if (result.Succeeded)
                {
                    //Succeeded, redirect the user
                    Response.Redirect("/Account/Manage?m=VerifyPhoneNumberSuccess");
                }
                else
                {
                    //Failed, show error message
                    msgSys.ShowMessageToUser("warning", "Verification Failed", "Failed to verify the phone.  Please check the code and try again.", 10000);
                }
            }
        }
コード例 #24
0
ファイル: uBuyingService.ascx.cs プロジェクト: ewin66/dev
        protected void popBuyingService_WindowCallback(object source, DevExpress.Web.ASPxPopupControl.PopupWindowCallbackArgs e)
        {
            string[] args = e.Parameter.Split('|');
            switch (args[0])
            {
            case "new":
                PrivateSession.Instance.BuyingServiceId = Guid.Empty;
                this.LoadBuyingServiceBuyingServiceCategoryEntities(Guid.Empty);
                this.LoadBuyingServiceSupplierEntities(Guid.Empty);
                this.LoadBuyingServiceEquivalenceEntities(Guid.Empty);
                frmBuyingService.DataSourceID = null;
                ClearForm();
                break;

            case "edit":
                ClearForm();
                frmBuyingService.DataSourceID = dsBuyingServiceProperty.ID;
                if (args.Length > 1)
                {
                    Guid buyingServiceId = Guid.Parse(args[1]);
                    PrivateSession.Instance.BuyingServiceId = buyingServiceId;

                    this.LoadBuyingServiceBuyingServiceCategoryEntities(buyingServiceId);
                    this.LoadBuyingServiceEquivalenceEntities(buyingServiceId);
                    this.LoadBuyingServiceSupplierEntities(buyingServiceId);

                    dsBuyingServiceProperty.CriteriaParameters["BuyingServiceId"].DefaultValue = buyingServiceId.ToString();
                    dsBuyingServiceProperty.CriteriaParameters["Language"].DefaultValue        = Utility.CurrentSession.Instance.Lang;

                    //HtmlEditorDescription.Html = BuyingServiceEntity.Description;
                    //txtCode.Text = BuyingServiceEntity.Code;
                }
                break;

            case "save":
                bool   isSuccess   = true;
                string recordIdStr = null;
                try
                {
                    //Check validation
                    if (!ASPxEdit.AreEditorsValid(pagBuyingService, true))
                    {
                        popBuyingService.JSProperties.Add("cpInvalid", true);
                        pagBuyingService.ActiveTabIndex = 0;
                        return;
                    }
                    //Logic to save data
                    if (args.Length > 1)
                    {
                        //Update mode
                        recordIdStr = args[1];
                        Guid recordId = Guid.Parse(recordIdStr);
                        //BuyingServiceEntity entity = new BuyingServiceEntity();
                        //entity.BuyingServiceId = recordId;
                        //entity.Code = txtCode.Text;
                        //entity.RowStatus = char.Parse(cbRowStatus.SelectedItem.Value.ToString());
                        //entity.Language = Utility.CurrentSession.Instance.Lang;
                        //entity.Name = txtName.Text;
                        //entity.Description = HtmlEditorDescription.Html;

                        //entity.BuyingServiceBuyingServiceCategoryEntities =
                        //    PrivateSession.Instance.BuyingServiceBuyingServiceCategoryEntities;

                        //entity.BuyingServiceSupplierEntities =
                        //    PrivateSession.Instance.BuyingServiceSupplierEntities;

                        //entity.BuyingServiceEquivalenceEntities =
                        //    PrivateSession.Instance.BuyingServiceEquivalenceEntities;

                        //buyingServiceBLO.Update(entity);
                    }
                    else
                    {
                        //Insert mode
                        //BuyingServiceEntity entity = new BuyingServiceEntity();
                        //entity.Code = txtCode.Text;
                        //entity.Language = Utility.CurrentSession.Instance.Lang;
                        //entity.RowStatus = char.Parse(cbRowStatus.SelectedItem.Value.ToString());
                        //entity.Name = txtName.Text;
                        //entity.Description = HtmlEditorDescription.Html;

                        //entity.BuyingServiceBuyingServiceCategoryEntities =
                        //    PrivateSession.Instance.BuyingServiceBuyingServiceCategoryEntities;

                        //entity.BuyingServiceSupplierEntities =
                        //    PrivateSession.Instance.BuyingServiceSupplierEntities;

                        //entity.BuyingServiceEquivalenceEntities =
                        //    PrivateSession.Instance.BuyingServiceEquivalenceEntities;

                        //buyingServiceBLO.Insert(entity);
                    }
                }
                catch (Exception)
                {
                    isSuccess = false;
                    throw;
                }
                finally
                {
                    popBuyingService.JSProperties.Add("cpCallbackArgs",
                                                      String.Format("{{ \"recordId\": \"{0}\", \"isSuccess\": {1} }}", recordIdStr, isSuccess.ToString().ToLower()));

                    PrivateSession.ClearInstance();
                }
                break;

            default:
                break;
            }
        }
コード例 #25
0
ファイル: ReceiptVoucherEdit.ascx.cs プロジェクト: ewin66/dev
        protected void popReceiptVouchesEdit_WindowCallback(object source, DevExpress.Web.ASPxPopupControl.PopupWindowCallbackArgs e)
        {
            string[]         args = e.Parameter.Split('|');
            ReceiptVouchesBO bo   = new ReceiptVouchesBO(); //ham dinh nghia ben NAS.BO

            switch (args[0])
            {
            //DND 851
            case "cbo_click":
                if (args.Length > 1)
                {
                    string textAdsress = "";
                    if (args[1].Equals(""))
                    {
                        textAdsress = "";
                    }
                    else
                    {
                        string[] org_code = args[1].ToString().Split('-');
                        org_code[0] = org_code[0].Trim();
                        textAdsress = bo.searchOrgnAdress(session, org_code[0]);
                    }

                    memoAddress.Value = textAdsress;
                    txtPayer.Focus();
                }
                break;

            //END DND 851
            case "new":
                ReceiptVouches tempReceiptVouches = ReceiptVouches.InitNewRow(session);
                popReceiptVouchesEdit.JSProperties["cpNewRecordId"]           = tempReceiptVouches.VouchesId.ToString();
                PrivateSession.Instance.ReceiptVoucherId                      = tempReceiptVouches.VouchesId;
                dsReceiptVouches.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.ReceiptVoucherId.ToString();
                dsVouchersAmount.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.ReceiptVoucherId.ToString();
                this.InvisibleCommandColumnGridviewIfApprovedCosting(grdVouchersAmount, "CommonOperations");
                ClearForm();
                txtCode.Text = artifactCodeRuleBO.GetArtifactCodeOfArtifactType(ArtifactTypeEnum.VOUCHER_RECEIPT);
                //DND 851
                dateIssuedDate.Value = DateTime.Now;


                //END DND
                break;

            case "edit":
                ClearForm();
                if (args.Length > 1)
                {
                    PrivateSession.Instance.ReceiptVoucherId = Guid.Parse(args[1]);
                    dsReceiptVouches.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.ReceiptVoucherId.ToString();
                    dsVouchersAmount.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.ReceiptVoucherId.ToString();
                    txtCode.Text = CurrentReceiptVouches.Code;
                    this.InvisibleCommandColumnGridviewIfApprovedCosting(grdVouchersAmount, "CommonOperations");
                    //DND
                    if (bo.searchOrgDefault(session, CurrentReceiptVouches.SourceOrganizationId.OrganizationId.ToString()))
                    {
                        popReceiptVouchesEdit.JSProperties.Add("cpIsDefaultSourceOrg", true);
                    }
                    else
                    {
                        popReceiptVouchesEdit.JSProperties.Add("cpIsDefaultSourceOrg", false);
                    }
                    //END DND
                }
                break;

            case "save":
                bool   isSuccess   = true;
                string recordIdStr = null;

                try
                {
                    //Check validation
                    if (!ASPxEdit.AreEditorsValid(frmReceiptVouches, true))
                    {
                        popReceiptVouchesEdit.JSProperties.Add("cpInvalid", true);
                        return;
                    }

                    //collect data for saving
                    string   code      = txtCode.Text;
                    DateTime issueDate = new DateTime();
                    if (!DateTime.TryParse(dateIssuedDate.Text, out issueDate))
                    {
                        issueDate = DateTime.Now;
                    }

                    string description = memoDescription.Text;
                    string address     = memoAddress.Text;
                    //2013-11-18 Khoa.Truong INS START
                    //Guid voucherTypeId = Guid.Parse(cbVouchesType.SelectedItem.Value.ToString());
                    //Guid sourceOrgId = Guid.Parse(cbSourceOrganization.SelectedItem.Value.ToString());
                    //2013-11-18 Khoa.Truong INS END

                    //2013-11-18 Khong.Truong DEL START
                    ////DND 851
                    Guid sourceOrgId;
                    bo = new ReceiptVouchesBO();     //ham dinh nghia ben NAS.BO
                    string cbVouchesType_name = cbVouchesType.Text;


                    if (cbSourceOrganization.Text == null || cbSourceOrganization.Text.Equals(""))
                    {
                        sourceOrgId = Guid.Parse(bo.searchOrganizationId(session));
                    }
                    else
                    {
                        string[] org_code = cbSourceOrganization.Text.ToString().Split('-');

                        org_code[0] = org_code[0].Trim();

                        sourceOrgId = Guid.Parse(bo.searchOrgId(session, org_code[0]));
                    }
                    Guid voucherTypeId = Guid.Parse(bo.searchVouchesTypeId(session, cbVouchesType_name));
                    ////END DND
                    //2013-11-18 Khong.Truong DEL END

                    string payer = txtPayer.Text;
                    //Logic to save data

                    if (args.Length > 1)
                    {
                        //Update mode
                        //Update general information
                        recordIdStr = args[1];
                        Guid             recordId         = Guid.Parse(recordIdStr);
                        ReceiptVouchesBO receiptVouchesBO = new ReceiptVouchesBO();
                        receiptVouchesBO.Update(PrivateSession.Instance.ReceiptVoucherId,
                                                code,
                                                issueDate,
                                                description,
                                                address,
                                                payer,
                                                Constant.ROWSTATUS_ACTIVE,
                                                sourceOrgId,
                                                Utility.CurrentSession.Instance.AccessingOrganizationId,
                                                voucherTypeId);
                    }
                    else
                    {
                        //Insert mode
                        ReceiptVouchesBO receiptVouchesBO = new ReceiptVouchesBO();
                        receiptVouchesBO.Insert(PrivateSession.Instance.ReceiptVoucherId,
                                                code,
                                                issueDate,
                                                description,
                                                address,
                                                payer,
                                                Constant.ROWSTATUS_ACTIVE,
                                                sourceOrgId,
                                                Utility.CurrentSession.Instance.AccessingOrganizationId,
                                                voucherTypeId);
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    throw;
                }
                finally
                {
                    popReceiptVouchesEdit.JSProperties.Add("cpCallbackArgs",
                                                           String.Format("{{ \"recordId\": \"{0}\", \"isSuccess\": {1} }}", recordIdStr, isSuccess.ToString().ToLower()));
                }
                break;

            default:
                break;
            }
        }
コード例 #26
0
        /// <summary>
        /// When the user clicks the Save button, save the changes to the user
        /// </summary>
        /// <param name="sender">The submitUser control</param>
        /// <param name="e">The Click event</param>
        protected void submitUser_Click(object sender, EventArgs e)
        {
            //Make sure the current user is correct
            currentUser = manager.FindById(currentUser.Id);

            //Whether or not the email changed
            bool emailChanged = false;

            //Only continue if the page is valid
            if (ASPxEdit.AreEditorsValid(this, submitUser.ValidationGroup))
            {
                //Check to see if the user's email changed
                if (currentUser.Email != Convert.ToString(txtEmail.Value))
                {
                    //The email changed
                    emailChanged = true;
                }

                //Only de-confirm the user's phone if it changed
                if (txtPhoneNumber.Value == null || (currentUser.PhoneNumber != txtPhoneNumber.Value.ToString()))
                {
                    currentUser.PhoneNumberConfirmed = false;
                }

                //Update the user's role
                if (currentUser.Roles.FirstOrDefault().RoleId != Convert.ToString(ddIdentityRole.Value))
                {
                    //Get the old role and new role
                    string oldRole = appContext.Roles.Find(currentUser.Roles.FirstOrDefault().RoleId).Name;
                    string newRole = appContext.Roles.Find(Convert.ToString(ddIdentityRole.Value)).Name;

                    //Change the role
                    manager.RemoveFromRole(currentUser.Id, oldRole);
                    manager.AddToRole(currentUser.Id, newRole);
                }

                //Set the user's information
                currentUser.EmailConfirmed    = !emailChanged;
                currentUser.PhoneNumber       = (txtPhoneNumber.Value == null ? null : txtPhoneNumber.Value.ToString());
                currentUser.Email             = txtEmail.Value.ToString();
                currentUser.FirstName         = txtFirstName.Value.ToString();
                currentUser.LastName          = txtLastName.Value.ToString();
                currentUser.LockoutEndDateUtc = (String.IsNullOrWhiteSpace(Convert.ToString(deLockoutEndDate.Value)) ? (DateTime?)null : Convert.ToDateTime(deLockoutEndDate.Value));
                currentUser.UpdateTime        = DateTime.Now;

                //Update the user in the database
                IdentityResult result = manager.Update(currentUser);

                if (result.Succeeded)
                {
                    //Send an email if the email changed
                    if (emailChanged)
                    {
                        //Generate the confirmation token and url
                        string code        = manager.GenerateEmailConfirmationToken(currentUser.Id);
                        string callbackUrl = IdentityHelper.GetEmailConfirmationRedirectUrl(code, currentUser.Id, Request);

                        //Send the confirmation email to the user via email
                        manager.SendEmail(currentUser.Id, "Confirm your email address change", Utilities.GetEmailHTML(callbackUrl, "Confirm Email", true, "Email Updated", "Please confirm your email address change by clicking the Confirm Email link below.", Request));
                    }

                    //Redirect the user to the user management page
                    Response.Redirect("/Admin/UserManagement.aspx?message=EditUserSuccess");
                }
                else
                {
                    //Show the user an error message
                    msgSys.ShowMessageToUser("danger", "Error", result.Errors.FirstOrDefault(), 120000);
                }
            }
        }
コード例 #27
0
ファイル: uDeviceUnit.ascx.cs プロジェクト: ewin66/dev
        /////2013-09-21 ERP-580 Khoa.Truong INS START
        //protected ToolUnitEntity ToolUnitEntity
        //{
        //    get
        //    {
        //        Guid recordId = Guid.Empty;
        //        try
        //        {
        //            recordId = (Guid)Session["ToolUnitId"];
        //            if (recordId == Guid.Empty) return null;
        //        }
        //        catch (Exception)
        //        {
        //            return null;
        //        }
        //        ToolUnitEntity toolUnitEntity;
        //        this.toolBOL.getToolUnitByKey(recordId, out toolUnitEntity);
        //        return toolUnitEntity;
        //    }
        //}
        /////2013-09-20 ERP-580 Khoa.Truong INS END


        protected void popDeviceCategoryEdit_WindowCallback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            string[] args = e.Parameter.Split('|');
            switch (args[0])
            {
            case "new":

                /////2013-09-21 ERP-580 Khoa.Truong INS START
                Session["ToolUnitId"] = Guid.Empty;
                /////2013-09-21 ERP-580 Khoa.Truong INS END

                frmlInfoGeneral.DataSourceID = null;
                ClearForm();
                //popManufacturerGroupEdit.ShowOnPageLoad = true;
                break;

            case "edit":
                /*frmlActiveElement.DataSourceID = "dsManufacturerCategory";
                 * if (args.Length > 1)
                 * {
                 *  dsManufacturerCategory.CriteriaParameters["ManufacturerCategoryId"].DefaultValue = args[1];
                 * }*/


                /////2013-09-21 ERP-580 Khoa.Truong INS START
                this.ClearForm();
                /////2013-09-21 ERP-580 Khoa.Truong INS END

                //ToolUnitEntity toolEntity;
                Guid guid = new Guid(args[1]);

                /////2013-09-21 ERP-580 Khoa.Truong INS START
                Session["ToolUnitId"] = guid;
                /////2013-09-21 ERP-580 Khoa.Truong INS END

                //frmlInfoGeneral.DataSource = this.toolBOL.getToolUnitByKey(guid, out toolEntity);
                frmlInfoGeneral.DataBind();
                //this.cboManufacturer.SelectedItem.Value = "123";
                //HtmlEditorDescription.Html = toolEntity.Description;
                //formDeviceUnitEdit.HeaderText = "Thông tin công cụ dụng cụ - Mã số: " + toolEntity.Code;
                formDeviceUnitEdit.ShowOnPageLoad = true;

                /////2013-09-21 ERP-580 Khoa.Truong INS START
                //txtCode.Text = toolEntity.Code;
                /////2013-09-21 ERP-580 Khoa.Truong INS END

                break;

            case "save":
                bool   isSuccess   = true;
                string recordIdStr = null;
                try
                {
                    /////2013-09-21 ERP-580 Khoa.Truong INS START
                    //Check validation
                    if (!ASPxEdit.AreEditorsValid(pagDeviceUnitEdit, true))
                    {
                        formDeviceUnitEdit.JSProperties.Add("cpInvalid", true);
                        pagDeviceUnitEdit.ActiveTabIndex = 0;
                        return;
                    }
                    /////2013-09-21 ERP-580 Khoa.Truong INS START

                    //Logic to save data
                    if (args.Length > 1)
                    {
                        //Update mode
                        recordIdStr = args[1];
                        Guid recordId = Guid.Parse(recordIdStr);
                        //ToolUnitEntity entity = new ToolUnitEntity();
                        //entity.ToolUnitId = recordId;
                        //entity.Code = txtCode.Text;
                        //entity.RowStatus = char.Parse(cbRowStatus.SelectedItem.Value.ToString());
                        //entity.Language = Utility.CurrentSession.Instance.Lang;
                        //entity.Name = txtName.Text;
                        //entity.Description = HtmlEditorDescription.Html;
                        //this.toolBOL.updateToolUnit(entity);
                    }
                    else
                    {
                        //Insert mode
                        //ToolUnitEntity entity = new ToolUnitEntity();
                        //entity.Code = txtCode.Text;
                        //entity.Language = Utility.CurrentSession.Instance.Lang;
                        //entity.RowStatus = char.Parse(cbRowStatus.SelectedItem.Value.ToString());
                        //entity.Name = txtName.Text;
                        //entity.Description = HtmlEditorDescription.Html;
                        //toolBOL.insertToolUnit(entity);
                    }

                    //popManufacturerGroupEdit.ShowOnPageLoad = false;
                }
                catch (Exception)
                {
                    isSuccess = false;
                    throw;
                }
                finally
                {
                    OnSaved(new WebModule.Interfaces.FormEditEventArgs()
                    {
                        isSuccess = isSuccess
                    });
                    formDeviceUnitEdit.JSProperties.Add("cpCallbackArgs",
                                                        String.Format("{{ \"recordId\": \"{0}\", \"isSuccess\": {1} }}", recordIdStr, isSuccess.ToString().ToLower()));
                }
                break;

            default:
                break;
            }
        }
コード例 #28
0
ファイル: uManufacturerEdit.ascx.cs プロジェクト: ewin66/dev
        protected void popManufacturerEdit_WindowCallback(object source, DevExpress.Web.ASPxPopupControl.PopupWindowCallbackArgs e)
        {
            string[] args = e.Parameter.Split('|');
            switch (args[0])
            {
            case "new":

                ManufacturerOrg tempManufacturerOrg = ManufacturerOrg.InitNewRow(session);
                PrivateSession.Instance.ManufacturerOrgId = tempManufacturerOrg.OrganizationId;
                frmManufacturerEdit.DataSourceID          = "dsManufacturer";
                dsManufacturer.CriteriaParameters["ManufacturerOrgId"].DefaultValue = PrivateSession.Instance.ManufacturerOrgId.ToString();
                ClearForm();
                //Get object id
                //Bind data to gridview

                #region add manufacturer
                session.BeginTransaction();
                try
                {
                    //ObjectType
                    ObjectType objectType =
                        ObjectType.GetDefault(session, NAS.DAL.CMS.ObjectDocument.ObjectTypeEnum.MANUFACTURER);

                    // object
                    NAS.BO.CMS.ObjectDocument.ObjectBO objectBO  = new NAS.BO.CMS.ObjectDocument.ObjectBO();
                    NAS.DAL.CMS.ObjectDocument.Object  cmsobject =
                        objectBO.CreateCMSObject(session, NAS.DAL.CMS.ObjectDocument.ObjectTypeEnum.MANUFACTURER);

                    // OrganizationObject
                    OrganizationObject organizatoinObject = new OrganizationObject(session)
                    {
                        ObjectId       = cmsobject,
                        OrganizationId = tempManufacturerOrg
                    };
                    organizatoinObject.Save();

                    // OrganizationCustomType
                    OrganizationCustomType organizationCustomType = new OrganizationCustomType(session)
                    {
                        ObjectTypeId   = objectType,
                        OrganizationId = tempManufacturerOrg
                    };
                    organizationCustomType.Save();
                    session.CommitTransaction();
                }
                catch
                {
                    session.RollbackTransaction();
                }


                OrganizationObject organizationObject = tempManufacturerOrg.OrganizationObjects.FirstOrDefault();
                grid_of_Manufacturer.CMSObjectId = organizationObject.ObjectId.ObjectId;
                grid_of_Manufacturer.DataBind();
                #endregion

                //2013-11-22 Khoa.Truong DEL START
                //gridviewCustomFields.CMSObjectId = CurrentManufacturerOrg.ObjectId.ObjectId;
                //gridviewCustomFields.DataBind();
                //2013-11-22 Khoa.Truong DEL END
                break;

            case "edit":
                ClearForm();
                frmManufacturerEdit.DataSourceID = "dsManufacturer";
                if (args.Length > 1)
                {
                    PrivateSession.Instance.ManufacturerOrgId = Guid.Parse(args[1]);
                    dsManufacturer.CriteriaParameters["ManufacturerOrgId"].DefaultValue = PrivateSession.Instance.ManufacturerOrgId.ToString();
                    txtCode.Text = CurrentManufacturerOrg.Code;
                    //Get object id
                    //Bind data to gridview

                    #region edit manufacturer
                    if (CurrentManufacturerOrg.OrganizationObjects.FirstOrDefault() == null)
                    {
                        session.BeginTransaction();
                        try
                        {
                            ObjectType objectType1 =
                                ObjectType.GetDefault(session, NAS.DAL.CMS.ObjectDocument.ObjectTypeEnum.MANUFACTURER);

                            // object
                            NAS.BO.CMS.ObjectDocument.ObjectBO objectBO1  = new NAS.BO.CMS.ObjectDocument.ObjectBO();
                            NAS.DAL.CMS.ObjectDocument.Object  cmsobject1 =
                                objectBO1.CreateCMSObject(session, NAS.DAL.CMS.ObjectDocument.ObjectTypeEnum.MANUFACTURER);

                            OrganizationObject organizatoinObject1 = new OrganizationObject(session)
                            {
                                ObjectId       = cmsobject1,
                                OrganizationId = CurrentManufacturerOrg
                            };
                            organizatoinObject1.Save();

                            // OrganizationCustomType
                            OrganizationCustomType organizationCustomType1 = new OrganizationCustomType(session)
                            {
                                ObjectTypeId   = objectType1,
                                OrganizationId = CurrentManufacturerOrg
                            };
                            organizationCustomType1.Save();
                            session.CommitTransaction();
                        }
                        catch (Exception)
                        {
                            session.RollbackTransaction();
                            throw;
                        }

                        OrganizationObject organizationObject1 = CurrentManufacturerOrg.OrganizationObjects.FirstOrDefault();
                        grid_of_Manufacturer.CMSObjectId = organizationObject1.ObjectId.ObjectId;
                        grid_of_Manufacturer.DataBind();
                    }

                    else
                    {
                        OrganizationObject organizationObject1 = CurrentManufacturerOrg.OrganizationObjects.FirstOrDefault();
                        grid_of_Manufacturer.CMSObjectId = organizationObject1.ObjectId.ObjectId;
                        grid_of_Manufacturer.DataBind();
                    }
                    #endregion



                    //2013-11-22 Khoa.Truong DEL START
                    //gridviewCustomFields.CMSObjectId = CurrentManufacturerOrg.ObjectId.ObjectId;
                    //gridviewCustomFields.DataBind();
                    //2013-11-22 Khoa.Truong DEL END
                }
                break;

            case "save":
                bool   isSuccess   = true;
                string recordIdStr = null;
                try
                {
                    //Check validation
                    if (!ASPxEdit.AreEditorsValid(pagMunufacturer, true))
                    {
                        popManufacturerEdit.JSProperties.Add("cpInvalid", true);
                        pagMunufacturer.ActiveTabIndex = 0;
                        return;
                    }
                    //Logic to save data
                    if (args.Length > 1)
                    {
                        //Update mode
                        //Update general information
                        recordIdStr = args[1];
                        Guid            recordId            = Guid.Parse(recordIdStr);
                        ManufacturerOrg editManufacturerOrg =
                            session.GetObjectByKey <ManufacturerOrg>(PrivateSession.Instance.ManufacturerOrgId);
                        editManufacturerOrg.Code      = txtCode.Text;
                        editManufacturerOrg.Name      = txtName.Text;
                        editManufacturerOrg.RowStatus = short.Parse(cbRowStatus.SelectedItem.Value.ToString());
                        editManufacturerOrg.Save();
                    }
                    else
                    {
                        //Insert mode
                        ManufacturerOrg newManufacturerOrg =
                            session.GetObjectByKey <ManufacturerOrg>(PrivateSession.Instance.ManufacturerOrgId);
                        newManufacturerOrg.Code      = txtCode.Text;
                        newManufacturerOrg.Name      = txtName.Text;
                        newManufacturerOrg.RowStatus = short.Parse(cbRowStatus.SelectedItem.Value.ToString());
                        newManufacturerOrg.Save();
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    throw;
                }
                finally
                {
                    popManufacturerEdit.JSProperties.Add("cpCallbackArgs",
                                                         String.Format("{{ \"recordId\": \"{0}\", \"isSuccess\": {1} }}", recordIdStr, isSuccess.ToString().ToLower()));
                }
                break;

            default:
                break;
            }
        }
コード例 #29
0
        /////2013-09-20 ERP-572 Khoa.Truong INS START
        //protected ActiveElementEntity ActiveElementEntity {
        //    get {
        //        Guid recordId = Guid.Empty;
        //        try
        //        {
        //            recordId = (Guid)Session["ActiveElementId"];
        //            if (recordId == Guid.Empty) return null;
        //        }
        //        catch (Exception)
        //        {
        //            return null;
        //        }
        //        ActiveElementEntity elementEntity;
        //        this.activeElementBLO.getActiveElementByKey(recordId, out elementEntity);
        //        return elementEntity;
        //    }
        //}
        /////2013-09-20 ERP-572 Khoa.Truong INS END

        protected void popManufacturerGroupEdit_WindowCallback(object source, DevExpress.Web.ASPxPopupControl.PopupWindowCallbackArgs e)
        {
            string[] args = e.Parameter.Split('|');
            switch (args[0])
            {
            case "new":
                frmlActiveElement.DataSourceID = null;
                this.ClearForm();

                /////2013-09-20 ERP-572 Khoa.Truong INS START
                Session["ActiveElementId"] = Guid.Empty;
                /////2013-09-20 ERP-572 Khoa.Truong INS END

                //popManufacturerGroupEdit.ShowOnPageLoad = true;
                break;

            case "edit":
                /*frmlActiveElement.DataSourceID = "dsManufacturerCategory";
                 * if (args.Length > 1)
                 * {
                 *  dsManufacturerCategory.CriteriaParameters["ManufacturerCategoryId"].DefaultValue = args[1];
                 * }*/

                /////2013-09-20 ERP-572 Khoa.Truong INS START
                this.ClearForm();
                /////2013-09-20 ERP-572 Khoa.Truong INS END

                // ActiveElementEntity elementEntity;
                Guid guid = new Guid(args[1]);

                /////2013-09-20 ERP-572 Khoa.Truong INS START
                Session["ActiveElementId"] = guid;
                /////2013-09-20 ERP-572 Khoa.Truong INS END

                //frmlActiveElement.DataSource = this.activeElementBLO.getActiveElementByKey(guid, out elementEntity);
                frmlActiveElement.DataBind();
                //HtmlEditorDescription.Html = elementEntity.Description;
                //popManufacturerGroupEdit.HeaderText = "Thông tin hoạt chất - Mã số: " + elementEntity.Code;
                popManufacturerGroupEdit.ShowOnPageLoad = true;

                /////2013-09-20 ERP-572 Khoa.Truong INS START
                //txtCode.Text = elementEntity.Code;
                /////2013-09-20 ERP-572 Khoa.Truong INS END

                /*HtmlEditorDescription.Html =
                 *  manufacturerCategoryBLO.getManufacturerCategoryEntity(Guid.Parse(args[1]),
                 *                                                 Utility.CurrentSession.Instance.Lang).Description;*/
                //popManufacturerGroupEdit.ShowOnPageLoad = true;
                break;

            case "save":
                bool   isSuccess   = true;
                string recordIdStr = null;
                try
                {
                    //Check validation
                    if (!ASPxEdit.AreEditorsValid(pagManufacturerGroupEdit, true))
                    {
                        popManufacturerGroupEdit.JSProperties.Add("cpInvalid", true);
                        pagManufacturerGroupEdit.ActiveTabIndex = 0;
                        return;
                    }
                    //Logic to save data
                    if (args.Length > 1)
                    {
                        //Update mode
                        recordIdStr = args[1];
                        Guid recordId = Guid.Parse(recordIdStr);
                        //ActiveElementEntity entity = new ActiveElementEntity();
                        //entity.ActiveElementId = recordId;
                        //entity.Code = txtCode.Text;
                        //entity.ActiveComponent = txtComponent.Text;
                        //entity.ActiveFunction = txtFunction.Text;
                        //entity.RowStatus = char.Parse(cbRowStatus.SelectedItem.Value.ToString());
                        //entity.Language = Utility.CurrentSession.Instance.Lang;
                        //entity.Name = txtName.Text;
                        //entity.Description = HtmlEditorDescription.Html;
                        //this.activeElementBLO.updateActiveElement(entity);
                    }
                    else
                    {
                        //Insert mode
                        //ActiveElementEntity entity = new ActiveElementEntity();
                        //entity.Code = txtCode.Text;
                        //entity.ActiveComponent = txtComponent.Text;
                        //entity.ActiveFunction = txtFunction.Text;
                        //entity.Language = Utility.CurrentSession.Instance.Lang;
                        //entity.RowStatus = char.Parse(cbRowStatus.SelectedItem.Value.ToString());
                        //entity.Name = txtName.Text;
                        //entity.Description = HtmlEditorDescription.Html;
                        ////activeElementBLO.insertActiveElement(entity);
                    }

                    //popManufacturerGroupEdit.ShowOnPageLoad = false;
                }
                catch (Exception)
                {
                    isSuccess = false;
                    throw;
                }
                finally
                {
                    OnSaved(new WebModule.Interfaces.FormEditEventArgs()
                    {
                        isSuccess = isSuccess
                    });
                    popManufacturerGroupEdit.JSProperties.Add("cpCallbackArgs",
                                                              String.Format("{{ \"recordId\": \"{0}\", \"isSuccess\": {1} }}", recordIdStr, isSuccess.ToString().ToLower()));
                }
                break;

            default:
                break;
            }
        }
コード例 #30
0
ファイル: uWarehouseUnit.ascx.cs プロジェクト: ewin66/dev
        protected void popWarehouseUnitEdit_WindowCallback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            string[] args = e.Parameter.Split('|');
            switch (args[0])
            {
            case "new":
                InventoryUnit invUnit = InventoryUnit.InitNewRow(this.session);
                PrivateSession.Instance.InventoryUnitId = invUnit.InventoryUnitId;

                this.dsInventoryUnit.CriteriaParameters["InventoryUnitId"].DefaultValue = PrivateSession.Instance.InventoryUnitId.ToString();
                this.ClearForm();
                break;

            case "edit":
                this.ClearForm();

                if (args.Length > 1)
                {
                    PrivateSession.Instance.InventoryUnitId = Guid.Parse(args[1]);
                    dsInventoryUnit.CriteriaParameters["InventoryUnitId"].DefaultValue = PrivateSession.Instance.InventoryUnitId.ToString();
                    //this.txtName.Text = CurrentInventoryUnit.Name;
                    //txtCode.Text = CurrentManufacturerOrg.Code;
                }
                break;

            case "save":
                bool   isSuccess   = true;
                string recordIdStr = null;
                try
                {
                    //Check validation
                    if (!ASPxEdit.AreEditorsValid(this.pagWarehouseUnitEdit, true))
                    {
                        formWarehouseUnitEdit.JSProperties.Add("cpInvalid", true);
                        pagWarehouseUnitEdit.ActiveTabIndex = 0;
                        return;
                    }
                    //Logic to save data
                    if (args.Length > 1)
                    {
                        //Update mode
                        //Update general information
                        recordIdStr = args[1];
                        Guid          recordId            = Guid.Parse(recordIdStr);
                        InventoryUnit editManufacturerOrg =
                            session.GetObjectByKey <InventoryUnit>(PrivateSession.Instance.InventoryUnitId);
                        //editManufacturerOrg.Code = txtCode.Text;
                        editManufacturerOrg.Name = txtName.Text;
                        //editManufacturerOrg.RowStatus = short.Parse(cbRowStatus.SelectedItem.Value.ToString());
                        editManufacturerOrg.Save();
                    }
                    else
                    {
                        //Insert mode
                        InventoryUnit newManufacturerOrg =
                            session.GetObjectByKey <InventoryUnit>(PrivateSession.Instance.InventoryUnitId);
                        //newManufacturerOrg.Code = txtCode.Text;
                        newManufacturerOrg.Name = txtName.Text;
                        //newManufacturerOrg.RowStatus = short.Parse(cbRowStatus.SelectedItem.Value.ToString());
                        newManufacturerOrg.RowStatus = Utility.Constant.ROWSTATUS_ACTIVE;
                        newManufacturerOrg.Save();
                    }
                }
                catch (Exception)
                {
                    isSuccess = false;
                    throw;
                }
                finally
                {
                    OnSaved(new WebModule.Interfaces.FormEditEventArgs()
                    {
                        isSuccess = isSuccess
                    });
                    formWarehouseUnitEdit.JSProperties.Add("cpCallbackArgs",
                                                           String.Format("{{ \"recordId\": \"{0}\", \"isSuccess\": {1} }}", recordIdStr, isSuccess.ToString().ToLower()));
                    PrivateSession.ClearInstance();
                }
                break;

            default:
                break;
            }
        }