Exemple #1
0
 /// <summary>
 /// 拷贝订单
 /// </summary>
 /// <param name="orderId"></param>
 /// <param name="newOrderId"></param>
 /// <returns></returns>
 public static int copyOrder(int orderId,int newOrderId)
 {
     using (var context = new AnnonContext())
     {
         try
         {
             var catlogOrders = context.ContentOrders
                 .Where(s => s.OrderID == orderId);
             foreach (var catlog in catlogOrders)
             {
                 context.ContentOrders.Add(new ContentOrder
                 {
                     PropertyName = catlog.PropertyName,
                     OrderID=newOrderId,
                     Value = catlog.Value,
                     ModuleTag=catlog.ModuleTag,
                     ImageName=catlog.ImageName,
                     CoolingPower=catlog.CoolingPower,
                     Price=catlog.Price,
                     Guid=catlog.Guid,
                     Items=catlog.Items
                 });
             }
             return context.SaveChanges();
         }
         catch (Exception e)
         {
             return -1;
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// 将临时表复制到订单表中,在最终需要到订单时保存时需要
 /// </summary>
 /// <param name="orderId"></param>
 /// <returns></returns>
 public static int copyCurrentToOrder(int orderId)
 {
     using (var context = new AnnonContext())
     {
         try
         {
             //先要删除对应orderId的订单
             deleteOrder(orderId);
             var contentCurrentValues = context.ContentCurrentValues
                 .Where(s => s.OrderID == orderId);
             //将临时表数据复制到订单中
             foreach (var ccv in contentCurrentValues)
             {
                 context.ContentOrders.Add(new ContentOrder
                     {
                         ModuleTag = ccv.ModuleTag,
                         PropertyName = ccv.PropertyName,
                         Value = ccv.Value,
                         ImageName = ccv.ImageName,
                         CoolingPower = ccv.CoolingPower,
                         OrderID = ccv.OrderID,
                         Guid=ccv.Guid,
                         Price=ccv.Price,
                         Items=ccv.Items
                     });
             }
             return context.SaveChanges();
         }
         catch (Exception e)
         {
             return -1;
         }
     }
 }
Exemple #3
0
        //复制详细订单信息;
        public static int CopyOrderDetail(int OrderDtIfID,int newOrderID)
        {
            using (var context = new AnnonContext())
            {
                try
                {
                    var od1 = context.orderDetailInfoes
                        .Where(s => s.orderDetailInfoID == OrderDtIfID)
                        .First();

                    orderDetailInfo od2 = new orderDetailInfo
                    {
                        OrderInfoId = od1.OrderInfoId,
                        OrderDetailNo = newOrderID,
                        Qty = od1.Qty,
                        custPrice = od1.custPrice,
                        listPrice = od1.listPrice,
                        RepPrice = od1.RepPrice,
                        tag = od1.tag,
                        ProDes = od1.ProDes,
                        OrderInfoType=od1.OrderInfoType,
                        OdDetlNum=ReturnLastNum()+1,
                        DeviceId=od1.DeviceId
                    };

                    context.orderDetailInfoes.Add(od2);
                    return context.SaveChanges();
                }
                catch (System.Exception ex)
                {
                    return -1;
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// 拷贝订单
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public static int copyOrder(int orderId)
        {
            using (var context = new AnnonContext())
            {
                try
                {
                    int newOrderId = 1;
                    var currentOrder = context.UnitOrders
                        .Select(s => s.OrderId);
                    if (currentOrder.Count() != 0)
                        newOrderId = currentOrder.Max() + 1;

                    var catlogOrders = context.UnitOrders
                        .Where(s => s.OrderId == orderId);
                    foreach (var catlog in catlogOrders)
                    {
                        context.UnitOrders.Add(new UnitOrder
                        {
                            PropertyName = catlog.PropertyName,
                            OrderId = newOrderId,
                            Value = catlog.Value
                        });
                    }
                     context.SaveChanges();
                     return newOrderId;
                }
                catch (Exception e)
                {
                    return -1;
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// 根据冷量和图块的名得到所有的满足条件的图块信息
        /// </summary>
        /// <param name="names"></param>
        /// <param name="coolingPower"></param>
        /// <returns></returns>
        public static List<ImageBlock> getImageBlocksByNames(List<PictureBoxInfo> pictureBoxInfos, int coolingPower)
        {
            using (var context = new AnnonContext())
            {
                try
                {
                    List<ImageBlock> imageBlocks = new List<ImageBlock>();
                    foreach (var pictureBoxInfo in pictureBoxInfos)
                    {
                        string name = null;
                        if (pictureBoxInfo.name == "virtualHRA")
                        {
                            name = "HRA";
                        }
                        else
                        {
                            name = pictureBoxInfo.name;
                        }

                        var imageBlock = context.ImageBlocks
                            .Where(s => s.ImageName == name
                            && s.CoolingPower == coolingPower)
                            .First();
                        imageBlocks.Add(imageBlock);
                    }
                    //这里的imageBlock(virtualHRA)的高度还是为HRA的高度要注意
                    return imageBlocks;
                }
                catch (Exception e)
                {
                    return null;
                }
            }
        }
Exemple #6
0
        //复制一条订单;
        public static int CopyOrder(int orderID)
        {
            using (var context = new AnnonContext())
            {
                try
                {
                    var ois = context.ordersinfoes
                        .Where(s => s.ordersinfoID == orderID)
                        .First();

                    ordersinfo oi = new ordersinfo
                    {
                        OrderNo=ReturnLastNum()+1,
                        JobNum = ois.JobNum,
                        JobName = ois.JobName,
                        JobDes = ois.JobDes,
                        Site = ois.Site,
                        Customer = ois.Customer,
                        Activity = ois.Activity,
                        AAonCon = ois.AAonCon,
                    };
                    context.ordersinfoes.Add(oi);
                    return context.SaveChanges();
                }
                catch (Exception e)
                {
                    return -1;
                }
            }
        }
Exemple #7
0
 /// <summary>
 /// 将临时表中的数据复制到订单中
 /// </summary>
 /// <param name="orderId"></param>
 /// <returns></returns>
 public static int copyCurrentToOrder(int orderId)
 {
     using (var context = new AnnonContext())
     {
         try
         {
             //先删除已有orderId的订单
             deleteOrder(orderId);
             var unitOrders = context.UnitCurrentValues
                 .Where(s => s.OrderId == orderId);
             //将临时表中的数据复制到订单表中
             foreach (var unitOrder in unitOrders)
             {
                 context.UnitOrders.Add(new UnitOrder
                 {
                     PropertyName = unitOrder.PropertyName,
                     Value = unitOrder.Value,
                     OrderId = unitOrder.OrderId,
                 });
             }
             ////删除临时表中的数据
             //foreach (var uo in unitOrders)
             //{
             //    context.UnitCurrentValues.Remove(uo);
             //}
             return context.SaveChanges();
         }
         catch (Exception e)
         {
             return -1;
         }
     }
 }
Exemple #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="deviceId"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        //public static List<Facility> getFacility(int orderId, int deviceId, string type)
        //{
        //    using (var context = new AnnonContext())
        //    {
        //        try
        //        {
        //            var facilityList = from x in context.CatalogOrders
        //                               join y in context.CatalogPropertyValues
        //                               on new { K1 = x.PropertyName, K2 = x.Value }
        //                               equals new { K1 = y.PropertyName, K2 = y.Value }
        //                               where x.OrderId == orderId && y.DeviceId == deviceId && x.Type == type
        //                               orderby x.SequenceNo
        //                               select new Facility
        //                               {
        //                                   PropertyName= y.PropertyName,
        //                                   Value= y.Value,
        //                                   PropertyParent= y.PropertyParent,
        //                                   ValueDescription= y.ValueDescription
        //                               };
        //            return facilityList.ToList();
        //        }
        //        catch (Exception e)
        //        {
        //            return null;
        //        }
        //    }
        //}
        public static List<Facility> getFacility(int orderId, int deviceId, string type)
        {
            using (var context = new AnnonContext())
            {
                try
                {
                    var facilityList =
                        context.CatalogCurrentValues
                        .Where(s => s.DeviceId == deviceId
                            && s.OrderId == orderId
                            && s.Type == type)
                            .Select(y => new Facility
                            {
                                PropertyName = y.PropertyName,
                                Value = y.Value,
                                PropertyParent = y.PropertyParent,
                                ValueDescription = y.ValueDescription,
                                Price=y.Price
                            });

                    return facilityList.ToList();
                }
                catch (Exception e)
                {
                    return null;
                }
            }
        }
Exemple #9
0
 /// <summary>
 /// 根据类型得到所有的附件
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static List<Accessory> getAccessories(string type)
 {
     using (var context = new AnnonContext())
     {
         try
         {
             var accessories = context.Accessories
                 .Where(s => s.Type.Equals(type));
             return accessories.ToList();
         }
         catch (Exception e)
         {
             return null;
         }
     }
 }
Exemple #10
0
        public static DataTable getOderDetail()
        {
            using (var context = new AnnonContext())
            {
                try
                {
                    var orderDetailIds = context.CurrentDevices
                        .Select(s => s.OrderDetailID)
                        .Distinct();

                    DataTable dataTable = new DataTable("OderDetail");
                    dataTable.Columns.Add("OrderId",System.Type.GetType("System.String"));
                    dataTable.Columns.Add("DeviceType", System.Type.GetType("System.String"));
                    dataTable.Columns.Add("DeviceId", System.Type.GetType("System.String"));
                    dataTable.Columns.Add("OrderDetail", System.Type.GetType("System.String"));
                    dataTable.Columns.Add("SumPrice", System.Type.GetType("System.Decimal"));

                    foreach (var orderDetailId in orderDetailIds)
                    {
                        string orderStr = string.Empty;
                        decimal sumPrice = 0;
                        var ptyValueArray = context.CurrentDevices
                            .Where(s => s.OrderDetailID == orderDetailId)
                            .Distinct();
                        foreach (var ptyValue in ptyValueArray)
                        {
                            orderStr += ptyValue.PropertyValueId;
                            orderStr += ",";
                            sumPrice += PropertyBLL.getPriceByPtyIdandValue(ptyValue.PropertyID, ptyValue.PropertyValueId, 1);
                        }
                        orderStr = orderStr.Substring(0, orderStr.Length - 1);
                        DataRow dataRow=dataTable.NewRow();
                        dataRow["OrderId"]=orderDetailId;
                        dataRow["DeviceType"] = "设备";
                        dataRow["DeviceId"] = "1";
                        dataRow["OrderDetail"]=orderStr;
                        dataRow["SumPrice"] = sumPrice;
                        dataTable.Rows.Add(dataRow);
                    }
                    return dataTable;
                }
                catch (Exception e)
                {
                    return null;
                }
            }
        }
Exemple #11
0
 /// <summary>
 /// 返回所有设备类型
 /// </summary>
 /// <returns></returns>
 public static List<Device> GetAllDevices()
 {
     using (var context = new AnnonContext())
     {
         try
         {
             //var devices = from u in context.Devices
             //              select u;
             var devices = context.Devices.ToList();
             return devices.ToList();
         }
         catch (Exception e)
         {
             return null;
         }
     }
 }
Exemple #12
0
 /// <summary>
 /// 删除制定订单
 /// </summary>
 /// <param name="accessoryId"></param>
 /// <returns></returns>
 public static int deleteOrder(int accessoryId)
 {
     using (var context = new AnnonContext())
     {
         try
         {
             var accessoryOrder = context.AccessoryOrders
                 .Where(s => s.AccessoryOrderID == accessoryId)
                 .First();
             context.AccessoryOrders.Remove(accessoryOrder);
             return context.SaveChanges();
         }
         catch (Exception e)
         {
             return -1;
         }
     }
 }
Exemple #13
0
 //删除订单信息;
 public static int DeleteOrder(int orderID)
 {
     using (var context = new AnnonContext())
     {
         try
         {
             var ois = context.ordersinfoes
                 .Where(s => s.ordersinfoID == orderID)
                 .ToList();
            context.ordersinfoes.Remove(ois.First());
            return context.SaveChanges();
         }
         catch (Exception e)
         {
             return -1;
         }
     }
 }
Exemple #14
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="orderDetailId"></param>
 /// <returns></returns>
 public static string getDescription(int orderDetailId)
 {
     using (var context = new AnnonContext())
     {
         try
         {
             var orderDetailInfo = context.orderDetailInfoes
                 .Where(s => s.OrderDetailNo == orderDetailId)
                 .First()
                 .ProDes;
             return orderDetailInfo;
         }
         catch (Exception e)
         {
             return string.Empty;
         }
     }
 }
Exemple #15
0
 /// <summary>
 /// 删除约束中的所有内容
 /// </summary>
 /// <returns></returns>
 public static int DeleteAllProperties()
 {
     using (var context = new AnnonContext())
     {
         try
         {
             var properties = context.Properties;
             foreach (var property in properties)
             {
                 context.Properties.Remove(property);
             }
             return context.SaveChanges();
         }
         catch (Exception e)
         {
             return -1;
         }
     }
 }
Exemple #16
0
 public static void DeleteAllCurrentDevices(int orderId, int deviceId)
 {
     using (var context = new AnnonContext())
     {
         try
         {
             var currentDevices = context.CurrentDevices
                 .Where(s => s.DeviceID == deviceId
                 && s.OrderDetailID == orderId);
             foreach (var currentDevice in currentDevices)
             {
                 context.CurrentDevices.Remove(currentDevice);
             }
             context.SaveChanges();
         }
         catch (Exception e)
         {
         }
     }
 }
Exemple #17
0
        /// <summary>
        /// 删除数据库中所有的图块信息
        /// </summary>
        /// <returns></returns>
        public static int DeleteAll()
        {
            using (var context = new AnnonContext())
            {
                try
                {
                    var imageBlocks = context.ImageBlocks;
                    foreach (var imageBlock in imageBlocks)
                    {
                        context.ImageBlocks.Remove(imageBlock);
                    }
                    return context.SaveChanges();
                }
                catch (Exception e)
                {
                    return -1;
                }

            }
        }
Exemple #18
0
        //删除所有详细订单信息;
        public static int DeleteAllOrderDetail()
        {
            using (var context = new AnnonContext())
            {
                try
                {
                    var od = context.orderDetailInfoes;

                    foreach (var odd in od)
                    {
                        context.orderDetailInfoes.Remove(odd);
                    }
                    return context.SaveChanges();

                }
                catch (System.Exception ex)
                {
                    return -1;
                }
            }
        }
Exemple #19
0
        //删除所有订单数据;
        public static int DeleteAllOrder()
        {
            using (var context = new AnnonContext())
            {
                try
                {
                    var ois = context.ordersinfoes;

                    foreach (var os in ois)
                    {
                        context.ordersinfoes.Remove(os);
                    }
                    //context.ordersinfoes.Remove(ois);
                    return context.SaveChanges();
                }
                catch (Exception e)
                {
                    return -1;
                }
            }
        }
Exemple #20
0
 /// <summary>
 /// 复制临时表到订单表
 /// </summary>
 /// <param name="orderId"></param>
 /// <param name="deviceId"></param>
 /// <returns></returns>
 public static int copyCurrentToOrder(int orderId, int deviceId)
 {
     //首先刷新下价格
     refreshPriceConstraint(orderId, deviceId);
     using (var context = new AnnonContext())
     {
         try
         {
             deleteOrder(orderId);
             var currentValues = context.CatalogCurrentValues
                 .Where(s => s.OrderId == orderId
                 && s.DeviceId == deviceId);
             foreach (var currentValue in currentValues)
             {
                 context.CatalogOrders.Add(new CatalogOrder
                 {
                     PropertyName=currentValue.PropertyName,
                     OrderId=currentValue.OrderId,
                     DeviceId=currentValue.DeviceId,
                     Value=currentValue.Value,
                     SequenceNo=currentValue.SequenceNo,
                     Type=currentValue.Type,
                     Price=currentValue.Price,
                     PropertyParent=currentValue.PropertyParent,
                     ValueDescription=currentValue.ValueDescription
                 });
             }
             //foreach (var currentValue in currentValues)
             //{
             //    context.CatalogCurrentValues.Remove(currentValue);
             //}
             return context.SaveChanges();
         }
         catch (Exception e)
         {
             return -1;
         }
     }
 }
Exemple #21
0
 /// <summary>
 /// 拷贝订单
 /// </summary>
 /// <param name="orderId"></param>
 /// <param name="newOrderId"></param>
 /// <returns></returns>
 public static int copyOrder(int orderId, int newOrderId)
 {
     using (var context = new AnnonContext())
     {
         try
         {
             var imageModels = context.ImageModels
                 .Where(s => s.OrderId == orderId);
             foreach (var imageModel in imageModels)
             {
                 context.ImageModels.Add(new ImageModel
                 {
                     Name=imageModel.Name,
                     X=imageModel.X,
                     Y=imageModel.Y,
                     Width=imageModel.Width,
                     Height=imageModel.Height,
                     Url=imageModel.Url,
                     Type=imageModel.Type,
                     Text=imageModel.Text,
                     coolingType=imageModel.coolingType,
                     FirstDance=imageModel.FirstDance,
                     SecondDance=imageModel.SecondDance,
                     ModuleTag=imageModel.ModuleTag,
                     OrderId=newOrderId,
                     IsSelected=imageModel.IsSelected,
                     ParentName=imageModel.ParentName,
                     Guid=imageModel.Guid
                 });
             }
             return context.SaveChanges();
         }
         catch (Exception e)
         {
             return -1;
         }
     }
 }
Exemple #22
0
        //删除某一条订单下的所有订单详情;
        public static int DeleteOneOrderAllDetail(int OrderID)
        {
            using (var context = new AnnonContext())
            {
                try
                {
                    var od = context.orderDetailInfoes
                        .Where(s => s.OrderInfoId == OrderID)
                        .ToList();

                    foreach (var ord in od)
                    {
                        context.orderDetailInfoes.Remove(ord);
                    }

                    return context.SaveChanges();
                }
                catch (System.Exception ex)
                {
                    return -1;
                }
            }
        }
Exemple #23
0
        /// <summary>
        /// 添加当前设备
        /// </summary>
        /// <param name="deviceId">设备ID</param>
        /// <param name="propertyId">属性ID</param>
        /// <param name="propertyValueArray">属性值列表</param>
        /// <param name="orderDetailId">订单ID</param>
        /// <param name="propertyValueId">属性当前取值</param>
        public static void InsertIntoCurrentDevice(int deviceId,int propertyId,string propertyValueArray,int orderDetailId,int propertyValueId)
        {
            var currentDevice = new CurrentDevice
            {
                DeviceID = deviceId,
                PropertyID = propertyId,
                PropertyValueArray = propertyValueArray,
                OrderDetailID = orderDetailId,
                PropertyValueId = propertyValueId
            };
            using (var context = new AnnonContext())
            {
                try
                {
                    context.CurrentDevices.Add(currentDevice);
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                }

            }
        }
Exemple #24
0
 /// <summary>
 /// 删除所有数据
 /// </summary>
 /// <returns></returns>
 public static int deleteAll()
 {
     using (var context = new AnnonContext())
     {
         try
         {
             var accessories = context.Accessories;
             if (accessories != null && accessories.Count() != 0)
             {
                 foreach (var accessory in accessories)
                 {
                     context.Accessories.Remove(accessory);
                 }
                 return context.SaveChanges();
             }
             return 0;
         }
         catch (Exception e)
         {
             return -1;
         }
     }
 }
Exemple #25
0
 /// <summary>
 /// 删除某个订单号的订单
 /// </summary>
 /// <param name="orderId"></param>
 /// <returns></returns>
 public static int deleteOrder(int orderId)
 {
     using (var context = new AnnonContext())
     {
         try
         {
             var imageModels = context.ImageModels
                 .Where(s => s.OrderId == orderId);
             if (imageModels != null && imageModels.Count() != 0)
             {
                 foreach (var imageModel in imageModels)
                 {
                     context.ImageModels.Remove(imageModel);
                 }
                 return context.SaveChanges();
             }
             return 0;
         }
         catch (Exception e)
         {
             return -1;
         }
     }
 }
Exemple #26
0
 /// <summary>
 /// 保存选项
 /// </summary>
 /// <param name="propertyName"></param>
 /// <param name="orderId"></param>
 /// <param name="coolingPower"></param>
 /// <param name="imageName"></param>
 /// <param name="guid"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 private static int saveOptions(string propertyName, int orderId, int coolingPower, string imageName, string guid,string options)
 {
     using (var context = new AnnonContext())
     {
         try
         {
             var contentCurrentValue = context.ContentCurrentValues
                 .Where(s => s.OrderID == orderId
                 && s.ImageName == imageName
                 && s.PropertyName == propertyName
                 && s.Guid == guid)
                 .First();
             if (!options.Split(',').Contains(contentCurrentValue.Value))
                 contentCurrentValue.Value = options.Split(',').First();
             contentCurrentValue.Items = options;
             return context.SaveChanges();
         }
         catch (Exception e)
         {
             return -1;
         }
     }
 }
Exemple #27
0
 /// <summary>
 /// 查找订单当前的值,根据订单的guid
 /// </summary>
 /// <param name="moduleTag"></param>
 /// <param name="coolingPower"></param>
 /// <param name="imageName"></param>
 /// <param name="orderId"></param>
 /// <returns></returns>
 private static string GetValueByOrder(string guid,int coolingPower,string propertyName,string imageName)
 {
     using (var context = new AnnonContext())
     {
         try
         {
             var contentCurrentValue = context.ContentCurrentValues
                 .Where(s => s.Guid==guid
                 &&s.CoolingPower==coolingPower
                 &&s.PropertyName==propertyName
                 &&s.ImageName==imageName)
                 .First()
                 .Value;
             return contentCurrentValue;
         }
         catch (Exception e)
         {
             return string.Empty;
         }
     }
 }
Exemple #28
0
 /// <summary>
 /// 根据被动属性,得到主动属性的列表,约束作用到每个图块
 /// </summary>
 /// <param name="influencedPropertyName"></param>
 /// <returns></returns>
 private static List<string> getPtyNames(string influencedPropertyName, string imageName,int coolingPower)
 {
     using (var context = new AnnonContext())
     {
         try
         {
             List<string> propertyNames = context.ContentConstraints.AsEnumerable()
                 .Where(s => s.InfluencedPropertyName == influencedPropertyName
                 && s.ImageName == imageName
                 &&s.CoolingPower==coolingPower)
                 .Select(s => s.PropertyName.Trim())
                 .ToList();
             return propertyNames;
         }
         catch (Exception e)
         {
             return null;
         }
     }
 }
Exemple #29
0
 /// <summary>
 /// 根据一列属性名得到属性的取值配对,这里通过订单号和moduleTag定位一个图块
 /// </summary>
 /// <param name="propertyNames"></param>
 /// <param name="orderId"></param>
 /// <returns></returns>
 private static List<string> generateCondition(List<string> propertyNames, int orderId,string guid,int coolingPower)
 {
     using (var context = new AnnonContext())
     {
         try
         {
             List<string> ptyValues = new List<string>();
             foreach (var propertyName in propertyNames)
             {
                 var unitValue = context.ContentCurrentValues
                 .Where(s => s.OrderID == orderId
                 && s.PropertyName == propertyName
                 &&s.Guid==guid
                 &&s.CoolingPower==coolingPower)
                 .Select(s => s.Value)
                 .First();
                 string ptyValue = propertyName + ":" + unitValue;
                 //生成字符串类似与“name:value”
                 ptyValues.Add(ptyValue);
             }
             return ptyValues;
         }
         catch (Exception e)
         {
             return null;
         }
     }
 }
Exemple #30
0
 /// <summary>
 /// 根据订单号得到图块内容订单列表
 /// </summary>
 /// <param name="orderId"></param>
 /// <returns></returns>
 public List<ContentOrder> getContentOrders(int orderId)
 {
     using (var context = new AnnonContext())
     {
         try
         {
             var contentOrders = context.ContentOrders
                 .Where(s => s.OrderID == orderId);
             return contentOrders.ToList();
         }
         catch (Exception e)
         {
             return null;
         }
     }
 }