/// <summary>
 /// 供应商首页
 /// </summary>
 /// <returns></returns>
 public ActionResult SupplierIndex(Guid? ParentOrgID = null)
 {
     // 权限验证
     if (!base.CheckPrivilege())
         RedirectToAction("ErrorPage", "Home", new { message = "Sorry you have no privilege to visit the Page" });
     retype = 1;
     Guid? userID = CurrentSession.UserID;
     if (userID != null)
     {
         //获取用户所属组织
         var sessionOrgId = dbEntity.MemberUsers.Where(p => p.Deleted == false && p.Gid == userID).Select(p => p.OrgID).Single();
         gOrgId = sessionOrgId;
     }
     //新建页面model
     PurchaseSupplier oViewModel = new PurchaseSupplier();
     //组织下拉框
     ViewBag.organization = GetSupportOrganizations();
     if (ParentOrgID != null)//有选中的组织
     {
         oViewModel.aParent = ParentOrgID.Value;
         gOrgId = ParentOrgID.Value;//设置全局gOrgId
         SetCurrentPath();//当前程序路径
     }
     return View(oViewModel);
 }
Exemple #2
0
        /// <summary>
        /// 导入组织定义
        /// </summary>
        /// <param name="sExcelFile"></param>
        /// <param name="sSheetName"></param>
        public void ImportOrganizations(string sExcelFile, string sSheetName)
        {
            try
            {
                ExcelData oExcel = new ExcelData(sExcelFile, sSheetName);
                DataColumn colCode = oExcel.ExcelTable.Columns["代码"];
                DataColumn colOstatus = oExcel.ExcelTable.Columns["状态"];
                DataColumn colOtype = oExcel.ExcelTable.Columns["类型"];
                DataColumn colExCode = oExcel.ExcelTable.Columns["扩展代码"];
                DataColumn colExType = oExcel.ExcelTable.Columns["扩展类型"];
                DataColumn colExTypeCode = oExcel.ExcelTable.Columns["类型代码"];
                DataColumn colParent = oExcel.ExcelTable.Columns["上级"];
                DataColumn colTerminal = oExcel.ExcelTable.Columns["末级"];
                DataColumn colFullNameCN = oExcel.ExcelTable.Columns["中文完整名称"];
                DataColumn colFullNameUS = oExcel.ExcelTable.Columns["英文完整名称"];
                DataColumn colShortNameCN = oExcel.ExcelTable.Columns["中文简称"];
                DataColumn colShortNameUS = oExcel.ExcelTable.Columns["英文简称"];
                DataColumn colLocation = oExcel.ExcelTable.Columns["地区"];
                DataColumn colFullAddress = oExcel.ExcelTable.Columns["完整地址"];
                DataColumn colPostCode = oExcel.ExcelTable.Columns["邮政编码"];
                DataColumn colContact = oExcel.ExcelTable.Columns["联系人"];
                DataColumn colCellPhone = oExcel.ExcelTable.Columns["手机"];
                DataColumn colWorkPhone = oExcel.ExcelTable.Columns["电话"];
                DataColumn colWorkFax = oExcel.ExcelTable.Columns["传真"];
                DataColumn colEmail = oExcel.ExcelTable.Columns["电子邮件"];
                DataColumn colHomeUrl = oExcel.ExcelTable.Columns["主页"];
                DataColumn colBrief = oExcel.ExcelTable.Columns["简介"];
                DataColumn colIntroduction = oExcel.ExcelTable.Columns["介绍"];
                DataColumn colPuPolicy = oExcel.ExcelTable.Columns["PU编码规则"];
                DataColumn colSkuPolicy = oExcel.ExcelTable.Columns["SKU编码规则"];
                DataColumn colBarcodePolicy = oExcel.ExcelTable.Columns["条码编码规则"];
                DataColumn colRemark = oExcel.ExcelTable.Columns["备注"];

                foreach (DataRow row in oExcel.ExcelTable.Rows)
                {
                    string sCode = row[colCode].ToString();
                    byte nStatus;
                    Byte.TryParse(row[colOstatus].ToString(), out nStatus);
                    byte nType;
                    Byte.TryParse(row[colOtype].ToString(), out nType);
                    string sExCode = row[colExCode].ToString();

                    byte nExType;
                    Byte.TryParse(row[colExType].ToString(), out nExType);
                    string sExTypeCode = row[colExTypeCode].ToString();
                    var oExType = (from c in dbEntity.GeneralStandardCategorys
                                   where c.Ctype == nExType && c.Code == sExTypeCode
                                   select c).FirstOrDefault();

                    string sParent = row[colParent].ToString();
                    var oParent = (from m in dbEntity.MemberOrganizations
                                   where m.Code == sParent && m.Otype == (byte)ModelEnum.OrganizationType.CORPORATION
                                   select m).FirstOrDefault();

                    bool bLeaf = row[colTerminal].ToString() == "1" ? true : false;
                    GeneralResource oFullName = new GeneralResource(ModelEnum.ResourceType.STRING, 2052, row[colFullNameCN].ToString(), 1033, row[colFullNameUS].ToString());
                    GeneralResource oShortName = new GeneralResource(ModelEnum.ResourceType.STRING, 2052, row[colShortNameCN].ToString(), 1033, row[colShortNameUS].ToString());
                    string sLocation = row[colLocation].ToString();
                    var oLocation = (from r in dbEntity.GeneralRegions
                                     where r.Code == sLocation
                                     select r).FirstOrDefault();

                    string sFullAddress = row[colFullAddress].ToString();
                    string sPostCode = row[colPostCode].ToString();
                    string sContact = row[colContact].ToString();
                    string sCellPhone = row[colCellPhone].ToString();
                    string sWorkPhone = row[colWorkPhone].ToString();
                    string sWorkFax = row[colWorkFax].ToString();
                    string sEmail = row[colEmail].ToString();
                    string sHomeUrl = row[colHomeUrl].ToString();
                    string sBrief = row[colBrief].ToString();
                    string sIntroduction = row[colIntroduction].ToString();
                    string sPuPolicy = row[colPuPolicy].ToString();
                    string sSkuPolicy = row[colSkuPolicy].ToString();
                    string sBarcodePolicy = row[colBarcodePolicy].ToString();
                    string sRemark = row[colRemark].ToString();

                    switch ((ModelEnum.OrganizationType)nType)
                    {
                        case ModelEnum.OrganizationType.CORPORATION:
                            var oOrgan = (from o in dbEntity.MemberOrganizations
                                          where o.Code == sCode && o.Otype == nType
                                          select o).FirstOrDefault();
                            if (oOrgan == null)
                            {
                                oOrgan = new MemberOrganization
                                {
                                    Code = sCode,
                                    Otype = nType
                                };
                                dbEntity.MemberOrganizations.Add(oOrgan);
                            }
                            oOrgan.Ostatus = nStatus;
                            oOrgan.ExCode = sExCode;
                            oOrgan.ExtendType = oExType;
                            oOrgan.Parent = oParent;
                            oOrgan.Terminal = bLeaf;
                            if (oOrgan.FullName == null)
                                oOrgan.FullName = oFullName;
                            else
                                oOrgan.FullName.SetResource(ModelEnum.ResourceType.STRING, oFullName);
                            if (oOrgan.ShortName == null)
                                oOrgan.ShortName = oShortName;
                            else
                                oOrgan.ShortName.SetResource(ModelEnum.ResourceType.STRING, oShortName);
                            oOrgan.Location = oLocation;
                            oOrgan.FullAddress = sFullAddress;
                            oOrgan.PostCode = sPostCode;
                            oOrgan.Contact = sContact;
                            oOrgan.CellPhone = sCellPhone;
                            oOrgan.WorkPhone = sWorkPhone;
                            oOrgan.WorkFax = sWorkFax;
                            oOrgan.Email = sEmail;
                            oOrgan.HomeUrl = sHomeUrl;
                            oOrgan.Brief = sBrief;
                            if (!String.IsNullOrEmpty(sIntroduction))
                            {
                                if (oOrgan.Introduction == null)
                                    oOrgan.Introduction = new GeneralLargeObject(2052, sIntroduction);
                                else
                                    oOrgan.Introduction.SetLargeObject(2052, sIntroduction);
                            }
                            oOrgan.ProdCodePolicy = sPuPolicy;
                            oOrgan.SkuCodePolicy = sSkuPolicy;
                            oOrgan.BarcodePolicy = sBarcodePolicy;
                            oOrgan.Remark = sRemark;
                            dbEntity.SaveChanges();
                            break;
                        case ModelEnum.OrganizationType.CHANNEL:
                            var oChannel = (from o in dbEntity.MemberChannels
                                            where o.Code == sCode && o.Otype == nType
                                            select o).FirstOrDefault();
                            if (oChannel == null)
                            {
                                oChannel = new MemberChannel
                                {
                                    Code = sCode,
                                    Otype = nType
                                };
                                dbEntity.MemberChannels.Add(oChannel);
                            }
                            oChannel.Ostatus = nStatus;
                            oChannel.ExCode = sExCode;
                            oChannel.ExtendType = oExType;
                            oChannel.Parent = oParent;
                            oChannel.Terminal = bLeaf;
                            if (oChannel.FullName == null)
                                oChannel.FullName = oFullName;
                            else
                                oChannel.FullName.SetResource(ModelEnum.ResourceType.STRING, oFullName);
                            if (oChannel.ShortName == null)
                                oChannel.ShortName = oShortName;
                            else
                                oChannel.ShortName.SetResource(ModelEnum.ResourceType.STRING, oShortName);
                            oChannel.Location = oLocation;
                            oChannel.FullAddress = sFullAddress;
                            oChannel.PostCode = sPostCode;
                            oChannel.Contact = sContact;
                            oChannel.CellPhone = sCellPhone;
                            oChannel.WorkPhone = sWorkPhone;
                            oChannel.WorkFax = sWorkFax;
                            oChannel.Email = sEmail;
                            oChannel.HomeUrl = sHomeUrl;
                            oChannel.Brief = sBrief;
                            if (!String.IsNullOrEmpty(sIntroduction))
                            {
                                if (oChannel.Introduction == null)
                                    oChannel.Introduction = new GeneralLargeObject(2052, sIntroduction);
                                else
                                    oChannel.Introduction.SetLargeObject(2052, sIntroduction);
                            }
                            oChannel.ProdCodePolicy = sPuPolicy;
                            oChannel.SkuCodePolicy = sSkuPolicy;
                            oChannel.BarcodePolicy = sBarcodePolicy;
                            oChannel.Remark = sRemark;
                            dbEntity.SaveChanges();
                            break;
                        case ModelEnum.OrganizationType.SHIPPER:
                            var oShipper = (from o in dbEntity.ShippingInformations
                                            where o.Code == sCode && o.Otype == nType
                                            select o).FirstOrDefault();
                            if (oShipper == null)
                            {
                                oShipper = new ShippingInformation
                                {
                                    Code = sCode,
                                    Otype = nType
                                };
                                dbEntity.ShippingInformations.Add(oShipper);
                            }
                            oShipper.Ostatus = nStatus;
                            oShipper.ExCode = sExCode;
                            oShipper.ExtendType = oExType;
                            oShipper.Parent = oParent;
                            oShipper.Terminal = bLeaf;
                            if (oShipper.FullName == null)
                                oShipper.FullName = oFullName;
                            else
                                oShipper.FullName.SetResource(ModelEnum.ResourceType.STRING, oFullName);
                            if (oShipper.ShortName == null)
                                oShipper.ShortName = oShortName;
                            else
                                oShipper.ShortName.SetResource(ModelEnum.ResourceType.STRING, oShortName);
                            oShipper.Location = oLocation;
                            oShipper.FullAddress = sFullAddress;
                            oShipper.PostCode = sPostCode;
                            oShipper.Contact = sContact;
                            oShipper.CellPhone = sCellPhone;
                            oShipper.WorkPhone = sWorkPhone;
                            oShipper.WorkFax = sWorkFax;
                            oShipper.Email = sEmail;
                            oShipper.HomeUrl = sHomeUrl;
                            oShipper.Brief = sBrief;
                            if (!String.IsNullOrEmpty(sIntroduction))
                            {
                                if (oShipper.Introduction == null)
                                    oShipper.Introduction = new GeneralLargeObject(2052, sIntroduction);
                                else
                                    oShipper.Introduction.SetLargeObject(2052, sIntroduction);
                            }
                            oShipper.ProdCodePolicy = sPuPolicy;
                            oShipper.SkuCodePolicy = sSkuPolicy;
                            oShipper.BarcodePolicy = sBarcodePolicy;
                            oShipper.Remark = sRemark;
                            dbEntity.SaveChanges();
                            break;
                        case ModelEnum.OrganizationType.SUPPLIER:
                            var oSupplier = (from o in dbEntity.PurchaseSuppliers
                                             where o.Code == sCode && o.Otype == nType
                                             select o).FirstOrDefault();
                            if (oSupplier == null)
                            {
                                oSupplier = new PurchaseSupplier
                                {
                                    Code = sCode,
                                    Otype = nType
                                };
                                dbEntity.PurchaseSuppliers.Add(oSupplier);
                            }
                            oSupplier.Ostatus = nStatus;
                            oSupplier.ExCode = sExCode;
                            oSupplier.ExtendType = oExType;
                            oSupplier.Parent = oParent;
                            oSupplier.Terminal = bLeaf;
                            if (oSupplier.FullName == null)
                                oSupplier.FullName = oFullName;
                            else
                                oSupplier.FullName.SetResource(ModelEnum.ResourceType.STRING, oFullName);
                            if (oSupplier.ShortName == null)
                                oSupplier.ShortName = oShortName;
                            else
                                oSupplier.ShortName.SetResource(ModelEnum.ResourceType.STRING, oShortName);
                            oSupplier.Location = oLocation;
                            oSupplier.FullAddress = sFullAddress;
                            oSupplier.PostCode = sPostCode;
                            oSupplier.Contact = sContact;
                            oSupplier.CellPhone = sCellPhone;
                            oSupplier.WorkPhone = sWorkPhone;
                            oSupplier.WorkFax = sWorkFax;
                            oSupplier.Email = sEmail;
                            oSupplier.HomeUrl = sHomeUrl;
                            oSupplier.Brief = sBrief;
                            if (!String.IsNullOrEmpty(sIntroduction))
                            {
                                if (oSupplier.Introduction == null)
                                    oSupplier.Introduction = new GeneralLargeObject(2052, sIntroduction);
                                else
                                    oSupplier.Introduction.SetLargeObject(2052, sIntroduction);
                            }
                            oSupplier.ProdCodePolicy = sPuPolicy;
                            oSupplier.SkuCodePolicy = sSkuPolicy;
                            oSupplier.BarcodePolicy = sBarcodePolicy;
                            oSupplier.Remark = sRemark;
                            dbEntity.SaveChanges();
                            break;
                        case ModelEnum.OrganizationType.WAREHOUSE:
                            var oWarehouse = (from o in dbEntity.WarehouseInformations
                                              where o.Code == sCode && o.Otype == nType
                                              select o).FirstOrDefault();
                            if (oWarehouse == null)
                            {
                                oWarehouse = new WarehouseInformation
                                {
                                    Code = sCode,
                                    Otype = nType
                                };
                                dbEntity.WarehouseInformations.Add(oWarehouse);
                            }
                            oWarehouse.Ostatus = nStatus;
                            oWarehouse.ExCode = sExCode;
                            oWarehouse.ExtendType = oExType;
                            oWarehouse.Parent = oParent;
                            oWarehouse.Terminal = bLeaf;
                            if (oWarehouse.FullName == null)
                                oWarehouse.FullName = oFullName;
                            else
                                oWarehouse.FullName.SetResource(ModelEnum.ResourceType.STRING, oFullName);
                            if (oWarehouse.ShortName == null)
                                oWarehouse.ShortName = oShortName;
                            else
                                oWarehouse.ShortName.SetResource(ModelEnum.ResourceType.STRING, oShortName);
                            oWarehouse.Location = oLocation;
                            oWarehouse.FullAddress = sFullAddress;
                            oWarehouse.PostCode = sPostCode;
                            oWarehouse.Contact = sContact;
                            oWarehouse.CellPhone = sCellPhone;
                            oWarehouse.WorkPhone = sWorkPhone;
                            oWarehouse.WorkFax = sWorkFax;
                            oWarehouse.Email = sEmail;
                            oWarehouse.HomeUrl = sHomeUrl;
                            oWarehouse.Brief = sBrief;
                            if (!String.IsNullOrEmpty(sIntroduction))
                            {
                                if (oWarehouse.Introduction == null)
                                    oWarehouse.Introduction = new GeneralLargeObject(2052, sIntroduction);
                                else
                                    oWarehouse.Introduction.SetLargeObject(2052, sIntroduction);
                            }
                            oWarehouse.ProdCodePolicy = sPuPolicy;
                            oWarehouse.SkuCodePolicy = sSkuPolicy;
                            oWarehouse.BarcodePolicy = sBarcodePolicy;
                            oWarehouse.Remark = sRemark;
                            dbEntity.SaveChanges();
                            break;
                    }
                    if (Utility.ConfigHelper.GlobalConst.IsDebug)
                        Debug.WriteLine("{0} {1} {2}", this.ToString(), sCode, oFullName.Matter);
                }
                oEventBLL.WriteEvent(String.Format("导入MemberOrganization成功: {0} {1}", sExcelFile, sSheetName),
                    ModelEnum.ActionLevel.GENERIC, ModelEnum.ActionSource.SYSTEM, this.ToString());
            }
            catch (Exception ex)
            {
                oEventBLL.WriteEvent(String.Format("导入MemberOrganization错误: {0} {1} {2}", sExcelFile, sSheetName, ex.Message),
                    ModelEnum.ActionLevel.ERROR, ModelEnum.ActionSource.SYSTEM, this.ToString());
            }
        }
 /// <summary>
 /// 保存组织
 /// </summary>
 /// <param name="oOrganization"></param>
 public void SaveEditOrgDetail(OrganizationBase oBackModel)
 {
     if (oBackModel.Gid != Guid.Empty)//编辑保存
     {
         OrganizationBase oOldOrganization = new OrganizationBase { FullName = NewResource(ModelEnum.ResourceType.STRING, oBackModel.aParent), ShortName = NewResource(ModelEnum.ResourceType.STRING, oBackModel.aParent) };
         switch (oBackModel.Otype)
         {
             case 0: oOldOrganization = dbEntity.MemberOrganizations.Include("FullName").Include("ShortName").Where(o => o.Gid == oBackModel.Gid).FirstOrDefault(); break;
             case 1: oOldOrganization = dbEntity.MemberChannels.Include("FullName").Include("ShortName").Where(c => c.Gid == oBackModel.Gid).FirstOrDefault(); break;
             case 2: oOldOrganization = dbEntity.WarehouseInformations.Include("FullName").Include("ShortName").Where(c => c.Gid == oBackModel.Gid).FirstOrDefault(); break;
             case 3: oOldOrganization = dbEntity.PurchaseSuppliers.Include("FullName").Include("ShortName").Where(c => c.Gid == oBackModel.Gid).FirstOrDefault(); break;
             case 4: oOldOrganization = dbEntity.ShippingInformations.Include("FullName").Include("ShortName").Where(c => c.Gid == oBackModel.Gid).FirstOrDefault(); break;
         }
         oOldOrganization.FullName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.FullName);
         oOldOrganization.ShortName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.ShortName);
         oOldOrganization.Code = oBackModel.Code;
         oOldOrganization.ExCode = oBackModel.ExCode;
         oOldOrganization.Ostatus = oBackModel.Ostatus;
         oOldOrganization.Otype = oBackModel.Otype;
         oOldOrganization.ExType = oBackModel.ExType;
         oOldOrganization.Terminal = oBackModel.Terminal;
         oOldOrganization.aLocation = oBackModel.aLocation;
         oOldOrganization.FullAddress = oBackModel.FullAddress;
         oOldOrganization.PostCode = oBackModel.PostCode;
         oOldOrganization.Contact = oBackModel.Contact;
         oOldOrganization.CellPhone = oBackModel.CellPhone;
         oOldOrganization.WorkPhone = oBackModel.WorkPhone;
         oOldOrganization.WorkFax = oBackModel.WorkFax;
         oOldOrganization.Email = oBackModel.Email;
         oOldOrganization.HomeUrl = oBackModel.HomeUrl;
         oOldOrganization.Sorting = oBackModel.Sorting;
         oOldOrganization.Brief = oBackModel.Brief;
         oOldOrganization.Remark = oBackModel.Remark;
     }
     else//添加保存
     {
         switch (oBackModel.Otype)
         {
             case 0: break;
             case 1: MemberChannel oNewMemberChannel = dbEntity.MemberChannels.Include("FullName").Include("ShortName").Where(o => o.Code == oBackModel.Code).FirstOrDefault();
                 if (oNewMemberChannel != null)//原来存在,则是编辑
                 {
                     oNewMemberChannel.Deleted = false;
                     oNewMemberChannel.FullName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.FullName);
                     oNewMemberChannel.ShortName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.ShortName);
                     //oNewMemberChannel.Code = oBackModel.Code;
                     oNewMemberChannel.ExCode = oBackModel.ExCode;
                     oNewMemberChannel.Ostatus = oBackModel.Ostatus;
                     //oNewMemberChannel.Otype = oBackModel.Otype;
                     oNewMemberChannel.ExType = oBackModel.ExType;
                     oNewMemberChannel.Terminal = oBackModel.Terminal;
                     oNewMemberChannel.aLocation = oBackModel.aLocation;
                     oNewMemberChannel.FullAddress = oBackModel.FullAddress;
                     oNewMemberChannel.PostCode = oBackModel.PostCode;
                     oNewMemberChannel.Contact = oBackModel.Contact;
                     oNewMemberChannel.CellPhone = oBackModel.CellPhone;
                     oNewMemberChannel.WorkPhone = oBackModel.WorkPhone;
                     oNewMemberChannel.WorkFax = oBackModel.WorkFax;
                     oNewMemberChannel.Email = oBackModel.Email;
                     oNewMemberChannel.HomeUrl = oBackModel.HomeUrl;
                     oNewMemberChannel.Sorting = oBackModel.Sorting;
                     oNewMemberChannel.Brief = oBackModel.Brief;
                     oNewMemberChannel.Remark = oBackModel.Remark;
                 }
                 else
                 {
                     oNewMemberChannel = new MemberChannel { FullName = NewResource(ModelEnum.ResourceType.STRING), ShortName = NewResource(ModelEnum.ResourceType.STRING) };
                     oNewMemberChannel.FullName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.FullName);
                     oNewMemberChannel.ShortName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.ShortName);
                     oNewMemberChannel.Code = oBackModel.Code;
                     oNewMemberChannel.ExCode = oBackModel.ExCode;
                     oNewMemberChannel.Ostatus = oBackModel.Ostatus;
                     oNewMemberChannel.Otype = oBackModel.Otype;
                     oNewMemberChannel.ExType = oBackModel.ExType;
                     oNewMemberChannel.Terminal = oBackModel.Terminal;
                     oNewMemberChannel.aLocation = oBackModel.aLocation;
                     oNewMemberChannel.FullAddress = oBackModel.FullAddress;
                     oNewMemberChannel.PostCode = oBackModel.PostCode;
                     oNewMemberChannel.Contact = oBackModel.Contact;
                     oNewMemberChannel.CellPhone = oBackModel.CellPhone;
                     oNewMemberChannel.WorkPhone = oBackModel.WorkPhone;
                     oNewMemberChannel.WorkFax = oBackModel.WorkFax;
                     oNewMemberChannel.Email = oBackModel.Email;
                     oNewMemberChannel.HomeUrl = oBackModel.HomeUrl;
                     oNewMemberChannel.Sorting = oBackModel.Sorting;
                     oNewMemberChannel.Brief = oBackModel.Brief;
                     oNewMemberChannel.Remark = oBackModel.Remark;
                     dbEntity.MemberChannels.Add(oNewMemberChannel);
                 }
                 break;
             case 2: WarehouseInformation oNewWarehouse = dbEntity.WarehouseInformations.Include("FullName").Include("ShortName").Where(w => w.Code == oBackModel.Code).FirstOrDefault();
                 if (oNewWarehouse != null)
                 {
                     oNewWarehouse.Deleted = false;
                     oNewWarehouse.FullName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.FullName);
                     oNewWarehouse.ShortName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.ShortName);
                     //oNewWarehouse.aParent = oBackModel.aParent;
                     //oNewWarehouse.Code = oBackModel.Code;
                     oNewWarehouse.ExCode = oBackModel.ExCode;
                     oNewWarehouse.Ostatus = oBackModel.Ostatus;
                     //oNewWarehouse.Otype = oBackModel.Otype;
                     oNewWarehouse.ExType = oBackModel.ExType;
                     oNewWarehouse.Terminal = oBackModel.Terminal;
                     oNewWarehouse.aLocation = oBackModel.aLocation;
                     oNewWarehouse.FullAddress = oBackModel.FullAddress;
                     oNewWarehouse.PostCode = oBackModel.PostCode;
                     oNewWarehouse.Contact = oBackModel.Contact;
                     oNewWarehouse.CellPhone = oBackModel.CellPhone;
                     oNewWarehouse.WorkPhone = oBackModel.WorkPhone;
                     oNewWarehouse.WorkFax = oBackModel.WorkFax;
                     oNewWarehouse.Email = oBackModel.Email;
                     oNewWarehouse.HomeUrl = oBackModel.HomeUrl;
                     oNewWarehouse.Sorting = oBackModel.Sorting;
                     oNewWarehouse.Brief = oBackModel.Brief;
                     oNewWarehouse.Remark = oBackModel.Remark;
                 }
                 else
                 {
                     oNewWarehouse = new WarehouseInformation { FullName = NewResource(ModelEnum.ResourceType.STRING, oBackModel.aParent), ShortName = NewResource(ModelEnum.ResourceType.STRING, oBackModel.aParent) };
                     oNewWarehouse.FullName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.FullName);
                     oNewWarehouse.ShortName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.ShortName);
                     oNewWarehouse.aParent = oBackModel.aParent;
                     oNewWarehouse.Code = oBackModel.Code;
                     oNewWarehouse.ExCode = oBackModel.ExCode;
                     oNewWarehouse.Ostatus = oBackModel.Ostatus;
                     oNewWarehouse.Otype = oBackModel.Otype;
                     oNewWarehouse.ExType = oBackModel.ExType;
                     oNewWarehouse.Terminal = oBackModel.Terminal;
                     oNewWarehouse.aLocation = oBackModel.aLocation;
                     oNewWarehouse.FullAddress = oBackModel.FullAddress;
                     oNewWarehouse.PostCode = oBackModel.PostCode;
                     oNewWarehouse.Contact = oBackModel.Contact;
                     oNewWarehouse.CellPhone = oBackModel.CellPhone;
                     oNewWarehouse.WorkPhone = oBackModel.WorkPhone;
                     oNewWarehouse.WorkFax = oBackModel.WorkFax;
                     oNewWarehouse.Email = oBackModel.Email;
                     oNewWarehouse.HomeUrl = oBackModel.HomeUrl;
                     oNewWarehouse.Sorting = oBackModel.Sorting;
                     oNewWarehouse.Brief = oBackModel.Brief;
                     oNewWarehouse.Remark = oBackModel.Remark;
                     dbEntity.WarehouseInformations.Add(oNewWarehouse);
                 }
                 break;
             case 3: PurchaseSupplier oNewPurchaseSupplier = dbEntity.PurchaseSuppliers.Include("FullName").Include("ShortName").Where(s => s.Code == oBackModel.Code).FirstOrDefault();
                 if (oNewPurchaseSupplier != null)
                 {
                     oNewPurchaseSupplier.Deleted = false;
                     oNewPurchaseSupplier.FullName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.FullName);
                     oNewPurchaseSupplier.ShortName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.ShortName);
                     //oNewPurchaseSupplier.aParent = oBackModel.aParent;
                     //oNewPurchaseSupplier.Code = oBackModel.Code;
                     oNewPurchaseSupplier.ExCode = oBackModel.ExCode;
                     oNewPurchaseSupplier.Ostatus = oBackModel.Ostatus;
                     //oNewPurchaseSupplier.Otype = oBackModel.Otype;
                     oNewPurchaseSupplier.ExType = oBackModel.ExType;
                     oNewPurchaseSupplier.Terminal = oBackModel.Terminal;
                     oNewPurchaseSupplier.aLocation = oBackModel.aLocation;
                     oNewPurchaseSupplier.FullAddress = oBackModel.FullAddress;
                     oNewPurchaseSupplier.PostCode = oBackModel.PostCode;
                     oNewPurchaseSupplier.Contact = oBackModel.Contact;
                     oNewPurchaseSupplier.CellPhone = oBackModel.CellPhone;
                     oNewPurchaseSupplier.WorkPhone = oBackModel.WorkPhone;
                     oNewPurchaseSupplier.WorkFax = oBackModel.WorkFax;
                     oNewPurchaseSupplier.Email = oBackModel.Email;
                     oNewPurchaseSupplier.HomeUrl = oBackModel.HomeUrl;
                     oNewPurchaseSupplier.Sorting = oBackModel.Sorting;
                     oNewPurchaseSupplier.Brief = oBackModel.Brief;
                     oNewPurchaseSupplier.Remark = oBackModel.Remark;
                 }
                 else
                 {
                     oNewPurchaseSupplier = new PurchaseSupplier { FullName = NewResource(ModelEnum.ResourceType.STRING, oBackModel.aParent), ShortName = NewResource(ModelEnum.ResourceType.STRING, oBackModel.aParent) };
                     oNewPurchaseSupplier.FullName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.FullName);
                     oNewPurchaseSupplier.ShortName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.ShortName);
                     oNewPurchaseSupplier.aParent = oBackModel.aParent;
                     oNewPurchaseSupplier.Code = oBackModel.Code;
                     oNewPurchaseSupplier.ExCode = oBackModel.ExCode;
                     oNewPurchaseSupplier.Ostatus = oBackModel.Ostatus;
                     oNewPurchaseSupplier.Otype = oBackModel.Otype;
                     oNewPurchaseSupplier.ExType = oBackModel.ExType;
                     oNewPurchaseSupplier.Terminal = oBackModel.Terminal;
                     oNewPurchaseSupplier.aLocation = oBackModel.aLocation;
                     oNewPurchaseSupplier.FullAddress = oBackModel.FullAddress;
                     oNewPurchaseSupplier.PostCode = oBackModel.PostCode;
                     oNewPurchaseSupplier.Contact = oBackModel.Contact;
                     oNewPurchaseSupplier.CellPhone = oBackModel.CellPhone;
                     oNewPurchaseSupplier.WorkPhone = oBackModel.WorkPhone;
                     oNewPurchaseSupplier.WorkFax = oBackModel.WorkFax;
                     oNewPurchaseSupplier.Email = oBackModel.Email;
                     oNewPurchaseSupplier.HomeUrl = oBackModel.HomeUrl;
                     oNewPurchaseSupplier.Sorting = oBackModel.Sorting;
                     oNewPurchaseSupplier.Brief = oBackModel.Brief;
                     oNewPurchaseSupplier.Remark = oBackModel.Remark;
                     dbEntity.PurchaseSuppliers.Add(oNewPurchaseSupplier);
                 }
                 break;
             case 4: ShippingInformation oNewShippingInformations = dbEntity.ShippingInformations.Include("FullName").Include("ShortName").Where(s => s.Code == oBackModel.Code).FirstOrDefault();
                 if (oNewShippingInformations != null)
                 {
                     oNewShippingInformations.Deleted = false;
                     oNewShippingInformations.FullName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.FullName);
                     oNewShippingInformations.ShortName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.ShortName);
                     //oNewShippingInformations.aParent = oBackModel.aParent;
                     //oNewShippingInformations.Code = oBackModel.Code;
                     oNewShippingInformations.ExCode = oBackModel.ExCode;
                     oNewShippingInformations.Ostatus = oBackModel.Ostatus;
                     //oNewShippingInformations.Otype = oBackModel.Otype;
                     oNewShippingInformations.ExType = oBackModel.ExType;
                     oNewShippingInformations.Terminal = oBackModel.Terminal;
                     oNewShippingInformations.aLocation = oBackModel.aLocation;
                     oNewShippingInformations.FullAddress = oBackModel.FullAddress;
                     oNewShippingInformations.PostCode = oBackModel.PostCode;
                     oNewShippingInformations.Contact = oBackModel.Contact;
                     oNewShippingInformations.CellPhone = oBackModel.CellPhone;
                     oNewShippingInformations.WorkPhone = oBackModel.WorkPhone;
                     oNewShippingInformations.WorkFax = oBackModel.WorkFax;
                     oNewShippingInformations.Email = oBackModel.Email;
                     oNewShippingInformations.HomeUrl = oBackModel.HomeUrl;
                     oNewShippingInformations.Sorting = oBackModel.Sorting;
                     oNewShippingInformations.Brief = oBackModel.Brief;
                     oNewShippingInformations.Remark = oBackModel.Remark;
                 }
                 else
                 {
                     oNewShippingInformations = new ShippingInformation { FullName = NewResource(ModelEnum.ResourceType.STRING, oBackModel.aParent), ShortName = NewResource(ModelEnum.ResourceType.STRING, oBackModel.aParent) };
                     oNewShippingInformations.FullName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.FullName);
                     oNewShippingInformations.ShortName.SetResource(ModelEnum.ResourceType.STRING, oBackModel.ShortName);
                     oNewShippingInformations.aParent = oBackModel.aParent;
                     oNewShippingInformations.Code = oBackModel.Code;
                     oNewShippingInformations.ExCode = oBackModel.ExCode;
                     oNewShippingInformations.Ostatus = oBackModel.Ostatus;
                     oNewShippingInformations.Otype = oBackModel.Otype;
                     oNewShippingInformations.ExType = oBackModel.ExType;
                     oNewShippingInformations.Terminal = oBackModel.Terminal;
                     oNewShippingInformations.aLocation = oBackModel.aLocation;
                     oNewShippingInformations.FullAddress = oBackModel.FullAddress;
                     oNewShippingInformations.PostCode = oBackModel.PostCode;
                     oNewShippingInformations.Contact = oBackModel.Contact;
                     oNewShippingInformations.CellPhone = oBackModel.CellPhone;
                     oNewShippingInformations.WorkPhone = oBackModel.WorkPhone;
                     oNewShippingInformations.WorkFax = oBackModel.WorkFax;
                     oNewShippingInformations.Email = oBackModel.Email;
                     oNewShippingInformations.HomeUrl = oBackModel.HomeUrl;
                     oNewShippingInformations.Sorting = oBackModel.Sorting;
                     oNewShippingInformations.Brief = oBackModel.Brief;
                     oNewShippingInformations.Remark = oBackModel.Remark;
                     dbEntity.ShippingInformations.Add(oNewShippingInformations);
                 }
                 break;
         }
     }
     dbEntity.SaveChanges();
 }