protected void ASPxTreeList_Department_NodeInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { var Organization = session.GetObjectByKey <NAS.DAL.Nomenclature.Organization.Organization>(OrganizationId); string parentKey = ASPxTreeList_Department.NewNodeParentKey; if (parentKey.Equals(String.Empty)) { e.NewValues["ParentDepartmentId!Key"] = parentKey = Guid.Empty.ToString(); } NAS.DAL.Nomenclature.Organization.Department department = session.GetObjectByKey <NAS.DAL.Nomenclature.Organization.Department>(Guid.Parse(parentKey)); NAS.DAL.Nomenclature.Organization.Department o = new NAS.DAL.Nomenclature.Organization.Department(session) { Name = e.NewValues["Name"].ToString(), Code = e.NewValues["Code"].ToString(), Description = e.NewValues["Description"] != null ? e.NewValues["Description"].ToString() : string.Empty, OrganizationId = Organization, ParentDepartmentId = department, RowStatus = Utility.Constant.ROWSTATUS_ACTIVE }; session.Save(o); e.Cancel = true; ASPxTreeList_Department.CancelEdit(); }
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); }
protected void trlDepartment_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxTreeList.TreeListHtmlDataCellEventArgs e) { if (e.Column.Name == "DpId") { NAS.DAL.Nomenclature.Organization.Department department = (NAS.DAL.Nomenclature.Organization.Department)trlDepartment.FindNodeByKeyValue(e.NodeKey).DataItem; string dptype = department.DepartmentTypeId.Name.ToString(); e.Cell.Text = dptype; } }
public void loadListUsers(TreeListNode node) { if (node != null) { NAS.DAL.Nomenclature.Organization.Department selectedDP = (NAS.DAL.Nomenclature.Organization.Department)node.DataItem; DepartmentBO bo = new DepartmentBO(); List <Person> LoginPersonLST = bo.getAllPeopleInDepartments(session, selectedDP); grd_ListUser.DataSource = LoginPersonLST; grd_ListUser.DataBind(); } }
protected void trlDepartment_CustomCallback(object sender, TreeListCustomCallbackEventArgs e) { string[] p = e.Argument.Split('|'); if (p[0] == "Delete") { Guid departmentId = Guid.Parse(p[1]); NAS.DAL.Nomenclature.Organization.Department department = session.GetObjectByKey <NAS.DAL.Nomenclature.Organization.Department>(departmentId); department.RowStatus = Constant.ROWSTATUS_DELETED; department.Save(); trlDepartment.JSProperties.Add("cpRefresh", "RefreshOnly"); } trlDepartment.DataBind(); }
public void updatePerson(Person p) { List <TreeListNode> nodes = trlDepartment.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, p.Code, p.Name, p.RowStatus); }
protected void trlDepartment_NodeValidating(object sender, DevExpress.Web.ASPxTreeList.TreeListNodeValidationEventArgs e) { ASPxTreeList treeDepart = (ASPxTreeList)sender; string departCode = e.NewValues["Code"].ToString().Trim(); if (treeDepart.IsNewNodeEditing) { bool isExist = Util.isExistXpoObject <NAS.DAL.Nomenclature.Organization.Department>("Code", departCode, Constant.ROWSTATUS_ACTIVE, Constant.ROWSTATUS_DEFAULT, Constant.ROWSTATUS_INACTIVE); if (isExist) { CriteriaOperator criteria = new BinaryOperator("Code", departCode, BinaryOperatorType.Equal); NAS.DAL.Nomenclature.Organization.Department depart = session.FindObject <NAS.DAL.Nomenclature.Organization.Department>(criteria); short rowstatus = depart.RowStatus; if (rowstatus > 0) { Utility.Helpers.AddErrorToTreeListNode(e.Errors, "Code", "Mã phòng ban đã tồn tại."); return; } } } else { if (treeDepart.IsEditing) { string newCode = e.NewValues["Code"].ToString().Trim(); string oldCode = e.OldValues["Code"].ToString().Trim(); if (!newCode.Equals(oldCode)) { bool isExist = Util.isExistXpoObject <NAS.DAL.Nomenclature.Organization.Department>("Code", departCode, Constant.ROWSTATUS_ACTIVE, Constant.ROWSTATUS_DEFAULT, Constant.ROWSTATUS_INACTIVE); if (isExist) { CriteriaOperator criteria = new BinaryOperator("Code", departCode, BinaryOperatorType.Equal); NAS.DAL.Nomenclature.Organization.Department depart = session.FindObject <NAS.DAL.Nomenclature.Organization.Department>(criteria); short rowstatus = depart.RowStatus; if (rowstatus > 0) { Utility.Helpers.AddErrorToTreeListNode(e.Errors, "Code", "Mã phòng ban đã tồn tại."); return; } } } } } }
public void loadDepartmentsOnPerson() { Dictionary <Guid, NAS.DAL.Nomenclature.Organization.DepartmentPerson> dpDictation = new Dictionary <Guid, DepartmentPerson>(); dpDictation = currentPerson.DepartmentPersons.ToDictionary(d => d.DepartmentPersonId); List <TreeListNode> nodes = getAllDepartmentNode(); foreach (TreeListNode n in nodes) { NAS.DAL.Nomenclature.Organization.Department d = (NAS.DAL.Nomenclature.Organization.Department)n.DataItem; bool flg = false; foreach (DepartmentPerson dp in d.DepartmentPersons) { if (dpDictation.ContainsKey(dp.DepartmentPersonId) && dp.RowStatus > 0) { flg = true; break; } } n.Selected = flg; } }