コード例 #1
0
ファイル: DataTransferBLL.cs プロジェクト: NH4CL/UniProject
        /// <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());
            }
        }
コード例 #2
0
ファイル: OrderController.cs プロジェクト: NH4CL/UniProject
        //public ActionResult OrderSupportShippingList()
        //{
        //    return View();
        //}
        ///// <summary>
        ///// 编辑订单时候显示的承运商列表
        ///// </summary>
        ///// <param name="searchModel"></param>
        ///// <returns></returns>
        //public ActionResult ListOrderSupportShipping(SearchModel searchModel)
        //{
        //    //需要对应全局的订单Guid
        //    Guid orderGid = oNewOrder.Gid;
        //    IQueryable<OrderShipping> oOrderShipping = dbEntity.OrderShippings.Include("Order").Include("Shipper").Where(p => p.Deleted == false && p.OrderID == orderGid).AsQueryable();
        //    GridColumnModelList<OrderShipping> columns = new GridColumnModelList<OrderShipping>();
        //    columns.Add(p => p.Gid).SetAsPrimaryKey();
        //    columns.Add(p => p.Shipper.FullName.GetResource(CurrentSession.Culture)).SetName("ShipperName");
        //    columns.Add(p => p.ShipWeight);
        //    columns.Add(p => p.ShippingCheckName).SetName("ShipStatus");
        //    columns.Add(p => p.Candidate);
        //    columns.Add(p => p.Remark);
        //    GridData gridData = oOrderShipping.ToGridData(searchModel, columns);
        //    return Json(gridData, JsonRequestBehavior.AllowGet);
        //}
        /// <summary>
        /// 添加订单时列出支持的承运商
        /// </summary>
        /// <returns></returns>
        public ActionResult ShippingListShow()
        {
            OrderBLL oOrderBLL = new OrderBLL(this.dbEntity);//新建oOrderBLL对象
            List<ShippingInformation> oShippingList = new List<ShippingInformation>();
            List<SelectListItem> shippinglist = new List<SelectListItem>();
            if (oNewOrder.WhID != null && oNewOrder.aLocation != null && listNewOrderItem.Count>=1)
            {
                //-----------edit by 2011/10/24 需求:手动编辑订单是可以选择所有组织支持的承运商
                //获取支持的承运商列表
                //oShippingList = oOrderBLL.GetSupportShippings(listNewOrderItem, (Guid)oNewOrder.WhID, (Guid)oNewOrder.aLocation);
                //获取组织支持的所有承运商
                oShippingList = dbEntity.ShippingInformations.Where(s => s.aParent == oNewOrder.OrgID && s.Deleted == false).ToList();
                //------------------------------------------------------------------------------

                listNewOrderShipping.Clear();//每次都清除之前的承运商列表,以保证该列表永远是最新的-----BUG修改09.25
                if (oShippingList.Count > 0)
                {
                    for (int i = 0; i < oShippingList.Count; i++)
                    {
                        OrderShipping oNewOrderShipping = new OrderShipping
                        {
                            ShipID = oShippingList.ElementAt(i).Gid,
                            Order = oNewOrder
                        };
                        listNewOrderShipping.Add(oNewOrderShipping);
                        shippinglist.Add(new SelectListItem { Text = oShippingList.ElementAt(i).FullName.GetResource(CurrentSession.Culture), Value = oShippingList.ElementAt(i).Gid.ToString() });
                    }
                    oNewShipper = oShippingList.ElementAt(0);//默认选中权重最大的,即通过排序查找出的列表的第一个
                    foreach (var reg in oOrderBLL.GetFullRegions((Guid)oNewOrder.aLocation))
                    {
                        if (oNewShipper.Areas != null)//支持区域不为空
                        {
                            foreach (var area in oNewShipper.Areas)
                            {
                                if (area.RegionID == reg.Gid)
                                {
                                    oNewOrder.ResidenceFee = area.Residential == null? 0:area.Residential.GetResource((Guid)oNewOrder.aCurrency);//收取的到门费
                                    oNewOrder.LiftGateFee = area.LiftGate == null? 0:area.LiftGate.GetResource((Guid)oNewOrder.aCurrency);//收取的上楼费
                                    oNewOrder.InstallFee = area.Installation == null? 0:area.Installation.GetResource((Guid)oNewOrder.aCurrency);//收取的安装费
                                }
                            }
                        }
                    }
                }
                else//未找到符合的承运商
                {
                    oNewShipper = new ShippingInformation();
                }
            }
            ViewBag.shippinglist = shippinglist;

            return View();
        }
コード例 #3
0
ファイル: ModelTestAngel.cs プロジェクト: NH4CL/UniProject
 public void ProductOnShippingTest()
 {
     ProductOnSale oProd = ProductOnSaleTest();
     ProductOnItem oSku = ProductOnItemTest();
     ShippingInformation shipper = new ShippingInformation
     {
         Code = GetRandCode()
     };
     oLiveEntities.ShippingInformations.Add(shipper);
     ProductOnShipping ship = new ProductOnShipping
     {
         OnSale = oProd,
         Shipper = shipper
     };
     oLiveEntities.ProductOnShippings.Add(ship);
     oLiveEntities.SaveChanges();
 }
コード例 #4
0
ファイル: OrderController.cs プロジェクト: NH4CL/UniProject
 /// <summary>
 /// 查看选择的订单信息
 /// </summary>
 /// <param name="orderGid"></param>
 /// <returns></returns>
 public string SetViewOrderInfo(Guid orderGid)
 {
     //查询出查看的订单信息
     OrderInformation oViewOrder = dbEntity.OrderInformations.Include("Organization").Include("Channel").Include("User").Include("Warehouse").Include("PayType").Include("Currency").Include("Location").Include("OrderItems").Include("OrderProcesses").Include("OrderAttributes").Include("OrderHistories").Where(p => p.Gid == orderGid && p.Deleted == false).FirstOrDefault();
     //设置订单页面编辑状态
     if (oViewOrder.Hanged == (byte)ModelEnum.HangStatus.HANGED)
         bChangeOrder = true;
     else
         bChangeOrder = false;
     if (oViewOrder.Equals(null))
     {
         return "failure";
     }
     oNewOrder = oViewOrder;
     listNewOrderItem.Clear();//清空缓存区商品列表
     foreach (OrderItem item in oNewOrder.OrderItems)
     {
         OrderItem obj = dbEntity.OrderItems.Include("OnSkuItem").Include("SkuItem").Where(o => o.Gid == item.Gid && o.Deleted==false).FirstOrDefault();
         if (obj != null)
             listNewOrderItem.Add(obj);
     }
     listNewOrderShipping.Clear();//清空缓存区承运商列表
     oNewShipper = new ShippingInformation();
     //-----------------------------------------------------------------edit by 2011/10/24 手工订单编辑可以选择该组织所有支持的承运商
     //foreach (OrderShipping ship in oNewOrder.OrderShippings)
     //{
     //    OrderShipping obj = dbEntity.OrderShippings.Include("Shipper").Where(o => o.Gid == ship.Gid && o.Deleted == false).FirstOrDefault();
     //    if (obj != null)
     //    {
     //        if (obj.Candidate)//将原MODEL中选中的承运商赋给oNewShipper
     //            oNewShipper = obj.Shipper;
     //        listNewOrderShipping.Add(obj);
     //    }
     //}
     List<ShippingInformation> listOrgShippers = dbEntity.ShippingInformations.Where(s => s.Deleted == false && s.aParent == oNewOrder.OrgID).ToList();//组织支持的承运商
     foreach (ShippingInformation ship in listOrgShippers)
     {
         OrderShipping oShip = new OrderShipping {  OrderID = oNewOrder.Gid,ShipID = ship.Gid};
         listNewOrderShipping.Add(oShip);
     }
     foreach (OrderShipping ship in oNewOrder.OrderShippings)
     {
         OrderShipping obj = dbEntity.OrderShippings.Include("Shipper").Where(o => o.Gid == ship.Gid && o.Deleted == false).FirstOrDefault();
         if (obj != null)
         {
             if (obj.Candidate)//将原MODEL中选中的承运商赋给oNewShipper
                 oNewShipper = obj.Shipper;
         }
     }
     //---------------------------------------------------------------------------------------------------------------------------------
     return "success";
 }
コード例 #5
0
ファイル: OrderController.cs プロジェクト: NH4CL/UniProject
        /// <summary>
        /// 编辑订单时列出支持的承运商
        /// </summary>
        /// <returns></returns>
        public void EditShippingListShow()
        {
            OrderBLL oOrderBLL = new OrderBLL(this.dbEntity);//新建oOrderBLL对象
            oNewShipper = dbEntity.ShippingInformations.Find(oNewShipper.Gid);
            List<ShippingInformation> oShippingList = new List<ShippingInformation>();
            List<SelectListItem> shippinglist = new List<SelectListItem>();
            if (oNewOrder.WhID != null && oNewOrder.aLocation != null && listNewOrderItem.Count >= 1)
            {
                //-----------edit by 2011/10/24 需求:手动编辑订单是可以选择所有组织支持的承运商
                //获取支持的承运商列表
                //oShippingList = oOrderBLL.GetSupportShippings(listNewOrderItem, (Guid)oNewOrder.WhID, (Guid)oNewOrder.aLocation);
                //获取组织支持的所有承运商
                oShippingList = dbEntity.ShippingInformations.Where(s => s.aParent == oNewOrder.OrgID && s.Deleted == false).ToList();
                //------------------------------------------------------------------------------

                listNewOrderShipping.Clear();//每次都清除之前的承运商列表,以保证该列表永远是最新的-----BUG修改09.25
                if (oShippingList.Count >= 1)//如果查出承运商
                {
                    for (int i = 0; i < oShippingList.Count; i++)
                    {
                        OrderShipping oNewOrderShipping = new OrderShipping
                        {
                            ShipID = oShippingList.ElementAt(i).Gid,
                            Order = oNewOrder
                        };
                        listNewOrderShipping.Add(oNewOrderShipping);
                    }
                    if (oNewShipper == null)//如果之前没有承运商的
                    {
                        oNewShipper = oShippingList.ElementAt(0);
                    }
                    foreach (var reg in oOrderBLL.GetFullRegions((Guid)oNewOrder.aLocation))
                    {
                        if (oNewShipper.Areas != null)//地区不为空
                        {
                            foreach (var area in oNewShipper.Areas)
                            {
                                if (area.RegionID == reg.Gid)
                                {
                                    oNewOrder.ResidenceFee = area.Residential == null ? 0 : area.Residential.GetResource((Guid)oNewOrder.aCurrency);//收取的到门费
                                    oNewOrder.LiftGateFee = area.LiftGate == null ? 0 : area.LiftGate.GetResource((Guid)oNewOrder.aCurrency);//收取的上楼费
                                    oNewOrder.InstallFee = area.Installation == null ? 0 : area.Installation.GetResource((Guid)oNewOrder.aCurrency);//收取的安装费
                                }
                            }
                        }
                    }
                }
                else//未找到符合的承运商
                {
                    oNewShipper = new ShippingInformation();
                }
            }
            else//错误:仓库ID 地区ID 不能为空 且 订单商品列表不为空
            {

            }
        }
コード例 #6
0
ファイル: OrderController.cs プロジェクト: NH4CL/UniProject
 /// <summary>
 /// 前台页面改变所选的承运商
 /// </summary>
 /// <param name="shipperID">传回的承运商ID</param>
 public void ChangeShipper(Guid shipperID)
 {
     oNewShipper = dbEntity.ShippingInformations.Find(shipperID);
 }
コード例 #7
0
        /// <summary>
        /// 承运商首页
        /// </summary>
        /// <returns></returns>
        public ActionResult ShippingIndex(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
            ShippingInformation oViewModel = new ShippingInformation();
            //组织下拉框
            ViewBag.organization = GetSupportOrganizations();
            if (ParentOrgID != null)//有选中的组织
            {
                //ViewBag.IsFromOrg = true;
                oViewModel.aParent = ParentOrgID.Value;
                //组织下拉框为ParentOrgID的组织
                //MemberOrganization oParentOrg = dbEntity.MemberOrganizations.Where(o=>o.Gid == ParentOrgID && o.Deleted == false).FirstOrDefault();
                //ViewData["orgCode"] = new List<SelectListItem> { new SelectListItem { Text = oParentOrg.FullName.GetResource(CurrentSession.Culture), Value = oParentOrg.Gid.ToString() } };
                gOrgId = ParentOrgID.Value;//设置全局gOrgId
                SetCurrentPath();//当前程序路径
            }
            return View(oViewModel);
        }
コード例 #8
0
 /// <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();
 }