Beispiel #1
0
        public static void DeleteLogical(Guid customerOrgId)
        {
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();
                //Finds ManufacturerOrg by Id
                NAS.DAL.Nomenclature.Organization.Organization customerOrg = session.GetObjectByKey <NAS.DAL.Nomenclature.Organization.Organization>(customerOrgId);
                //Check foreign key constraint with Item table
                //var itemList = customerOrg.;
                //if (itemList.Count() > 0)
                //{
                //    string param0 = supplierOrg.Name;
                //    string param1 = itemList.First().ItemId.Name;
                //    throw new Exception(String.Format("Nhà cung cấp '{0}' đang được cấu hình trong hàng hóa '{1}'", param0, param1));
                //}
                customerOrg.RowStatus = Utility.Constant.ROWSTATUS_DELETED;
                customerOrg.Save();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
Beispiel #2
0
        public List <Person> getAllPeopleInOrganization(Session session, Guid OrganizationId)
        {
            List <Person> rs = new List <Person>();

            NAS.DAL.Nomenclature.Organization.Organization o = session.GetObjectByKey <NAS.DAL.Nomenclature.Organization.Organization>(OrganizationId);
            if (o == null)
            {
                throw new Exception("The key is not exist in Organization");
            }
            if (o.Deparments == null || o.Deparments.Count == 0)
            {
                return(null);
            }

            foreach (Department d in o.Deparments)
            {
                List <Person> lst = getAllPeopleInDepartments(session, d);
                foreach (Person p in lst)
                {
                    if (!rs.Contains <Person>(p))
                    {
                        rs.Add(p);
                    }
                }
            }
            return(rs);
        }
Beispiel #3
0
 protected void tList_Organization_CustomCallback(object sender, TreeListCustomCallbackEventArgs e)
 {
     string[] para = e.Argument.Split('|');
     if (para[0] == "Delete")
     {
         Guid organId = Guid.Parse(para[1]);
         NAS.DAL.Nomenclature.Organization.Organization organ = session.GetObjectByKey <NAS.DAL.Nomenclature.Organization.Organization>(organId);
         organ.RowStatus = Constant.ROWSTATUS_DELETED;
         organ.Save();
         tList_Organization.JSProperties.Add("cpRefresh", "Refresh");
     }
     tList_Organization.DataBind();
 }
Beispiel #4
0
        protected void cboSupplierColumn_OnItemRequestedByValue_SQL(object source, ListEditItemRequestedByValueEventArgs e)
        {
            ASPxComboBox comboBox = (ASPxComboBox)source;

            //2013-11-03 ERP-872 Khoa.Truong MOD START
            //NAS.DAL.Nomenclature.Organization.SupplierOrg obj = session.GetObjectByKey<NAS.DAL.Nomenclature.Organization.SupplierOrg>(e.Value);
            NAS.DAL.Nomenclature.Organization.Organization obj = session.GetObjectByKey <NAS.DAL.Nomenclature.Organization.Organization>(e.Value);

            if (obj != null)
            {
                comboBox.DataSource = new NAS.DAL.Nomenclature.Organization.Organization[] { obj };
                comboBox.DataBindItems();
            }
            //2013-11-03 ERP-872 Khoa.Truong MOD END
        }
Beispiel #5
0
        protected void tList_Organization_NodeValidating(object sender, DevExpress.Web.ASPxTreeList.TreeListNodeValidationEventArgs e)
        {
            ASPxTreeList tree             = (ASPxTreeList)sender;
            string       organizationCode = e.NewValues["Code"].ToString();

            //New mode
            if (tree.IsNewNodeEditing)
            {
                bool isExist = Util.isExistXpoObject <NAS.DAL.Nomenclature.Organization.Organization>("Code", organizationCode,
                                                                                                      Constant.ROWSTATUS_ACTIVE, Constant.ROWSTATUS_DEFAULT, Constant.ROWSTATUS_INACTIVE);
                if (isExist)
                {
                    CriteriaOperator criteria = new BinaryOperator("Code", organizationCode, BinaryOperatorType.Equal);
                    NAS.DAL.Nomenclature.Organization.Organization organ = session.FindObject <NAS.DAL.Nomenclature.Organization.Organization>(criteria);
                    short rowstatus = organ.RowStatus;
                    if (rowstatus > 0)
                    {
                        Utility.Helpers.AddErrorToTreeListNode(e.Errors, "Code", "Mã tổ chức đã tồn tại");
                    }
                }
            }

            //Edit mode
            else
            {
                if (tree.IsEditing)
                {
                    if (e.NewValues["Code"].ToString().Trim() != e.OldValues["Code"].ToString().Trim())
                    {
                        bool isExist = Util.isExistXpoObject <NAS.DAL.Nomenclature.Organization.Organization>("Code", organizationCode,
                                                                                                              Constant.ROWSTATUS_ACTIVE, Constant.ROWSTATUS_DEFAULT, Constant.ROWSTATUS_INACTIVE);
                        if (isExist)
                        {
                            CriteriaOperator criteria = new BinaryOperator("Code", organizationCode, BinaryOperatorType.Equal);
                            NAS.DAL.Nomenclature.Organization.Organization organ = session.FindObject <NAS.DAL.Nomenclature.Organization.Organization>(criteria);
                            short rowstatus = organ.RowStatus;
                            if (rowstatus > 0)
                            {
                                Utility.Helpers.AddErrorToTreeListNode(e.Errors, "Code", "Mã tổ chức đã tồn tại");
                            }
                        }
                    }
                }
            }
        }
Beispiel #6
0
        public NAS.DAL.Nomenclature.Organization.Organization GetAllocatedCustomerByManualTransaction(Session session, Guid manualBookingTransactionId)
        {
            NAS.DAL.Nomenclature.Organization.Organization ret = null;
            try
            {
                Transaction transaction =
                    session.GetObjectByKey <Transaction>(manualBookingTransactionId);
                TransactionObject transactionObject = transaction.TransactionObjects.First();
                if (transactionObject == null)
                {
                    return(null);
                }
                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.MANUAL_BOOKING_CUSTOMER);

                ObjectCustomField objectCustomField = transactionObject.ObjectId.ObjectCustomFields.Where(
                    r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId ==
                    objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault();
                if (objectCustomField == null)
                {
                    return(null);
                }

                ObjectCustomFieldData objectCustomFieldData =
                    objectCustomField.ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData == null)
                {
                    return(null);
                }

                PredefinitionData predefinitionData =
                    (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

                ret = session.GetObjectByKey <NAS.DAL.Nomenclature.Organization.Organization>(predefinitionData.RefId);

                return(ret);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #7
0
 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);
 }
Beispiel #8
0
        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);
        }