Beispiel #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);
        }
Beispiel #2
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);
        }