/// <summary>
 /// Constructor for a product
 /// </summary>
 /// <param name="title"></param>
 /// <param name="primaryCategory"></param>
 /// <param name="topLevelCategory"></param>
 /// <param name="categoryPath"></param>
 /// <param name="skus"></param>
 /// <param name="description"></param>
 public Product(String title, Int32 primaryCategory, Int32 topLevelCategory, String categoryPath, SKU[] skus, ProductDescription description)
     : this()
 {
     this.SKUs = skus;
     this.Description = description;
     this.Title = title;
     this.PrimaryCategory = primaryCategory;
     this.TopLevelCategory = topLevelCategory;
     this.CategoryPath = categoryPath;
 }
        public void SKUConstructorTest()
        {
            String skuNumber = "23";
            Dictionary<String, String> itemSpecifics = new Dictionary<string,string>();

            itemSpecifics.Add("key", "value");
            itemSpecifics.Add("key2", "value2");

            SKU sku = new SKU(skuNumber, itemSpecifics);

            Assert.AreEqual(sku.SKUNumber, skuNumber);
            Assert.AreEqual(sku.ItemSpecifics.Count, itemSpecifics.Count);
            Assert.AreEqual(sku.ItemSpecifics["key"], itemSpecifics["key"]);
            Assert.AreEqual(sku.ItemSpecifics["key2"], itemSpecifics["key2"]);
        }
        public void ProductConstructorTest()
        {
            String title = "Title";
            Int32 primaryCategory = 5;
            Int32 topLevelCategory = 10;
            String categoryPath = "Some Path";
            SKU[] skus = new SKU[5];
            var features = new Dictionary<String, String>() {{"F1", "V1"}, {"F2", "V2"}, {"F3", "V3"}};
            ProductDescription description = new ProductDescription(arbitraryElements: null, features: features);

            Product product = new Product(title, primaryCategory, topLevelCategory, categoryPath, skus, description);

            Assert.AreEqual(product.Title, title);
            Assert.AreEqual(product.PrimaryCategory, primaryCategory);
            Assert.AreEqual(product.TopLevelCategory, topLevelCategory);
            Assert.AreEqual(product.CategoryPath, categoryPath);
            Assert.AreEqual(product.SKUs.Count, skus.Length);
            Assert.AreEqual(product.Description.Features.Count, features.Count);
        }
예제 #4
0
 void FSerch()
 {
     try
     {
         int      id = int.Parse(IDNumber.Text);
         MContext mc = new MContext();
         if (mc.SKUs.Any(x => x.ID == id))
         {
             SKU     s    = mc.SKUs.First(x => x.ID == id);
             InfoSKU asku = new InfoSKU(s);
             asku.ShowDialog();
             this.Close();
         }
         else
         {
             MessageBox.Show("Товар с таким ID не найден");
         }
     }
     catch
     {
         MessageBox.Show("Введен не корректный ID");
         IDNumber.Clear();
     }
 }
예제 #5
0
        public bool Update(SKU sku)
        {
            int i = 0;

            try
            {
                using (SqlConnection con = new SqlConnection(DbConn))
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("sp_UpdateSKURecord", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@SKUId", sku.Id);
                    cmd.Parameters.AddWithValue("@Name", sku.Name);
                    cmd.Parameters.AddWithValue("@Code", sku.Code);
                    cmd.Parameters.AddWithValue("@UnitPrice", sku.UnitPrice);
                    cmd.Parameters.AddWithValue("@IsActive", "1");

                    i = cmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            if (i >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #6
0
        public bool Insert(SKU sku)
        {
            int i = 0;

            try
            {
                using (SqlConnection con = new SqlConnection(DbConn))
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("sp_InsertSKURecord", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@Name", sku.Name);
                    cmd.Parameters.AddWithValue("@Code", sku.Code);
                    cmd.Parameters.AddWithValue("@UnitPrice", sku.UnitPrice);
                    cmd.Parameters.AddWithValue("@DateCreated", Convert.ToDateTime(DateTime.Now.ToShortDateString()));
                    cmd.Parameters.AddWithValue("@IsActive", "1");

                    i = cmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            if (i >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #7
0
        public async Task <bool> DecreaseQuantity(SKU sku, SKUOption skuOption)
        {
            var shoppingCartItemFromDb =
                await _context.ShoppingCartItems
                .SingleOrDefaultAsync(x => x.ShoppingCartId == CartId && x.SKUId == sku.Id && x.SKUOptionId == skuOption.Id);

            if (shoppingCartItemFromDb == null)
            {
                return(false);
            }

            if (shoppingCartItemFromDb.Amount > 1)
            {
                shoppingCartItemFromDb.Amount--;
            }
            else
            {
                _context.Remove(shoppingCartItemFromDb);
            }

            await _context.SaveChangesAsync();

            return(true);
        }
예제 #8
0
        public ActionResult Create([Bind(Include = "client_name,SKU1,description,length,width,height,rate,supplier,cost,category,notes")] SKU sKU, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    var path     = Path.Combine(Server.MapPath("~/Images/"), fileName);
                    file.SaveAs(path);

                    sKU.image_url = Url.Content("~/Images/" + fileName);
                }
                try
                {
                    db.SKUs.Add(sKU);
                    db.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Trace.TraceError("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                         eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Trace.TraceError("- Property: \"{0}\", Error: \"{1}\"",
                                             ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                }

                return(RedirectToAction("Index"));
            }
            ViewBag.client_name = new SelectList(db.tbl_client, "client_name", "contact_person", sKU.client_name);
            return(View(sKU));
        }
예제 #9
0
파일: Product.cs 프로젝트: ChrisMcKee/Kona
 public override int GetHashCode()
 {
     return(SKU.GetHashCode());
 }
예제 #10
0
 public static bool IsSKU(string SKUToCompare)
 {
     return(SKU.Equals(SKUToCompare.ToUpper()));
 }
예제 #11
0
        /// <summary>
        /// 通過SKU對象,獲取對應批次對象,如果批次對象為空,新增批次對象
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras">2個參數,SKU,LOTNO保存的位置</param>
        public static void GetLotDataloader(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            string           ColoumName = "skuno";
            Row_R_LOT_STATUS RLotSku;
            T_R_LOT_STATUS   TR  = new T_R_LOT_STATUS(Station.SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle);
            LotNo            LOT = new LotNo();

            if (Paras.Count <= 0)
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000050"));
            }
            MESStationSession Ssku        = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);
            MESStationSession Slot        = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);
            MESStationSession SLotNewFlag = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (Ssku == null)
            {
                //throw new Exception("请输入SKU!");
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE }));
            }
            else
            {
                SKU ObjSku = (SKU)Ssku.Value;
                //Marked by LLF 20018-02-22
                //RLotSku = TR.GetByInput(ObjSku.SkuNo, ColoumName, Station.SFCDB);
                //RLotSku = TR.GetLotBySku(ObjSku.SkuNo, ColoumName, Station.SFCDB);
                //modify by fgg get lot by sku and station name 2018.8.16
                RLotSku = TR.GetLotBySkuAnd(ObjSku.SkuNo, Station.StationName, Station.SFCDB);
            }

            if (Slot == null)
            {
                Slot = new MESStationSession()
                {
                    MESDataType = Paras[1].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[1].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(Slot);
            }

            if (SLotNewFlag == null)
            {
                SLotNewFlag = new MESStationSession()
                {
                    MESDataType = Paras[2].SESSION_TYPE, SessionKey = Paras[2].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(SLotNewFlag);
            }

            try
            {
                //Modify by LLF 2018-02-07 SLotNewFlag 為新生成Lot的標誌位
                //if (LOT == null)//LOT 為空需產生新的LOTNO
                if (RLotSku == null)
                {
                    SLotNewFlag.Value = "1";
                    Slot.Value        = LOT.GetNewLotNo("HWD_FQCLOT", Station.SFCDB);
                }
                else
                {
                    SLotNewFlag.Value = "0";
                    LOT.Init(RLotSku.LOT_NO, "", Station.SFCDB);
                    Slot.Value = LOT;
                    Station.AddMessage("MES00000029", new string[] { "LotNo", LOT.ToString() }, MESPubLab.MESStation.MESReturnView.Station.StationMessageState.Message);
                }
            }
            catch (Exception ex)
            {
                string msgCode = ex.Message;
                throw ex;
            }
        }
 public WomansInvisibleSocks(SKU sku, string name, double price)
     : base(sku, name, price)
 {
 }
예제 #13
0
 public CartItem(SKU skuItem, int noOfItems)
 {
     this.skuItem   = skuItem;
     this.noOfItems = noOfItems;
     this.skuTotal  = skuItem.skuPrice * noOfItems;
 }
예제 #14
0
        /// <summary>
        /// Ecom中的定义:
        /// Sellset,组合产品中的定义,在Group中,用于标识子产品在组合产品中的PCS数量
        /// Sellpack,销售数量定义,表示网站订单1QTY对应系统中销售N个产品的意思
        /// boxnum就是sellpack,一个货号我卖6个,装3箱,则:pcs 6 mp2 sellpack 3 Add Remark:2014年4月15日15:09:08
        /// </summary>
        /// <param name="WPModel"></param>
        /// <param name="db"></param>
        public void SKU_Action(CMS_SKU_Model WPModel, EcomEntities db)
        {
            if (WPModel.CMS_ShipViaType == null)//HMModel.CMS_ShipVia_Type.CMS_ShipVia_Default.SHIPVIA
            {
                throw new Exception("This SKU does not set ShipVia Type");
            }
            if (WPModel.CMS_ShipViaType.CMS_ShipVia_Default == null)
            {
                throw new Exception("This SKU does not set ShipVia");
            }

            var query = db.SKU.FirstOrDefault(s => s.SKUOrder == WPModel.SKU && s.MerchantID == WPModel.ChannelName);

            if (query == null)
            {
                var newSKU = new SKU
                {
                    MerchantID = WPModel.ChannelName,
                    HMNUM      = WPModel.SKU_HM_Relation.CMS_HMNUM.HMNUM,
                    SKUOrder   = WPModel.SKU,
                    SKUBest    = WPModel.SKU,
                    SellPack   = WPModel.SKU_HM_Relation.R_QTY / Convert.ToInt32(WPModel.SKU_HM_Relation.CMS_HMNUM.MasterPack),
                    //Description = WPModel.ProductName, eCom的Description其实是CMS的ProductName, 2014年4月9日
                    Description = WPModel.ProductName,
                    URL         = WPModel.URL,
                    UPC         = WPModel.UPC,
                    SHIPVIA     = WPModel.CMS_ShipViaType.CMS_ShipVia_Default.SHIPVIA,
                    Status      = WPModel.StatusName
                };
                db.SKU.Add(newSKU);

                db.SaveChanges();//!! 这里如果不保存,则SKUID =0 !!!

                //新增:SKU对应的Costing表
                db.Costing.Add(new Costing
                {
                    HMNUM          = newSKU.HMNUM,
                    MerchantID     = newSKU.MerchantID,
                    SKUID          = newSKU.SKUID,
                    SKUOrder       = newSKU.SKUOrder,
                    EffectiveDate  = WPModel.SKU_Costing.EffectiveDate,
                    Cost           = decimal.Parse(WPModel.SKU_Costing.SalePrice, NumberStyles.Currency, new CultureInfo("en-US")),
                    Coupon         = 0,//以后再做,Promo这一块 2014年4月24日11:53:47 (Boonie)
                    Retail         = WPModel.RetailPrice,
                    Freight        = decimal.Parse(WPModel.SKU_Costing.EstimateFreight, NumberStyles.Currency, new CultureInfo("en-US")),
                    MerchantCoupon = 0
                });
            }
            else
            {
                query.MerchantID = WPModel.ChannelName;
                query.HMNUM      = WPModel.SKU_HM_Relation.CMS_HMNUM.HMNUM;
                query.SKUOrder   = WPModel.SKU;
                query.SellPack   = WPModel.SKU_HM_Relation.R_QTY / Convert.ToInt32(WPModel.SKU_HM_Relation.CMS_HMNUM.MasterPack);
                //query.SellPack = WPModel.SKU_HM_Relation.CMS_HMNUM.IsGroup ? 1 : WPModel.SKU_HM_Relation.R_QTY;
                //query.Description = WPModel.ProductDesc;eCom的Description其实是CMS的ProductName, 2014年4月9日
                query.Description = WPModel.ProductName;
                query.URL         = WPModel.URL;
                query.UPC         = WPModel.UPC;
                //query.SHIPVIA = WPModel.CMS_ShipViaType.CMS_ShipVia_Default.SHIPVIA;

                //取出当前eCom.dbo.Costing表的数据
                var eComCostings = db.Costing.Where(s => s.SKUOrder == WPModel.SKU && s.MerchantID == WPModel.ChannelName && s.EffectiveDate != null);
                if (eComCostings.FirstOrDefault() == null)
                {
                    db.Costing.Add(new Costing
                    {
                        HMNUM          = query.HMNUM,
                        MerchantID     = query.MerchantID,
                        SKUID          = query.SKUID,
                        SKUOrder       = query.SKUOrder,
                        EffectiveDate  = WPModel.SKU_Costing.EffectiveDate,
                        Cost           = decimal.Parse(WPModel.SKU_Costing.SalePrice, NumberStyles.Currency, new CultureInfo("en-US")),
                        Coupon         = 0,//以后再做,Promo这一块 2014年4月24日11:53:47 (Boonie)
                        Retail         = WPModel.RetailPrice,
                        Freight        = decimal.Parse(WPModel.SKU_Costing.EstimateFreight, NumberStyles.Currency, new CultureInfo("en-US")),
                        MerchantCoupon = 0
                    });
                }
                else
                {
                    //如果已经存在并且不止一列,取出最大的那个时间点做比较
                    if (WPModel.SKU_Costing.EffectiveDate == eComCostings.Max(s => s.EffectiveDate).Value)//前面过滤了null值,所以这里不会出现null值了
                    {
                        //相等说明CMS没有做价格变动
                    }
                    else
                    {
                        //插入新的Costing
                        db.Costing.Add(new Costing
                        {
                            HMNUM          = query.HMNUM,
                            MerchantID     = query.MerchantID,
                            SKUID          = query.SKUID,
                            SKUOrder       = query.SKUOrder,
                            EffectiveDate  = WPModel.SKU_Costing.EffectiveDate,
                            Cost           = decimal.Parse(WPModel.SKU_Costing.SalePrice, NumberStyles.Currency, new CultureInfo("en-US")),
                            Coupon         = 0,//以后再做,Promo这一块 2014年4月24日11:53:47 (Boonie)
                            Retail         = WPModel.RetailPrice,
                            Freight        = decimal.Parse(WPModel.SKU_Costing.EstimateFreight, NumberStyles.Currency, new CultureInfo("en-US")),
                            MerchantCoupon = 0
                        });
                    }
                }

                //db.SaveChanges();为什么要在这里Save导致不能做transaction?2014年4月24日10:41:57
            }
        }
예제 #15
0
        public override string ToString()
        {
            if (m_fValid)
            {
                try
                {
                    StringBuilder output = new StringBuilder();

                    output.AppendLine(String.Format("HAL build info: {0}, {1}", HalBuildVersion?.ToString(), HalBuildInfo?.TrimEnd('\0')));
                    output.AppendLine(String.Format("OEM Product codes (vendor, model, SKU): {0}, {1}, {2}", OEM.ToString(), Model.ToString(), SKU.ToString()));
                    output.AppendLine("Serial Numbers (module, system):");
                    output.AppendLine("  " + ModuleSerialNumber?.TrimEnd('\0'));
                    output.AppendLine("  " + SystemSerialNumber?.TrimEnd('\0'));
                    output.AppendLine(String.Format("Solution Build Info: {0}, {1}", SolutionBuildVersion?.ToString(), SolutionBuildInfo?.TrimEnd('\0')));

                    output.AppendLine("AppDomains:");
                    foreach (IAppDomainInfo adi in AppDomains)
                    {
                        output.AppendLine(String.Format("  {0}, id={1}", adi.Name, adi.ID));
                    }

                    output.AppendLine("Assemblies:");
                    foreach (IAssemblyInfo ai in Assemblies)
                    {
                        output.AppendLine(String.Format("  {0}, {1}", ai.Name, ai.Version));
                    }

                    return(output.ToString());
                }
                catch { };
            }

            return("DeviceInfo is not valid!");
        }
예제 #16
0
        public SKU CalculatePromotionForItem(PromotionType promotionType, PromotionModel promotionModel, SKU sku)
        {
            SKU _sku = new SKU();

            if (promotionType == PromotionType.OnOneSKU)
            {
                if (promotionModel.QutyOfSKUCollection.FirstOrDefault().Value > sku.Quty)
                {
                    var rem  = 0;
                    var cost = (Math.DivRem(sku.Quty, promotionModel.QutyOfSKUCollection.FirstOrDefault().Value, out rem) *
                                promotionModel.CostCollection.FirstOrDefault().Value) + (rem * sku.CostPerSKU);
                    _sku.TotalSavings = _sku.TotalCost - cost;
                    _sku.TotalCost    = cost;
                }
            }
            return(_sku);
        }
예제 #17
0
        /// <summary>
        /// 提供工站打印本站
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void PrintStationLabelAction(MESStation.BaseClass.MESStationBase Station, MESStation.BaseClass.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            OleExec SFCDB = Station.SFCDB;
            string  Run   = "";

            try
            {
                Run = (Station.StationSession.Find(T => T.MESDataType == Paras[0].SESSION_TYPE && T.SessionKey == Paras[0].SESSION_KEY).Value).ToString();
                if (Run.ToUpper() == "FALSE")
                {
                    return;
                }
            }
            catch
            {
            }


            SKU SKU = (SKU)(Station.StationSession.Find(T => T.MESDataType == Paras[1].SESSION_TYPE && T.SessionKey == Paras[1].SESSION_KEY).Value);

            List <string> ProcessLabType = new List <string>();

            if (Paras.Count > 1)
            {
                for (int i = 2; i < Paras.Count; i++)
                {
                    ProcessLabType.Add(Paras[i].VALUE.ToString());
                }
            }

            T_C_SKU_Label TCSL = new T_C_SKU_Label(SFCDB, DB_TYPE_ENUM.Oracle);
            //獲取label配置
            List <Row_C_SKU_Label> labs = TCSL.GetLabelConfigBySkuStation(SKU.SkuBase.SKUNO, Station.StationName, SFCDB);

            List <Label.LabelBase> PrintLabs = new List <Label.LabelBase>();
            T_R_Label      TRL  = new T_R_Label(SFCDB, DB_TYPE_ENUM.Oracle);
            T_C_Label_Type TCLT = new T_C_Label_Type(SFCDB, DB_TYPE_ENUM.Oracle);

            for (int i = 0; i < labs.Count; i++)
            {
                if (ProcessLabType.Count > 0)
                {
                    if (!ProcessLabType.Contains(labs[i].LABELTYPE))
                    {
                        continue;
                    }
                }
                Row_R_Label      RL = TRL.GetLabelConfigByLabelName(labs[i].LABELNAME, SFCDB);
                Row_C_Label_Type RC = TCLT.GetConfigByName(labs[i].LABELTYPE, SFCDB);

                string      path      = System.AppDomain.CurrentDomain.BaseDirectory;
                Assembly    assembly  = Assembly.LoadFile(path + RC.DLL);
                System.Type APIType   = assembly.GetType(RC.CLASS);
                object      API_CLASS = assembly.CreateInstance(RC.CLASS);

                LabelBase Lab = (LabelBase)API_CLASS;
                //給label的輸入變量加載值
                for (int j = 0; j < Lab.Inputs.Count; j++)
                {
                    if (Lab.Inputs[j].Name.ToUpper() == "STATION")
                    {
                        Lab.Inputs[j].Value = Station.StationName;
                    }

                    MESStationSession S = Station.StationSession.Find(T => T.MESDataType == Lab.Inputs[j].StationSessionType && T.SessionKey == Lab.Inputs[j].StationSessionKey);
                    if (S != null)
                    {
                        Lab.Inputs[i].Value = S.Value;
                    }
                }
                Lab.LabelName = RL.LABELNAME;
                Lab.FileName  = RL.R_FILE_NAME;
                Lab.PrintQTY  = (int)labs[i].QTY;
                Lab.MakeLabel(SFCDB);
                List <LabelBase> pages = MakePrintPage(Lab, RL);

                for (int k = 0; k < pages.Count; k++)
                {
                    pages[k].ALLPAGE = pages.Count;
                    Station.LabelPrint.Add(pages[k]);
                }
            }
        }
예제 #18
0
 public override int GetHashCode()
 {
     return((SKU == null) ? 0 : SKU.GetHashCode());
 }
예제 #19
0
        public void ImportDataTable(System.Data.DataTable datatable)
        {
            List <BOMComponent> list        = new List <BOMComponent>();
            SKU          sku                = null;
            string       parentsku          = "";
            BOMComponent parentbomComponent = null;

            foreach (DataRow row in datatable.Rows)
            {
                BOMComponent item = new BOMComponent();
                item.ObjectState = Repository.Pattern.Infrastructure.ObjectState.Added;
                foreach (DataColumn col in datatable.Columns)
                {
                    var sourcefieldname = col.ColumnName;
                    var colval          = row[sourcefieldname].ToString();
                    if (sourcefieldname == "组件")
                    {
                        string strsku = row["组件"].ToString().Trim();
                        sku = _iskuservice.Queryable().Where(x => x.Sku == strsku).FirstOrDefault();
                        if (sku == null)
                        {
                            throw new Exception(string.Format("{0}没有维护SKU主数据", strsku));
                        }
                        item.ComponentSKU = sku.Sku;
                        item.SKUId        = sku.Id;
                        item.StockSKU     = sku.Sku;
                        item.SKUGroup     = sku.SKUGroup;
                    }
                    else if (sourcefieldname == "父件")
                    {
                        parentsku = row["父件"].ToString().Trim();
                        if (!string.IsNullOrEmpty(parentsku))
                        {
                            SKU psku = _iskuservice.Queryable().Where(x => x.Sku == parentsku).FirstOrDefault();
                            if (psku == null)
                            {
                                throw new Exception(string.Format("{0}没有维护SKU主数据", parentsku));
                            }
                            parentbomComponent     = list.Where(x => x.ComponentSKU == parentsku).FirstOrDefault();
                            item.ParentComponent   = parentbomComponent;
                            item.ParentComponentId = parentbomComponent.Id;
                        }
                    }
                    else if (sourcefieldname == "生产工序")
                    {
                        var process = _processservice.Queryable().Where(x => x.Name == colval).FirstOrDefault();
                        if (process != null)
                        {
                            item.ProductionProcessId = process.Id;
                        }
                    }
                    else
                    {
                        var mapping = _mappingservice.FindMapping("BOMComponent", sourcefieldname);
                        if (mapping != null && row[sourcefieldname] != DBNull.Value)
                        {
                            Type         bomcomponenttype = item.GetType();
                            PropertyInfo propertyInfo     = bomcomponenttype.GetProperty(mapping.FieldName);
                            propertyInfo.SetValue(item, Convert.ChangeType(row[sourcefieldname], propertyInfo.PropertyType), null);
                            //bomcomponenttype.GetProperty(mapping.FieldName).SetValue(item, row[sourcefieldname]);
                        }
                    }
                }

                list.Add(item);
            }
            this.InsertRange(list);
        }
예제 #20
0
 public PrintPrice(SKU s)
 {
     InitializeComponent();
     this.s = s;
     Init(s);
 }
예제 #21
0
 public InfoSKU(SKU s)
 {
     InitializeComponent();
     sku = s;
     Set(s);
 }
예제 #22
0
        /// <summary>
        /// Query job info
        /// </summary>
        private async Task QueryJobChangeAsync()
        {
            TraceHelper.TraceEvent(this.sessionid, TraceEventType.Verbose,
                                   "[AzureBatchJobMonitorEntry] Enters QueryTaskInfo method.");
            bool shouldExit = false;

            this.pullJobGap = PullJobMinGap;
            JobState state = JobState.Active;

            Session.Data.JobState currentJobState = Session.Data.JobState.Configuring;
            var    pool    = this.batchClient.PoolOperations.GetPool(AzureBatchConfiguration.BatchPoolName);
            string skuName = pool.VirtualMachineSize;

            TraceHelper.TraceEvent(this.sessionid, TraceEventType.Information, "[AzureBatchJobMonitor] VMSize in pool is {0}",
                                   skuName);
            SKU targetSku = Array.Find(this.skus, sku => sku.Name.Equals(skuName, StringComparison.OrdinalIgnoreCase));

            this.nodeCapacity = targetSku.VCPUs;
            TraceHelper.TraceEvent(this.sessionid, TraceEventType.Information,
                                   "[AzureBatchJobMonitor] Node capacity in pool is {0}", nodeCapacity);

            ODATADetailLevel detailLevel = new ODATADetailLevel();

            detailLevel.SelectClause = "affinityId, ipAddress";
            var nodes = await pool.ListComputeNodes(detailLevel).ToListAsync();

            while (true)
            {
                if (shouldExit)
                {
                    break;
                }
                List <TaskInfo> stateChangedTaskList = new List <TaskInfo>();

                try
                {
                    TraceHelper.TraceEvent(this.sessionid, TraceEventType.Verbose, "[AzureBatchJobMonitor] Starting get job state.");
                    ODATADetailLevel detail = new ODATADetailLevel(selectClause: "state");
                    this.cloudJob = await this.batchClient.JobOperations.GetJobAsync(this.cloudJob.Id);

                    state           = this.cloudJob.State.HasValue ? this.cloudJob.State.Value : state;
                    currentJobState = await AzureBatchJobStateConverter.FromAzureBatchJobAsync(this.cloudJob);

                    TraceHelper.TraceEvent(this.sessionid, TraceEventType.Information, "[AzureBatchJobMonitor] Current job state in AzureBatch: JobState = {0}\n", state);
                    TraceHelper.TraceEvent(this.sessionid, TraceEventType.Information, "[AzureBatchJobMonitor] Current job state in Telepathy: JobState = {0}\n", currentJobState);
                    stateChangedTaskList = await this.GetTaskStateChangeAsync(nodes);

                    TraceHelper.TraceEvent(this.sessionid, TraceEventType.Information, "[AzureBatchJobMonitor] Previous job state report to AzureBatchJobMonitorEntry: JobState = {0}\n", previousJobState);
                    if (state == JobState.Completed || state == JobState.Disabled)
                    {
                        if (this.previousJobState == Session.Data.JobState.Canceling)
                        {
                            currentJobState = Session.Data.JobState.Canceled;
                        }
                        shouldExit = true;
                    }
                    else if (this.previousJobState == Session.Data.JobState.Canceling && !shouldExit)
                    {
                        //Override current job state as Canceling, because when all tasks turn to be completed, the job state converter will make job state finishing.
                        //If one job is cancelling in previous state and now is not in one terminated state, keep to reporting cancelling state to job monitor entry.
                        currentJobState = Session.Data.JobState.Canceling;
                        TraceHelper.TraceEvent(this.sessionid, TraceEventType.Information, "[AzureBatchJobMonitor] Overwrite current job state as {0} in Telepathy according to previous job state {1}\n", currentJobState, previousJobState);
                    }
                }
                catch (BatchException e)
                {
                    TraceHelper.TraceEvent(this.sessionid, TraceEventType.Warning, "[AzureBatchJobMonitor] BatchException thrown when querying job info: {0}", e);
                    //If the previous job state is canceling and current job is not found, then the job is deleted.
                    if (e.RequestInformation != null & e.RequestInformation.HttpStatusCode != null)
                    {
                        if (e.RequestInformation.HttpStatusCode == System.Net.HttpStatusCode.NotFound)
                        {
                            if (previousJobState == Session.Data.JobState.Canceling)
                            {
                                TraceHelper.TraceEvent(this.sessionid, TraceEventType.Warning, "[AzureBatchJobMonitor] The queried job has been deleted.");
                            }
                            else
                            {
                                TraceHelper.TraceEvent(this.sessionid, TraceEventType.Warning, "[AzureBatchJobMonitor] The queried job previous state is {0}, we make its state as canceled because it's no longer exist.", previousJobState);
                            }
                            shouldExit      = true;
                            currentJobState = Session.Data.JobState.Canceled;
                        }
                    }
                }
                catch (Exception e)
                {
                    TraceHelper.TraceEvent(this.sessionid, TraceEventType.Warning, "[AzureBatchJobMonitor] Exception thrown when querying job info: {0}", e);
                }

                try
                {
                    if (this.ReportJobStateAction != null)
                    {
                        TraceHelper.TraceEvent(this.sessionid, TraceEventType.Information,
                                               "[AzureBatchJobMonitor] Current job state report to AzureBatchJobMonitorEntry: JobState = {0}\n",
                                               currentJobState);
                        this.ReportJobStateAction(currentJobState, stateChangedTaskList, shouldExit);
                    }
                }
                catch (Exception e)
                {
                    TraceHelper.TraceEvent(this.sessionid, TraceEventType.Warning, "[AzureBatchJobMonitor] Exception thrown when report job info: {0}", e);
                }

                this.previousJobState = currentJobState;

                if (!shouldExit)
                {
                    TraceHelper.TraceEvent(this.sessionid, TraceEventType.Information, "[AzureBatchJobMonitor] Waiting {0} milliseconds and start another round of getting job state info.", this.pullJobGap);

                    // Sleep and pull job again, clear the register pull job flag
                    await Task.Delay(this.pullJobGap);

                    if (this.pullJobGap < PullJobMaxGap)
                    {
                        this.pullJobGap *= 2;
                        if (this.pullJobGap > PullJobMaxGap)
                        {
                            this.pullJobGap = PullJobMaxGap;
                        }
                    }
                }
            }
        }
예제 #23
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="ProductList"></param>
    private void InsertDefaultSKU(TList<SKUEntity> SKUList)
    {
        string ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ZNodeECommerceDB"].ConnectionString;
        ZNode.Libraries.DataAccess.Service.SKUService ProductSKUServ = new SKUService();

        foreach (SKUEntity entity in SKUList)
        {
            SKU _sku = new SKU();

            int Productid = GetProductID(entity.ProductNum, ConnectionString);
            int SkuId = GetSkuID(entity.SKU, ConnectionString);

            if (Productid == 0)
            {
                break;
            }

            //Set Properties
            _sku.QuantityOnHand = entity.QuantityOnHand;
            _sku.ProductID = Productid;

            if (entity.RetailPriceOverride.HasValue)
            {
                _sku.RetailPriceOverride = entity.RetailPriceOverride.Value;
            }
            _sku.SKU = entity.SKU;

            if (SkuId > 0)
            {
                _sku.UpdateDte = System.DateTime.Now;
                ProductSKUServ.Update(_sku);
            }
            else
            {
                ProductSKUServ.Insert(_sku);
            }

        }
    }
        public override string ToString()
        {
            if (Valid)
            {
                try
                {
                    StringBuilder output = new StringBuilder();

                    output.AppendLine($"HAL build info: {HalBuildVersion?.ToString()}, {HalBuildInfo}");
                    output.AppendLine();
                    output.AppendLine($"Image build @ { ImageBuildDate } { ImageCompilerInfo } v{ ImageCompilerVersion.ToString() }");
                    output.AppendLine();
                    output.AppendLine($"OEM Product codes (vendor, model, SKU): {OEM.ToString()}, {Model.ToString()}, {SKU.ToString()}");
                    output.AppendLine();
                    output.AppendLine("Serial Numbers (module, system):");
                    output.AppendLine("  " + ModuleSerialNumber);
                    output.AppendLine("  " + SystemSerialNumber);
                    output.AppendLine();
                    output.AppendLine($"Solution Build Info: {SolutionBuildVersion?.ToString()}, {SolutionBuildInfo}");

                    output.AppendLine();
                    output.AppendLine("AppDomains:");
                    foreach (IAppDomainInfo adi in AppDomains)
                    {
                        output.AppendLine($"  {adi.Name}, id={adi.ID}");
                    }

                    output.AppendLine();
                    output.AppendLine("Assemblies:");
                    foreach (IAssemblyInfo ai in Assemblies)
                    {
                        output.AppendLine($"  {ai.Name}, {ai.Version}");
                    }

                    output.AppendLine();
                    output.AppendLine("Native Assemblies:");
                    foreach (CLRCapabilities.NativeAssemblyProperties assembly in NativeAssemblies)
                    {
                        output.AppendLine($"  {assembly.Name} v{assembly.Version}, checksum 0x{assembly.Checksum.ToString("X8")}");
                    }

                    return(output.ToString());
                }
                catch { };
            }

            return("DeviceInfo is not valid!");
        }
예제 #25
0
 /// <summary>
 /// Convert back to SKU instance
 /// </summary>
 /// <param name="original">Original SKU. If Null a new instance is created.</param>
 /// <returns>SKU containing viewmodel data </returns>
 public Model.SKU ToEntity(Model.SKU original)
 {
     return(SKU.ToEntity(null));
 }
예제 #26
0
        public void SkuIsGeneratedCorrectly(int cores, int memory, NodeType target, string expectedResult)
        {
            var SKU = new SKU(cores, memory, target);

            Assert.IsTrue(SKU.ToString() == expectedResult);
        }
예제 #27
0
    /// <summary>
    /// Submit Button Click Event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        #region Declarations
        SKUAdmin skuAdminAccess = new SKUAdmin();
        ProductAdmin productAdmin = new ProductAdmin();
        SKUAttribute skuAttribute = new SKUAttribute();
        SKU sku = new SKU();
        ProductCategory productCategory = new ProductCategory();
        ProductCategoryAdmin  productCategoryAdmin=new ProductCategoryAdmin();
        Product product = new Product();
        System.IO.FileInfo fileInfo=null;
        bool retVal = false;

        //check if category was selected
        if (CategoryTreeView.CheckedNodes.Count > 0)
        {
            lblCategoryError.Visible = false;
        }
        else
        {
            lblCategoryError.Visible = true;
            return;
        }

        #endregion

        #region Set Product Properties

        //passing Values
        product.ProductID = ItemID;
        product.PortalID = ZNodeConfigManager.SiteConfig.PortalID;

        //if edit mode then get all the values first
        if (ItemID > 0)
        {
            product = productAdmin.GetByProductId(ItemID);

            if (ViewState["productSkuId"] != null)
            {
                sku.SKUID = int.Parse(ViewState["productSkuId"].ToString());
            }
        }

        //General Info
        product.Name = txtProductName.Text;
        product.ImageFile = txtimagename.Text;
        product.ProductNum = txtProductNum.Text;
        product.PortalID = ZNodeConfigManager.SiteConfig.PortalID;

        if (ProductTypeList.SelectedIndex != -1)
        {
            product.ProductTypeID = Convert.ToInt32(ProductTypeList.SelectedValue);
        }
        else
        {
            //"Please add a product type before you add a new product";
        }
        //MANUFACTURER
        if (ManufacturerList.SelectedIndex != -1)
        {
            if (ManufacturerList.SelectedItem.Text.Equals("No Manufacturer Selected"))
            {
                product.ManufacturerID = null;
            }
            else
            {
                product.ManufacturerID = Convert.ToInt32(ManufacturerList.SelectedValue);
            }
        }

        //Supplier
        if (ddlSupplier.SelectedIndex != -1)
        {
            if (ddlSupplier.SelectedItem.Text.Equals("None"))
            {
                product.SupplierID = null;
            }
            else
            {
                product.SupplierID = Convert.ToInt32(ddlSupplier.SelectedValue);
            }
        }

        product.DownloadLink = txtDownloadLink.Text.Trim();
        product.ShortDescription = txtshortdescription.Text;
        product.Description = ctrlHtmlText.Html;
        product.RetailPrice = Convert.ToDecimal(txtproductRetailPrice.Text);

        if (txtproductSalePrice.Text.Trim().Length > 0)
        {
            product.SalePrice = Convert.ToDecimal(txtproductSalePrice.Text.Trim());
        }
        else { product.SalePrice = null; }

        if (txtProductWholeSalePrice.Text.Trim().Length > 0)
        {
            product.WholesalePrice = Convert.ToDecimal(txtProductWholeSalePrice.Text.Trim());
        }
        else { product.WholesalePrice = null; }

        //Quantity Available
        product.QuantityOnHand = Convert.ToInt32(txtProductQuantity.Text);
        if (txtReOrder.Text.Trim().Length > 0)
        {
            product.ReorderLevel = Convert.ToInt32(txtReOrder.Text);
        }
        else
        {
            product.ReorderLevel = null;
        }
        if(txtMaxQuantity.Text.Equals(""))
        {
            product.MaxQty = 10;
        }
        else
        {
            product.MaxQty = Convert.ToInt32(txtMaxQuantity.Text);
        }

        // Display Settings
        product.MasterPage = ddlPageTemplateList.SelectedItem.Text;
        product.DisplayOrder = int.Parse(txtDisplayOrder.Text.Trim());

        // Tax Settings
        if(ddlTaxClass.SelectedIndex != -1)
            product.TaxClassID = int.Parse(ddlTaxClass.SelectedValue);

        //Shipping Option setting
        product.ShippingRuleTypeID = Convert.ToInt32(ShippingTypeList.SelectedValue);
        product.FreeShippingInd = chkFreeShippingInd.Checked;
        product.ShipSeparately = chkShipSeparately.Checked;

        if (txtProductWeight.Text.Trim().Length > 0)
        {
            product.Weight = Convert.ToDecimal(txtProductWeight.Text.Trim());
        }
        else { product.Weight = null; }

        //Product Height - Which will be used to determine the shipping cost
        if (txtProductHeight.Text.Trim().Length > 0)
        {
            product.Height = decimal.Parse(txtProductHeight.Text.Trim());
        }
        else { product.Height = null; }

        if (txtProductWidth.Text.Trim().Length > 0)
        {
            product.Width = decimal.Parse(txtProductWidth.Text.Trim());
        }
        else { product.Width = null; }

        if (txtProductLength.Text.Trim().Length > 0)
        {
            product.Length = decimal.Parse(txtProductLength.Text.Trim());
        }
        else { product.Length = null; }

        //Stock
        DataSet MyAttributeTypeDataSet = productAdmin.GetAttributeTypeByProductTypeID(int.Parse(ProductTypeList.SelectedValue));
        if (MyAttributeTypeDataSet.Tables[0].Rows.Count == 0)
        {
            product.SKU = txtProductSKU.Text.Trim();
            product.QuantityOnHand = Convert.ToInt32(txtProductQuantity.Text);
        }
        else
        {
            //SKU
            sku.ProductID = ItemID;
            sku.QuantityOnHand = Convert.ToInt32(txtProductQuantity.Text);
            sku.SKU = txtProductSKU.Text.Trim();
            sku.ActiveInd = true;
            product.SKU = txtProductSKU.Text.Trim();
            product.QuantityOnHand = 0; //Reset quantity available in the Product table,If SKU is selected
        }

        product.ImageAltTag = txtImageAltTag.Text.Trim();
        #endregion

        #region Image Validation

        // Validate image
        if ((ItemID == 0 || RadioProductNewImage.Checked == true) && UploadProductImage.PostedFile.FileName.Length > 0)
        {
            //Check for Product Image
            fileInfo = new System.IO.FileInfo(UploadProductImage.PostedFile.FileName);

            if (fileInfo != null)
            {
              product.ImageFile = fileInfo.Name;
              sku.SKUPicturePath = fileInfo.Name;
            }
        }
        #endregion

        #region Database & Image Updates

        //set update date
        product.UpdateDte = System.DateTime.Now;

        //create transaction
        TransactionManager tranManager = ConnectionScope.CreateTransaction();

        try
        {
            if (ItemID > 0) //PRODUCT UPDATE
            {
                //Update product Sku and Product values
                if (MyAttributeTypeDataSet.Tables[0].Rows.Count > 0) //If ProductType has SKU's
                {
                    if (sku.SKUID > 0) //For this product already SKU if on exists
                    {
                        sku.UpdateDte = System.DateTime.Now;

                        // Check whether Duplicate attributes is created
                        string Attributes = String.Empty;

                        DataSet MyAttributeTypeDataSet1 = productAdmin.GetAttributeTypeByProductTypeID(ProductTypeId);

                        foreach (DataRow MyDataRow in MyAttributeTypeDataSet1.Tables[0].Rows)
                        {
                            System.Web.UI.WebControls.DropDownList lstControl = (System.Web.UI.WebControls.DropDownList)ControlPlaceHolder.FindControl("lstAttribute" + MyDataRow["AttributeTypeId"].ToString());

                            int selValue = int.Parse(lstControl.SelectedValue);

                            Attributes += selValue.ToString() + ",";
                        }

                        // Split the string
                        string Attribute = Attributes.Substring(0, Attributes.Length - 1);

                        // To check SKU combination is already exists.
                        bool RetValue = skuAdminAccess.CheckSKUAttributes(ItemID, sku.SKUID, Attribute);

                        if (!RetValue)
                        {
                            //then Update the database with new property values
                            retVal = productAdmin.Update(product, sku);
                        }
                        else
                        {
                            //Throw error if duplicate attribute
                            lblMsg.Text = "This Attribute combination already exists for this product. Please select different combination.";
                            return;
                        }
                    }
                    else
                    {
                        retVal = productAdmin.Update(product);
                        //If Product doesn't have any SKUs yet,then create new SKU in the database
                        skuAdminAccess.Add(sku);
                    }
                }
                else
                {
                    retVal = productAdmin.Update(product);
                    // If User selectes Default product type for this product,
                    // then Remove all the existing SKUs for this product
                    skuAdminAccess.DeleteByProductId(ItemID);
                }

                if (!retVal) { throw (new ApplicationException()); }

                // Delete existing categories
                productAdmin.DeleteProductCategories(ItemID);

                // Add Product Categories
                foreach (TreeNode Node in CategoryTreeView.CheckedNodes)
                {
                    ProductCategory prodCategory = new ProductCategory();
                    ProductAdmin prodAdmin = new ProductAdmin();

                    prodCategory.CategoryID = int.Parse(Node.Value);
                    prodCategory.ProductID = ItemID;
                    prodAdmin.AddProductCategory(prodCategory);
                }

                // Delete existing SKUAttributes
                skuAdminAccess.DeleteBySKUId(sku.SKUID);

                // Add SKU Attributes
                foreach (DataRow MyDataRow in MyAttributeTypeDataSet.Tables[0].Rows)
                {
                    System.Web.UI.WebControls.DropDownList lstControl = (System.Web.UI.WebControls.DropDownList)ControlPlaceHolder.FindControl("lstAttribute" + MyDataRow["AttributeTypeId"].ToString());

                    int selValue = int.Parse(lstControl.SelectedValue);

                    if (selValue > 0)
                    {
                        skuAttribute.AttributeId = selValue;
                    }

                    skuAttribute.SKUID = sku.SKUID;

                    skuAdminAccess.AddSKUAttribute(skuAttribute);

                }

            }
            else // PRODUCT ADD
            {
                product.ActiveInd = true;

                // Add Product/SKU
                if (MyAttributeTypeDataSet.Tables[0].Rows.Count > 0)
                {
                    //if ProductType has SKUs, then insert sku with Product
                    retVal = productAdmin.Add(product, sku, out _ProductID, out SKUId);
                }
                else
                {
                    retVal = productAdmin.Add(product, out _ProductID); //if ProductType is Default
                }

                if (!retVal) { throw (new ApplicationException()); }

                // Add Category List for the Product
                foreach (TreeNode Node in CategoryTreeView.CheckedNodes)
                {
                    ProductCategory prodCategory = new ProductCategory();
                    ProductAdmin prodAdmin = new ProductAdmin();

                    prodCategory.CategoryID = int.Parse(Node.Value);
                    prodCategory.ProductID = _ProductID;
                    prodAdmin.AddProductCategory(prodCategory);
                }

                // Add SKU Attributes
                foreach (DataRow MyDataRow in MyAttributeTypeDataSet.Tables[0].Rows)
                {
                    System.Web.UI.WebControls.DropDownList lstControl = (System.Web.UI.WebControls.DropDownList)ControlPlaceHolder.FindControl("lstAttribute" + MyDataRow["AttributeTypeId"].ToString());

                    int selValue = int.Parse(lstControl.SelectedValue);

                    if (selValue > 0)
                    {
                        skuAttribute.AttributeId = selValue;
                    }

                    skuAttribute.SKUID = SKUId;

                    skuAdminAccess.AddSKUAttribute(skuAttribute);
                }

                ZNode.Libraries.Admin.ProductViewAdmin imageAdmin = new ProductViewAdmin();
                ZNode.Libraries.DataAccess.Entities.ProductImage productImage = new ProductImage();

                productImage.Name = txtimagename.Text;
                productImage.ActiveInd = false;
                productImage.ShowOnCategoryPage = false;
                productImage.ProductID = _ProductID;
                productImage.ProductImageTypeID = 1;
                productImage.DisplayOrder = 500;
                productImage.ImageAltTag = txtImageAltTag.Text.Trim();
                productImage.AlternateThumbnailImageFile = txtImageAltTag.Text.Trim();

                if (fileInfo != null)
                {
                    productImage.ImageFile = fileInfo.Name;
                }

                imageAdmin.Insert(productImage);
            }

            // Commit transaction
            tranManager.Commit();
        }
        catch // error occurred so rollback transaction
        {
            if (tranManager.IsOpen)
                tranManager.Rollback();

            lblMsg.Text = "Unable to update product. Please try again.";
            return;
        }

        // Upload File if this is a new product or the New Image option was selected for an existing product
        if (RadioProductNewImage.Checked || ItemID == 0)
        {
            if (fileInfo != null)
            {
                UploadProductImage.SaveAs(Server.MapPath(ZNodeConfigManager.EnvironmentConfig.OriginalImagePath + fileInfo.Name));

                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemLargeWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.LargeImagePath));
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemThumbnailWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.ThumbnailImagePath));
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemMediumWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.MediumImagePath));
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemSmallWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.SmallImagePath));
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemSwatchWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.SwatchImagePath));
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemCrossSellWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.CrossSellImagePath));
            }
        }

        #endregion

        #region Redirect to next page
        //Redirect to next page
        if (ItemID > 0)
        {
            string ViewLink = "~/admin/secure/catalog/product/view.aspx?itemid=" + ItemID.ToString();
            Response.Redirect(ViewLink);
        }
        else
        {
            string NextLink = "~/admin/secure/catalog/product/view.aspx?itemid=" + _ProductID.ToString();
            Response.Redirect(NextLink);
        }
        #endregion
    }
예제 #28
0
        private void MI15_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            ofd.Filter = "CSV files (*.csv)|*.csv";
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                List <SKU>     ls     = new List <SKU>();
                List <SkuAnot> lskuan = new List <SkuAnot>();
                string         content;
                using (StreamReader sr = new StreamReader(ofd.FileName))
                {
                    while ((content = sr.ReadLine()) != null)
                    {
                        string[] mas = content.Split(';');
                        SKU      s   = new SKU();
                        SkuAnot  sa  = new SkuAnot();

                        for (int i = 0; i < mas.Length; i++)
                        {
                            switch (i)
                            {
                            case 0: s.Name = mas[i]; break;

                            case 1: s.InputPrice = double.Parse(mas[i]); break;

                            case 2: if (mas[i] != string.Empty)
                                {
                                    s.Price = int.Parse(mas[i]);
                                }
                                else
                                {
                                    s.Price = 0;
                                }
                                break;

                            case 3: s.idComfy = mas[i]; break;

                            case 4: s.idRozetka = mas[i]; break;

                            case 5: s.idAllo = mas[i]; break;

                            case 6: s.idEldorado = mas[i]; break;

                            case 7: s.UrlHotline = mas[i]; break;

                            case 8: sa.Val1 = mas[i]; break;

                            case 9: sa.Val2 = mas[i]; break;

                            case 10: sa.Val3 = mas[i]; break;

                            case 11: sa.Val4 = mas[i]; break;

                            case 12: sa.Val5 = mas[i]; break;

                            case 13: sa.Val6 = mas[i]; break;

                            case 14: sa.Val7 = mas[i]; break;

                            case 15: sa.Val8 = mas[i]; break;

                            case 16: sa.Val9 = mas[i]; break;

                            case 17: sa.Val10 = mas[i]; break;

                            case 18: sa.Val11 = mas[i]; break;

                            case 19: sa.Val12 = mas[i]; break;
                            }
                        }
                        ls.Add(s);
                        lskuan.Add(sa);
                    }
                }
                int j = 0;
                foreach (SKU s in ls)
                {
                    AddSKU asku = new AddSKU(s, lskuan[j]);
                    this.Visibility = Visibility.Hidden;
                    asku.ShowDialog();
                    this.Visibility = Visibility.Visible;
                    j++;
                }
            }
        }
예제 #29
0
        //Security Defect -START - Added the below code to validate the fields in the lineitem
        public CCResponse ValidateFields()
        {
            //Security Defect - Added the below code to trim all the fields
            ProductCode   = ProductCode.Trim();
            ProductName   = ProductName.Trim();
            ClubCode      = ClubCode.Trim();
            SubProduct    = SubProduct.Trim();
            AccountNumber = AccountNumber.Trim();
            LastName      = LastName.Trim();
            FirstName     = FirstName.Trim();
            SKU           = SKU.Trim();
            RevenueCode   = RevenueCode.Trim();
            RevenueType   = RevenueType.Trim();
            //Security Defect - Added the below code to trim all the fields
            CCResponse c = new CCResponse();

            if ((ProductCode.Length > 10) || junkValidation(ProductCode))
            {
                c.Message       = CSAAWeb.Constants.ERR_AUTHVALIDATION + "ProductCode";
                c.ActualMessage = c.Message;
                c.Flag          = Config.Setting("ERRCDE_PRODUCTCODE");
                Logger.Log(c.Message + c.Flag);
                return(c);
            }
            if ((ProductName.Length > 50) || junkValidation(ProductName))
            {
                c.Message       = CSAAWeb.Constants.ERR_AUTHVALIDATION + "ProductName";
                c.ActualMessage = c.Message;
                c.Flag          = Config.Setting("ERRCDE_PRODUCTNAME");
                Logger.Log(c.Message + c.Flag);
                return(c);
            }
            if ((ClubCode.Length > 50) || junkValidation(ClubCode))
            {
                c.Message       = CSAAWeb.Constants.ERR_AUTHVALIDATION + "ClubCode";
                c.ActualMessage = c.Message;
                c.Flag          = Config.Setting("ERRCDE_CLUBCODE");
                Logger.Log(c.Message + c.Flag);
                return(c);
            }
            if ((SubProduct.Length > 25) || junkValidation(SubProduct))
            {
                c.Message       = CSAAWeb.Constants.ERR_AUTHVALIDATION + "SubProduct";
                c.ActualMessage = c.Message;
                c.Flag          = Config.Setting("ERRCDE_SUBPRODUCT");
                Logger.Log(c.Message + c.Flag);
                return(c);
            }
            if (IsMissing(AccountNumber) || (AccountNumber.Length > 25) || junkValidation(AccountNumber))
            {
                c.Message       = CSAAWeb.Constants.ERR_AUTHVALIDATION + "AccountNumber";
                c.ActualMessage = c.Message;
                c.Flag          = Config.Setting("ERRCDE_ACCOUNTNUMBER");
                Logger.Log(c.Message + c.Flag);
                return(c);
            }
            //if (IsMissing(LastName))
            //{
            //    c.Message = CSAAWeb.Constants.ERR_AUTHVALIDATION + "LastName";
            //    c.ActualMessage = c.Message;
            //    c.Flag = Config.Setting("ERRCDE_LASTNAME");
            //    Logger.Log(c.Message + c.Flag);
            //    return c;
            //}
            //if (IsMissing(FirstName))
            //{
            //    c.Message = CSAAWeb.Constants.ERR_AUTHVALIDATION + "FirstName";
            //    c.ActualMessage = c.Message;
            //    c.Flag = Config.Setting("ERRCDE_FIRSTNAME");
            //    Logger.Log(c.Message + c.Flag);
            //    return c;
            //}
            if ((SKU.Length > 3) || junkValidation(SKU))
            {
                c.Message       = CSAAWeb.Constants.ERR_AUTHVALIDATION + "SKU";
                c.ActualMessage = c.Message;
                c.Flag          = Config.Setting("ERRCDE_SKU");
                Logger.Log(c.Message + c.Flag);
                return(c);
            }
            if ((RevenueCode.Length > 10) || junkValidation(RevenueCode))
            {
                c.Message       = CSAAWeb.Constants.ERR_AUTHVALIDATION + "RevenueCode";
                c.ActualMessage = c.Message;
                c.Flag          = Config.Setting("ERRCDE_REVENUECODE");
                Logger.Log(c.Message + c.Flag);
                return(c);
            }
            if (IsMissing(RevenueType) || (RevenueType.Length > 20) || junkValidation(RevenueType))
            {
                c.Message       = CSAAWeb.Constants.ERR_AUTHVALIDATION + "RevenueType";
                c.ActualMessage = c.Message;
                c.Flag          = Config.Setting("ERRCDE_REVENUETYPE");
                Logger.Log(c.Message + c.Flag);
                return(c);
            }
            if ((Amount < 0) || (Amount > 25000) || junkValidation(Amount.ToString()))
            {
                c.Message       = CSAAWeb.Constants.ERR_AUTHVALIDATION + "Amount";
                c.ActualMessage = c.Message;
                c.Flag          = Config.Setting("ERRCDE_AMOUNT");
                Logger.Log(c.Message + c.Flag);
                return(c);
            }
            if ((Tax_Amount < 0) || (Tax_Amount > 25000) || junkValidation(Tax_Amount.ToString()))
            {
                c.Message       = CSAAWeb.Constants.ERR_AUTHVALIDATION + "Tax_Amount";
                c.ActualMessage = c.Message;
                c.Flag          = Config.Setting("ERRCDE_TAXAMOUNT");
                Logger.Log(c.Message + c.Flag);
                return(c);
            }
            //if ((LineItemNo > 10) || !CSAAWeb.Validate.IsAllNumeric(LineItemNo.ToString()))
            //{
            //    c.Message = CSAAWeb.Constants.ERR_AUTHVALIDATION + "LineItemNo";
            //    c.ActualMessage = c.Message;
            //    c.Flag = Config.Setting("ERRCDE_LINEITEMNO");
            //    Logger.Log(c.Message + c.Flag);
            //    return c;
            //}
            if ((Quantity > 10) || !CSAAWeb.Validate.IsAllNumeric(Quantity.ToString()))
            {
                c.Message       = CSAAWeb.Constants.ERR_AUTHVALIDATION + "Quantity";
                c.ActualMessage = c.Message;
                c.Flag          = Config.Setting("ERRCDE_QUANTITY");
                Logger.Log(c.Message + c.Flag);
                return(c);
            }
            else
            {
                return(null);
            }
            //Security Defect -END - Added the below code to validate the fields in the lineitem
        }
 public int ApplySinglePromotion(SKU item)
 {
     return((item.Count / item.OfferCount) * item.OfferPrice + (item.Count % item.OfferCount * item.ActualPrice));
 }
 public static ValueTask <bool> ProductWithSKUExists(this WarehouseDBContext dbContext, SKU productSKU, CancellationToken ct)
 => new (dbContext.Set <Product>().AnyAsync(product => product.Sku.Value == productSKU.Value, ct));
예제 #32
0
        public void CheckSKU()
        {
            int countSKU = SKU.GetSKUCount();

            Assert.AreEqual(26, countSKU);
        }
        private void FillArtToKit(KitWrapper kit, IUnitOfWork uow)
        {
            var arts = ArtLoadHelper.FindArtByArtName(kit.MANDANTID, kit.ARTNAME, GetModeEnum.Full, uow);

            using (var artMgr = IoC.Instance.Resolve <IBaseManager <Art> >())
            {
                if (uow != null)
                {
                    artMgr.SetUnitOfWork(uow);
                }

                // если его нет, то создаем артикул и SKU
                if (!arts.Any())
                {
                    if (kit.KITINSART == 1)
                    {
                        var art = new Art
                        {
                            ArtName       = kit.ARTNAME,
                            ArtDesc       = kit.ARTDESC,
                            ArtCommercDay = 0,
                            ArtPickOrder  = 1,
                            ARTABCD       = kit.ARTABCD,
                            MANDANTID     = kit.MANDANTID
                        };
                        SetXmlIgnore(art, false);
                        artMgr.Insert(ref art);
                        kit.ARTCODE_R = art.ArtCode;
                        Log.DebugFormat("Создан артикул комплекта '{0}'", kit.ARTCODE_R);
                    }
                    else
                    {
                        throw new IntegrationLogicalException("Не существует артикул комплекта = '{0}'", kit.ARTNAME);
                    }

                    // есть ли тип ЕИ
                    var mtFilter = string.Format("{0} = '{1}'",
                                                 SourceNameHelper.Instance.GetPropertySourceName(typeof(MeasureType), MeasureType.MeasureTypeNamePropertyName),
                                                 kit.KITMEASURE);
                    var mtMgr = IoC.Instance.Resolve <IBaseManager <MeasureType> >();
                    mtMgr.SetUnitOfWork(uow);
                    var    measureTypes = mtMgr.GetFiltered(mtFilter).ToArray();
                    string measureTypeCode;
                    if (!measureTypes.Any())
                    {
                        var measureType = new MeasureType
                        {
                            MeasureTypeCode = "U" + kit.KITMEASURE,
                            MeasureTypeName = kit.KITMEASURE
                        };
                        SetXmlIgnore(measureType, false);
                        mtMgr.Insert(ref measureType);
                        measureTypeCode = measureType.MeasureTypeCode;
                        Log.DebugFormat("Создан тип ЕИ (ID = {0})", measureTypeCode);
                    }
                    else
                    {
                        measureTypeCode = measureTypes[0].MeasureTypeCode;
                        Log.DebugFormat("Найден тип ЕИ (ID = {0})", measureTypeCode);
                    }

                    // есть ли ЕИ
                    var measureFilter = string.Format("{0} = '{1}'",
                                                      SourceNameHelper.Instance.GetPropertySourceName(typeof(Measure), Measure.MeasureNamePropertyName),
                                                      kit.KITMEASURE);
                    var measureMgr = IoC.Instance.Resolve <IBaseManager <Measure> >();
                    measureMgr.SetUnitOfWork(uow);
                    var    measures = measureMgr.GetFiltered(measureFilter).ToArray();
                    string measureCode;
                    if (!measures.Any())
                    {
                        var measure = new Measure
                        {
                            MeasureTypeCodeR = measureTypeCode,
                            MeasureFactor    = 1,
                            MeasureName      = kit.KITMEASURE,
                            MeasureCode      = kit.KITMEASURE
                        };
                        SetXmlIgnore(measure, false);
                        measureMgr.Insert(ref measure);
                        measureCode = measure.MeasureCode;
                        Log.DebugFormat("Создана ЕИ (ID = {0})", measureCode);
                    }
                    else
                    {
                        measureCode = measures[0].MeasureCode;
                        Log.DebugFormat("Найдена ЕИ (ID = {0})", measureCode);
                    }

                    var skuMgr = IoC.Instance.Resolve <IBaseManager <SKU> >();
                    skuMgr.SetUnitOfWork(uow);
                    var sku = new SKU
                    {
                        ArtCode     = kit.ARTCODE_R,
                        MeasureCode = measureCode,
                        SKUCount    = (double)SerializationHelper.ConvertToTrueType(kit.KITCOUNT, typeof(double)),
                        SKUPrimary  = true,
                        SKUName     = kit.ARTNAME + "_" + kit.KITMEASURE + "_1"
                    };
                    SetXmlIgnore(sku, false);
                    skuMgr.Insert(ref sku);
                    Log.DebugFormat("Создана SKU шапки комплекта (ID = {0})", sku.SKUID);
                }
                else
                {
                    var firstOrDefault = arts.FirstOrDefault();
                    if (firstOrDefault != null)
                    {
                        kit.ARTCODE_R = firstOrDefault.ArtCode;
                    }
                }
            }
        }
예제 #34
0
        public Task GetOSInfo()
        {
            return(Task.Run(() =>
            {
                //网络是否连接
                int i = 0;
                if (InternetGetConnectedState(out i, 0))
                {
                    this.Text = "      " + Language.Default.main_窗口名_在线 + " " + soft_ver;
                }
                else
                {
                    this.Text = "      " + Language.Default.main_窗口名_离线 + " " + soft_ver;
                }

                Register register = new Register(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", Register.RegDomain.LocalMachine);

                ManagementScope scope = new ManagementScope(@"\\" + System.Environment.MachineName + @"\root\cimv2");
                scope.Connect();
                SelectQuery searchQuery = new SelectQuery("SELECT * FROM SoftwareLicensingProduct WHERE PartialProductKey <> null AND ApplicationID = '55c92734-d682-4d71-983e-d6ec3f16059f'");
                ManagementObjectSearcher searcherObj = new ManagementObjectSearcher(scope, searchQuery);
                foreach (ManagementBaseObject mo in searcherObj.Get())
                {
                    string[] nameArray = mo["Name"].ToString().Split(' ');
                    OsName = nameArray[1];                                    //产品名称
                    string[] desArray = mo["Description"].ToString().Split(' ');
                    OsDescription = desArray[3];                              //描述
                    OsID = mo["ID"].ToString();                               //激活ID
                    OsPartialProductKey = mo["PartialProductKey"].ToString(); //部份产品密钥
                    OsLicenseStatus = mo["LicenseStatus"].ToString();         //许可状态
                }

                //版本号
                string ver = register.ReadRegeditKey("BuildLabEx").ToString();
                string[] verArray = ver.Split('.');
                OsBuild = verArray[0] + "." + verArray[1];

                //许可状态
                switch (OsLicenseStatus)
                {
                case "0":
                    {
                        ProductStatus = Language.Default.info_未授权;
                        break;
                    }

                case "1":
                    {
                        ProductStatus = Language.Default.info_已授权;
                        break;
                    }

                case "2":
                    {
                        ProductStatus = Language.Default.info_初始宽限期;
                        break;
                    }

                case "3":
                    {
                        ProductStatus = Language.Default.info_延长宽限期;
                        break;
                    }

                case "4":
                    {
                        ProductStatus = Language.Default.info_非正版宽限期;
                        break;
                    }

                case "5":
                    {
                        ProductStatus = Language.Default.info_通知状态;
                        break;
                    }

                default:
                    {
                        ProductStatus = Language.Default.info_未知;
                        break;
                    }
                }

                //SKU值
                int SKU;
                GetProductInfo(
                    Environment.OSVersion.Version.Major,
                    Environment.OSVersion.Version.Minor,
                    0,
                    0,
                    out SKU);
                if (OsName == "ProfessionalEducation")
                {
                    sku_textBox.Text = "164";
                }
                else if (OsName == "ProfessionalEducationN")
                {
                    sku_textBox.Text = "165";
                }
                else
                {
                    sku_textBox.Text = SKU.ToString();
                }

                //将获取的值显示到listView1
                //1.产品
                listView1.Items[0].SubItems[1].Text = OsName + " [" + OsBuild + "]";
                //2.类型
                if (Environment.Is64BitOperatingSystem)
                {
                    listView1.Items[1].SubItems[1].Text = "x64";
                }
                else
                {
                    listView1.Items[1].SubItems[1].Text = "x86";
                }
                //3.描述
                listView1.Items[2].SubItems[1].Text = OsDescription;
                //4.激活ID
                listView1.Items[3].SubItems[1].Text = OsID;
                //5.部份密钥
                listView1.Items[4].SubItems[1].Text = OsPartialProductKey;
                //6.许可状态
                listView1.Items[5].SubItems[1].Text = ProductStatus;
                //7.WindowsUpdate状态
                register.SubKey = @"SYSTEM\CurrentControlSet\Services\wuauserv";
                string WU = register.ReadRegeditKey("Start").ToString();
                switch (WU)
                {
                case "1":
                    {
                        WUStatus = Language.Default.info_WU_自动延迟;
                        break;
                    }

                case "2":
                    {
                        WUStatus = Language.Default.info_WU_自动;
                        break;
                    }

                case "3":
                    {
                        WUStatus = Language.Default.info_WU_手动;
                        break;
                    }

                case "4":
                    {
                        WUStatus = Language.Default.info_WU_禁用;
                        break;
                    }
                }
                listView1.Items[6].SubItems[1].Text = WUStatus;

                //如果KEY文本框为空,显示内置KEY
                if (key_textBox.Text == "")
                {
                    if (editionDic.ContainsKey(OsName.ToString()))
                    {
                        if (OsName == "EnterpriseS" && OsBuild.Contains("10240"))
                        {
                            key_textBox.Text = "FWN7H-PF93Q-4GGP8-M8RF3-MDWWW";
                        }
                        else if (OsName == "EnterpriseSN" && OsBuild.Contains("10240"))
                        {
                            key_textBox.Text = "8V8WN-3GXBH-2TCMG-XHRX3-9766K";
                        }
                        else
                        {
                            key_textBox.Text = editionDic[OsName.ToString()];
                        }
                    }
                    else
                    {
                        key_textBox.Text = Language.Default.提示_无KEY;
                    }
                }
            }));
        }
예제 #35
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="ds"></param>
    /// <param name="appSettings"></param>
    /// <param name="connString"></param>
    private void UploadProductRetailPrice(ZNode.Libraries.Framework.Business.ZNodeGenericCollection<ProductSKUEntity> ProdSKUList, string connString)
    {
        #region Local Variable Declaration
        SqlConnection conn = new SqlConnection(connString);
        ZNode.Libraries.DataAccess.Service.ProductService ProductServ = new ProductService();
        ZNode.Libraries.DataAccess.Service.SKUService ProductSKUServ = new SKUService();
        ZNode.Libraries.DataAccess.Service.AddOnValueService ProductAddOnValueServ = new AddOnValueService();
        #endregion

        foreach (ProductSKUEntity entity in ProdSKUList)
        {
            SKU _sku = new SKU();

            //Update Prodcut table
            int ProductID = GetProductBySKU(entity.SKU, connString);

            if (ProductID > 0)
            {
                Product _productObject = ProductServ.GetByProductID(ProductID);
                _productObject.RetailPrice = entity.RetailPrice;
                _productObject.SalePrice = entity.SalePrice;
                _productObject.WholesalePrice = entity.WholesalePrice;
                _productObject.UpdateDte = System.DateTime.Now;

                ProductServ.Update(_productObject);
            }

            //Update SKU table
            int SkuId = GetSkuID(entity.SKU, connString);

            if (SkuId > 0)
            {
                _sku = ProductSKUServ.GetBySKUID(SkuId);
                //Set Quantity available value
                _sku.RetailPriceOverride = entity.RetailPrice;
                _sku.SalePriceOverride = entity.SalePrice;
                _sku.WholesalePriceOverride = entity.WholesalePrice;

                _sku.UpdateDte = System.DateTime.Now;

                //Upate SKU
                ProductSKUServ.Update(_sku);
            }

            //Update Add-On table
            AddOnValue _addOnvalue = new AddOnValue();

            int AddOnValueId = GetSkuIDByAddOnValueSKU(entity.SKU, connString);

            if (AddOnValueId > 0)
            {
                _addOnvalue = ProductAddOnValueServ.GetByAddOnValueID(AddOnValueId);

                _addOnvalue.RetailPrice = entity.RetailPrice;
                _addOnvalue.SalePrice = entity.SalePrice;
                _addOnvalue.WholesalePrice = entity.WholesalePrice;

                _addOnvalue.UpdateDte = System.DateTime.Now;

                ProductAddOnValueServ.Update(_addOnvalue);
            }
        }
    }
예제 #36
0
        /// <summary>
        /// 加載SKU在Allpart的配置信息從Allpart系統加載mes1.c_product_config, mes4.r_pcba_link
        /// 將查詢到的結果存入Dictionary<string_Datarow> 中, key為表名如:" c_product_config "
        /// 2018/1/3 肖倫
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void SkuAPInfoDataloader(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            string  StrSku = "";
            string  StrVer = "";
            SKU     sku    = new SKU();
            OleExec apdb   = null;
            Dictionary <string, List <DataRow> > APInfo = new Dictionary <string, List <DataRow> >();

            if (Paras.Count != 2)
            {
                string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000057");
                throw new MESReturnMessage(errMsg);
            }
            MESStationSession APConfig_Session = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (APConfig_Session == null)
            {
                APConfig_Session = new MESStationSession()
                {
                    MESDataType = Paras[0].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[0].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(APConfig_Session);
            }

            MESStationSession Wo_Session = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (Wo_Session == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY }));
            }
            //Modify by LLF 2017-01-25 For 獲取工單對象,從工單對象中獲取料號,版本
            //MESStationSession Sku_Session = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);
            //if (Sku_Session == null)
            //{
            //    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY }));
            //}
            //else
            //{
            //    sku = (SKU)Sku_Session.Value;
            //    if (sku == null || sku.SkuNo == null || sku.SkuNo.Length <= 0)
            //    {
            //        throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY }));
            //    }
            //    if (sku.Version == null || sku.Version.Length <= 0)
            //    {
            //        throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY + " Version" }));
            //    }
            //}
            //獲取ALLPART數據
            try
            {
                StrSku = ((MESStation.LogicObject.WorkOrder)Wo_Session.Value).SkuNO;
                StrVer = ((MESStation.LogicObject.WorkOrder)Wo_Session.Value).SKU_VER;
                apdb   = Station.APDB;
                AP_DLL         APDLL      = new AP_DLL();
                List <DataRow> ConfigList = APDLL.C_Product_Config_GetBYSkuAndVerson(StrSku, StrVer, apdb);
                if (ConfigList.Count <= 0)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000072", new string[] { "SKU:" + StrSku + ",VER:" + StrVer, "C_PRODUCT_CONFIG" }));
                }
                APInfo.Add("C_PRODUCT_CONFIG", ConfigList);
                List <DataRow> PCBALinkList = APDLL.R_PCBA_LINK_GetBYSku(StrSku, apdb);
                if (PCBALinkList.Count <= 0)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000072", new string[] { "SKU:" + StrSku, "R_PCBA_LINK" }));
                }
                APInfo.Add("R_PCBA_LINK", PCBALinkList);
                APConfig_Session.Value = APInfo;

                Station.AddMessage("MES00000001", new string[] { StrSku }, MESPubLab.MESStation.MESReturnView.Station.StationMessageState.Pass);
                //Modify By LLF 2018-01-25 For 料號&版本從工單對象中獲取,而不是從C_SKU 中獲取

                /* List<DataRow> ConfigList = APDLL.C_Product_Config_GetBYSkuAndVerson(sku.SkuNo, sku.Version, apdb);
                 * if (ConfigList.Count <= 0)
                 * {
                 * throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000072", new string[] { "SKU:" + sku.SkuNo, "C_PRODUCT_CONFIG" }));
                 * }
                 * APInfo.Add("C_PRODUCT_CONFIG", ConfigList);
                 * List<DataRow> PCBALinkList = APDLL.R_PCBA_LINK_GetBYSku(sku.SkuNo, apdb);
                 * if (PCBALinkList.Count <= 0)
                 * {
                 *  throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000072", new string[] { "SKU:" + sku.SkuNo, "R_PCBA_LINK" }));
                 * }
                 * APInfo.Add("R_PCBA_LINK", PCBALinkList);
                 * APConfig_Session.Value = APInfo;
                 * Station.DBS["APDB"].Return(apdb);
                 * Station.AddMessage("MES00000001", new string[] { sku.SkuNo }, MESPubLab.MESStation.MESReturnView.Station.StationMessageState.Pass);
                 */
            }
            catch (Exception ex)
            {
                if (apdb != null)
                {
                }
                throw ex;
            }
        }
예제 #37
0
        public string AddOrder(dynamic requestData)
        {
            try
            {
                //if (string.IsNullOrEmpty(requestData.OrderName))
                //{
                //    return "姓名不能为空";
                //}
                //if (string.IsNullOrEmpty(requestData.OrderTelephone))
                //{
                //    return "手机号不能为空";
                //}
                LogHelper.WriteLog("AddOrder-log:" + requestData.ToString());
                string           query     = JsonConvert.SerializeObject(requestData);
                RequestOrderInfo orderInfo = JsonConvert.DeserializeObject <RequestOrderInfo>(query);

                #region  单判断库存部分
                if (orderInfo.OrderType != 2)
                {
                    foreach (var item in orderInfo.OrderDetaile)
                    {
                        var sql = string.Format("Select Stock from SKU Where SkuId = {0}", item.SkuId);
                        var q   = dataContext.ExecuteScalar(CommandType.Text, sql);

                        if ((int)q < item.Count)
                        {
                            return("Stock is not enough");
                        }
                    }
                }
                #endregion

                //操作订单积分
                string integralSql = string.Format("update RegistMember Set LeaveIntegral = LeaveIntegral - {0} where MemberId = {1}", orderInfo.OrderPrice, orderInfo.MemberId);
                int    nums        = dataContext.ExecuteNonQuery(CommandType.Text, integralSql);

                if (nums > 0)
                {
                    #region 订单新增部分
                    MemberOrder order = new MemberOrder();
                    order.MemberId       = orderInfo.MemberId;
                    order.OrderName      = orderInfo.OrderName;
                    order.OrderTelephone = orderInfo.OrderTelephone;
                    order.OrderState     = orderInfo.OrderState;
                    order.OrderAddress   = orderInfo.OrderAddress;
                    order.OrderPrice     = orderInfo.OrderPrice;
                    order.OrderType      = orderInfo.OrderType;
                    order.InventedType   = orderInfo.InventedType;
                    order.LogisticsNo    = "";
                    order.LogisticsType  = "";
                    order.OrderFrom      = orderInfo.OrderFrom;
                    order.OrderRemark    = orderInfo.OrderRemark;
                    order.AddDate        = DateTime.Now;

                    db.Order.Add(order);
                    db.SaveChanges();
                    #endregion

                    string date   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    string remark = "积分商城:" + order.OrderId;
                    //记录积分操作日志
                    string logsql = string.Format("insert into MemberIntegralDetail values({0},{1},'{2}',2,'积分商城','{2}','{3}','','');", order.MemberId, order.OrderPrice, date, remark);
                    dataContext.ExecuteNonQuery(CommandType.Text, logsql);

                    #region 新增订单商品
                    //新增完订单获取到订单ID然后录入订单商品
                    foreach (var item in orderInfo.OrderDetaile)
                    {
                        string sql = string.Format("Insert into OrderDetaile Values({0},{1},'{2}',{3},{4})", order.OrderId, item.SkuId, item.SkuName, item.ProductId, item.Count);

                        var count = dataContext.ExecuteNonQuery(CommandType.Text, sql);

                        string stockSql = string.Format("Update SKU Set Stock = Stock - {0} Where SkuId = {1}", item.Count, item.SkuId);
                        dataContext.ExecuteNonQuery(CommandType.Text, stockSql);
                    }
                    #endregion

                    //虚拟商品订单-欧飞充值
                    if (order.OrderType == 2)
                    {
                        int id     = orderInfo.OrderDetaile[0].SkuId;
                        int skuNum = orderInfo.OrderDetaile[0].Count;
                        SKU sku    = (from s in db.SKU
                                      where s.SkuId == id
                                      select s).FirstOrDefault();
                        int price = Convert.ToInt32(sku.MarketPrice);

                        if (!string.IsNullOrEmpty(order.OrderTelephone))
                        {
                            for (int i = 0; i < skuNum; i++)
                            {
                                LogHelper.WriteLog("共" + skuNum + "件商品,充值电话:" + order.OrderTelephone + ",充值的面值:" + price);
                                InventedManage(order.InventedType, order.OrderTelephone, i.ToString(), order.OrderId.ToString(), price);
                            }
                        }
                    }
                    return(order.OrderId.ToString());
                }
                else
                {
                    return("Integral is not enough");
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("AddOrder-error:" + ex.ToString());
                return(ex.Message);
            }
        }