Example #1
0
        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);
        }
Example #2
0
        public bool PersonCreating_UpdateGUI()
        {
            ClearForm();
            txt_Code.Focus();
            popup_PersonCreate.ShowOnPageLoad    = true;
            popup_PersonCreate.HeaderText        = "Thông Tin Người Dùng";
            ASPxGridView_LoginAccount.DataSource = Temp_LoginAccount;
            ASPxGridView_LoginAccount.DataBind();
            ASPxTreeList_OfDepartment.DataBind();
            ASPxGridView_LoginAccount.AddNewRow();

            return(true);
        }
Example #3
0
        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);
        }
Example #4
0
        public bool PersonEditing_UpdateGUI()
        {
            ClearForm();
            // Load Person
            Person person = session.GetObjectByKey <Person>(PersonId);

            frmPersonEdit.DataSource = person;
            frmPersonEdit.DataBind();

            // load TMP_LOGINACCOUNT
            var selectedLA = from la in person.LoginAccounts where la.RowStatus > 0 select la;

            foreach (LoginAccount la in selectedLA)
            {
                Temp_LoginAccount.Add(new TMPLoginAccount()
                {
                    LoginAccountId = la.LoginAccountId,
                    Email          = la.Email
                });
            }
            ASPxGridView_LoginAccount.DataSource = Temp_LoginAccount;
            ASPxGridView_LoginAccount.DataBind();

            // Bind selected Node
            var selectedDP = from dp in person.DepartmentPersons where dp.RowStatus > 0 select dp;

            foreach (DepartmentPerson dp in selectedDP)
            {
                foreach (TreeListNode node in DepartmentNodes)
                {
                    if (Guid.Parse(node.Key).Equals(dp.DepartmentId.DepartmentId))
                    {
                        node.Selected = true;
                    }
                }
            }
            ASPxTreeList_OfDepartment.DataBind();

            // UPDATE GUI
            popup_PersonCreate.ShowOnPageLoad = true;
            popup_PersonCreate.HeaderText     = string.Format("Thông Tin Người Dùng: {0}", person.Name);
            return(true);
        }
Example #5
0
        //

        void ClearForm()
        {
            txt_Name.Text = string.Empty;
            txt_Code.Text = string.Empty;
            ASPxTreeList_OfDepartment.ClearNodes();
        }