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 static void Populate() { Session session = null; try { session = XpoHelper.GetNewSession(); //insert default data into Organization table if (!Util.isExistXpoObject <Department>("Code", Utility.Constant.NAAN_DEFAULT_CODE)) { XPQuery <Organization> organizationQuery = session.Query <Organization>(); XPQuery <DepartmentType> departmentTypeQuery = session.Query <DepartmentType>(); DepartmentType.Populate(); Organization.Populate(); Organization organization = organizationQuery.Where(r => r.Code == Utility.Constant.NAAN_DEFAULT_CODE).FirstOrDefault(); DepartmentType departmentType = departmentTypeQuery.Where(r => r.Code == Utility.Constant.NAAN_DEFAULT_CODE).FirstOrDefault(); Department department = new Department(session) { Code = Utility.Constant.NAAN_DEFAULT_CODE, Name = Utility.Constant.NAAN_DEFAULT_NAME, DepartmentTypeId = departmentType, OrganizationId = organization, Description = "", RowStatus = -1, RowCreationTimeStamp = DateTime.Now }; department.Save(); } } catch (Exception) { throw; } finally { if (session != null) { session.Dispose(); } } }