Example #1
0
        public ActionResult AddProduct()
        {
            string ProductNum  = WebUtil.GetFormValue <string>("SnNum", string.Empty);
            string BarCode     = WebUtil.GetFormValue <string>("BarCode", string.Empty);
            string ProductName = WebUtil.GetFormValue <string>("ProductName", string.Empty);
            string BatchNum    = WebUtil.GetFormValue <string>("ProductBatch", string.Empty);
            string LocalNum    = WebUtil.GetFormValue <string>("LocalNum", string.Empty);
            string Size        = WebUtil.GetFormValue <string>("Size", string.Empty);
            string Color       = WebUtil.GetFormValue <string>("Color", string.Empty);
            string Count       = WebUtil.GetFormValue <string>("Count", string.Empty);
            double LocalQty    = WebUtil.GetFormValue <double>("LocalQty", 0);
            double Num         = WebUtil.GetFormValue <double>("Num", 0);
            double InPrice     = WebUtil.GetFormValue <double>("Price", 0);
            double Cl          = WebUtil.GetFormValue <double>("Cl", 0);
            double Ca          = WebUtil.GetFormValue <double>("Ca", 0);
            double Cb          = WebUtil.GetFormValue <double>("Cb", 0);

            InStorDetailEntity entity = new InStorDetailEntity();

            entity.SnNum       = SequenceProvider.GetSequence(typeof(InStorDetailEntity));
            entity.OrderNum    = string.Empty;
            entity.ProductName = ProductName;
            entity.BarCode     = BarCode;
            entity.ProductNum  = ProductNum;
            entity.Color       = Color;
            entity.Count       = Count;
            entity.Size        = Size;
            entity.Num         = Num;
            entity.IsPick      = (int)EBool.No;
            entity.RealNum     = 0;
            entity.InPrice     = InPrice;
            entity.CreateTime  = DateTime.Now;
            entity.LocalNum    = LocalNum;
            entity.Cl          = Cl;
            entity.Ca          = Ca;
            entity.Cb          = Cb;
            entity.RGB         = ColorHelper.GetRgb16Color(LabRgb.LabToRgb(new double[] { Cl, Ca, Cb }));
            LocationEntity localtion = new LocationProvider().GetSingleByNumCache(LocalNum);

            if (localtion != null)
            {
                entity.LocalName = new LocationProvider().GetSingleByNumCache(LocalNum).LocalName;
            }
            else
            {
                entity.LocalName = "";
            }
            entity.Amount     = entity.InPrice * entity.Num;
            entity.StorageNum = this.DefaultPStore;

            entity.BatchNum   = BatchNum;
            entity.TotalPrice = entity.Num * entity.InPrice;
            List <InStorDetailEntity> list = Session[CacheKey.TEMPDATA_CACHE_INSTORDETAIL] as List <InStorDetailEntity>;

            list = list.IsNull() ? new List <InStorDetailEntity>() : list;
            list.Add(entity);
            Session[CacheKey.TEMPDATA_CACHE_INSTORDETAIL] = list;

            return(Content(string.Empty));
        }
Example #2
0
        public static void BuildColorLab()
        {
            StorageDataContext sdc = new StorageDataContext();
            var l = sdc.Color.ToList();

            l.ForEach(p =>
            {
                Console.WriteLine("开始转化,颜色:" + p.Name + "  RGB:" + p.RGB);
                int r   = System.Convert.ToInt32(p.RGB.Substring(1, 2), 16);
                int b   = System.Convert.ToInt32(p.RGB.Substring(3, 2), 16);
                int g   = System.Convert.ToInt32(p.RGB.Substring(5, 2), 16);
                var lab = LabRgb.RgbToLab(new int[] { r, b, g });
                p.Lab_L = lab[0];
                p.Lab_a = lab[1];
                p.Lab_b = lab[2];
            });
            sdc.SaveChanges();
            Console.WriteLine("全部转换完成。");

            Console.ReadKey();
        }