Exemplo n.º 1
0
        public Stream OpenProdInfo()
        {
            IStorage encStorage = ProdInfo.Open().AsStorage();
            var      decStorage = new CachedStorage(new Aes128XtsStorage(encStorage, Keyset.BisKeys[0], 0x4000, true), 0x4000, 4, true);

            return(decStorage.AsStream(FileAccess.Read));
        }
Exemplo n.º 2
0
        string  PackShowStr(int xuhao, ProdInfo prodinfo)
        {
            string str       = "";
            double liaochang = 0;

            liaochang = prodinfo.Len / 100;

            str = "切割序号:" + (xuhao + 1).ToString() + "  料长:" + liaochang.ToString("0.00");

            int countId = 1;

            foreach (int size in prodinfo.Cut)
            {
                double sizedouble = (double)size / 100;

                if (countId > 3)
                {
                    str += "\r\n";
                }

                str +=
                    ("  " + countId.ToString() + "段: " +
                     sizedouble.ToString("0.00") +
                     " L" + prodinfo.leftAngle[countId - 1]
                     + " R" + prodinfo.rightAngle[countId - 1]
                    );
                countId++;
            }
            double wlDouble = ((double)prodinfo.WL / 100);

            str += ("  余料:" + wlDouble.ToString("0.00"));
            return(str);
        }
Exemplo n.º 3
0
        public Stream OpenProdInfo()
        {
            SparseStream encStream = ProdInfo.Open();
            Xts          xts       = XtsAes128.Create(Keyset.BisKeys[0]);
            var          decStream = new RandomAccessSectorStream(new XtsSectorStream(encStream, xts, 0x4000, 0), true);

            return(decStream);
        }
Exemplo n.º 4
0
        // GET: Home
        public ActionResult Index(ProdInfo prod)
        {
            var q = (from s in db.ProdInfoes
                     select s);
            var result = q.ToList();

            return(View(result));
        }
        public JsonResult Save(Int32 id, Int32 Org, String Name, String Value, String ProductType, Int32 attrSet, Int32 taxcat, Int32 prodCat, Int32 UOM, String UPC, int Parent_ID)
        {
            ProdInfo value = null;

            if (Session["ctx"] != null)
            {
                VAdvantage.Utility.Ctx ctx   = Session["ctx"] as Ctx;
                ProductManagementModel model = new ProductManagementModel();
                value = model.save(id, Org, Name, Value, ProductType, attrSet, taxcat, prodCat, UOM, UPC, Parent_ID, ctx);
            }
            return(Json(JsonConvert.SerializeObject(value), JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        public void SetRation(ProdInfo p)
        {
            ration = 0.4098;// len * 100 / (double)p.Len;

            xmargin = (int)(p.DBC * ration / 100);

            double het = 0;

            if (double.TryParse(p.Param16[0], out het)) //材料宽度
            {
                height = (int)(het * ration);
            }
        }
        public async Task <IActionResult> OnGet(int?ID)
        {
            if (ID == null)
            {
                return(NotFound());
            }
            ProdInfo = await _db.ProdInfo.Include(m => m.ApplicationUser).FirstOrDefaultAsync(m => m.Id == ID);

            if (ProdInfo == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemplo n.º 8
0
        // this function will create products while creating incoming goods
        public void CreateProdAtIG(List <ProdInfo> NewProd)
        {
            try
            {
                DateTime InDateTime       = DateTime.Now;
                string   sqlFormattedDate = InDateTime.ToString("yyyy-MM-dd HH:mm:ss");

                // create new products here

                foreach (var Prod in NewProd)
                {
                    if (Prod.ProdName == null)
                    {
                        Prod.ProdName = "غير محدد";
                    }
                    ProdInfo ProdInfo = new ProdInfo
                    {
                        ProdCode        = Prod.ProdCode,
                        ProdName        = Prod.ProdName,
                        CostPrice       = Prod.CostPrice,
                        RetailPrice     = Prod.RetailPrice,
                        WholePrice      = Prod.WholePrice,
                        CreatedDateTime = InDateTime,
                        CreatedById     = GetLoggedInUserId(),
                    };


                    _db.ProdInfo.Add(ProdInfo);

                    /// i will have to create prodct in wh later ****

                    // CreateProdInWh(int ProdId, 0, double OpenQty);
                }

                // Save changes
                _db.SaveChanges();

                // return true;
            }
            catch (Exception ex)
            {
                // return false;
            }
        }
        public ActionResult OnPostCreateProduct()
        {
            bool check = _InveTrans.CheckProdCodeExist(ProdInfo.ProdCode).GetAwaiter().GetResult();

            if (check == false)
            {
                StatusMessage = "Error!رمز المادة مضافة سابقا";
                return(Page());
            }

            var    ClaimId = (ClaimsIdentity)User.Identity;
            var    Claim   = ClaimId.FindFirst(ClaimTypes.NameIdentifier);
            string UserId  = Claim.Value;


            ProdInfo.CreatedDateTime = DateTime.Now;
            var NewProd = new ProdInfo
            {
                CreatedById     = UserId,
                ProdCode        = ProdInfo.ProdCode,
                ProdDescription = ProdInfo.ProdDescription,
                ProdName        = ProdInfo.ProdName,
                ProdCategory    = ProdInfo.ProdCategory,
                CostPrice       = ProdInfo.CostPrice,
                RetailPrice     = ProdInfo.RetailPrice,
                WholePrice      = ProdInfo.WholePrice,
                CreatedDateTime = ProdInfo.CreatedDateTime
            };

            _db.ProdInfo.Add(NewProd);

            _db.SaveChanges();
            var  Prod           = _db.ProdInfo.FirstOrDefault(pr => pr.ProdCode == ProdInfo.ProdCode);
            bool CreateProdInWh = _InveTrans.CreateProdInWh(Prod.Id, 0, 0);

            StatusMessage = "تمت اضافة مادة جديدة";
            // return new JsonResult(StatusMessage);
            //return RedirectToPage("/Inventory/IncomingGoods/Create");
            return(Page());
        }
Exemplo n.º 10
0
        public void ProdDrawPloygon(ProdInfo prodinfo, ref Bitmap bt, int heightId, PictureBox p1, int xuhao)
        {
            int count = prodinfo.Cut.Count;

            SetRation(prodinfo);
            Point xtop = new Point(OrigninP.X, OrigninP.Y);

            if (bt == null)
            {
                bt = new Bitmap(OrigninP.X + len + xmargin * (prodinfo.Cut.Count + 1) + 100 * xmargin + 100, 2 * OrigninP.Y + (count + 50) * (height + ymargin));
                //p1.Height = bt.Height + 100;
            }

            Point[] pwl = new Point[2];
            DrawLen(bt, heightId, (int)(prodinfo.Len * ration / Constant.dataMultiple), ref pwl);


            Point[] pArray = new Point[4];
            Point[] pLine  = new Point[2];
            if (prodinfo.Cut.Count > 0)
            {
                xtop.X   = xtop.X + calcuXMargin(prodinfo.leftAngle[0]);
                xtop.Y   = xtop.Y + heightId * height + ymargin * heightId;
                pLine[0] = xtop;
                pLine[1] = xtop;

                pLine[1].Y += height;

                DrawLine(bt, pLine);

                //开始画图
                for (int i = 0; i < prodinfo.Cut.Count; i++)
                {
                    double upSize   = 0;
                    double downSize = 0;
                    if (!double.TryParse(prodinfo.Param5[i], out upSize))
                    {
                        MessageBox.Show(Constant.convertError + Constant.resultTip5 + heightId.ToString() +
                                        Constant.resultTip6 + Constant.resultTip5 + i.ToString() + Constant.resultTip7);
                        return;
                    }
                    if (!double.TryParse(prodinfo.Param6[i], out downSize))
                    {
                        MessageBox.Show(Constant.convertError + Constant.resultTip5 + heightId.ToString() +
                                        Constant.resultTip6 + Constant.resultTip5 + i.ToString() + Constant.resultTip7);
                        return;
                    }

                    upSize   = upSize * (ration);
                    downSize = downSize * (ration);

                    if (i < (prodinfo.Cut.Count() - 1))
                    {
                        if (i != 0)
                        {
                            pArray =
                                pointArrayGet(ref xtop, prodinfo.leftAngle[i], prodinfo.rightAngle[i], prodinfo.leftAngle[i + 1], prodinfo.rightAngle[i - 1], (int)upSize, (int)downSize);
                        }
                        else
                        {
                            pArray =
                                pointArrayGet(ref xtop, prodinfo.leftAngle[i], prodinfo.rightAngle[i], prodinfo.leftAngle[i + 1], 90, (int)upSize, (int)downSize);
                        }
                    }
                    else
                    {
                        if (i > 0)
                        {
                            pArray =
                                pointArrayGet(ref xtop, prodinfo.leftAngle[i], prodinfo.rightAngle[i], 0, prodinfo.rightAngle[i - 1], (int)upSize, (int)downSize);
                        }
                        else
                        {
                            pArray =
                                pointArrayGet(ref xtop, prodinfo.leftAngle[i], prodinfo.rightAngle[i], 0, 0, (int)upSize, (int)downSize);
                        }
                    }
                    if (i != 0)
                    {
                        if (prodinfo.Barc.Contains("尾料裁剪"))
                        {
                            DrawPolygon(bt, pArray, 7, "");
                        }
                        else
                        {
                            DrawPolygon(bt, pArray, 1, "");
                        }
                    }
                    else
                    {
                        DrawPolygon(bt, pArray, 1, PackShowStr(xuhao, prodinfo));
                    }
                }


                //尾料再换个颜色
                List <Point> pwlLst = new List <Point>();

                if (pArray.Count() == 4 && pwl.Count() == 2)
                {
                    pwlLst.Add(pArray[1]);
                    pwlLst.Add(pwl[0]);
                    pwlLst.Add(pwl[1]);
                    pwlLst.Add(pArray[2]);
                    if (prodinfo.Barc.Contains("尾料裁剪"))
                    {
                        DrawPolygon(bt, pwlLst.ToArray(), 8, "");
                    }
                    else
                    {
                        DrawPolygon(bt, pwlLst.ToArray(), 3, "");
                    }
                }

                if (bt != null)
                {
                    p1.Image = bt;
                }
            }
        }
Exemplo n.º 11
0
        public async Task <IActionResult> OnPost()
        {
            bool check = _InveTrans.CheckProdCodeExist(ProductInfo.ProdCode).GetAwaiter().GetResult();

            if (check == false)
            {
                StatusMessage = "Error!رمز المادة مضافة سابقا";
                return(Page());
            }

            var    ClaimId = (ClaimsIdentity)User.Identity;
            var    Claim   = ClaimId.FindFirst(ClaimTypes.NameIdentifier);
            string UserId  = Claim.Value;

            if (!ModelState.IsValid)
            {
                // return Page();
            }
            string newfileName = string.Empty;

            if (img != null && img.Length > 0)
            {
                string fn = img.FileName;
                if (IsImagValidate(fn))
                {
                    string extension = Path.GetExtension(fn);
                    newfileName = Guid.NewGuid().ToString() + extension;
                    string filename = Path.Combine(_host.WebRootPath + "/img/", newfileName);
                    await img.CopyToAsync(new FileStream(filename, FileMode.Create));
                }
                else
                {
                    return(Page());
                }
            }

            ProductInfo.CreatedDateTime = DateTime.Now;
            var Information = new ProdInfo
            {
                CreatedById     = UserId,
                ProdCode        = ProductInfo.ProdCode,
                ProdDescription = ProductInfo.ProdDescription,
                ProdName        = ProductInfo.ProdName,
                ProdCategory    = ProductInfo.ProdCategory,
                CostPrice       = ProductInfo.CostPrice,
                RetailPrice     = ProductInfo.RetailPrice,
                WholePrice      = ProductInfo.WholePrice,
                CreatedDateTime = ProductInfo.CreatedDateTime,

                ImgFile = newfileName
            };

            AddPhoto = await _db.TempProdImg.ToListAsync();

            foreach (var item in AddPhoto)
            {
                var AddPhoto = new ProdImg
                {
                    ImgFile = item.ImgFile,
                    ProdId  = Information.Id
                };
                _db.ProdImg.Add(AddPhoto);
            }
            _db.TempProdImg.RemoveRange(AddPhoto);
            _db.ProdInfo.Add(Information);

            await _db.SaveChangesAsync();

            var  Prod           = _db.ProdInfo.FirstOrDefault(pr => pr.ProdCode == ProductInfo.ProdCode);
            bool CreateProdInWh = _InveTrans.CreateProdInWh(Prod.Id, SelectedWarehouse, OpenQty);

            StatusMessage = "تمت اضافة مادة جديدة";
            return(RedirectToPage("Create"));
        }
Exemplo n.º 12
0
        public async Task <IActionResult> OnPostProduct(ProdInfo prodInfo)
        {
            DateTime InDateTime       = DateTime.Now;
            string   sqlFormattedDate = InDateTime.ToString("yyyy-MM-dd HH:mm:ss");
            bool     check            = _InveTrans.CheckProdCodeExist(prodInfo.ProdCode).GetAwaiter().GetResult();

            if (check == false)
            {
                return(new JsonResult(new
                {
                    success = false,
                    error = "Error!رمز المادة مضافة سابقا"
                }));
            }

            var    ClaimId = (ClaimsIdentity)User.Identity;
            var    Claim   = ClaimId.FindFirst(ClaimTypes.NameIdentifier);
            string UserId  = Claim.Value;

            prodInfo.CreatedById = UserId;

            var  context           = new ValidationContext(prodInfo, serviceProvider: null, items: null);
            var  validationResults = new List <ValidationResult>();
            bool isValid           = Validator.TryValidateObject(prodInfo, context, validationResults, true);

            if (!isValid)
            {
                return(new JsonResult(new
                {
                    success = false,
                    error = validationResults.First().ErrorMessage
                }));
            }

            string newfileName = string.Empty;

            if (img != null && img.Length > 0)
            {
                string fn = img.FileName;
                if (IsImagValidate(fn))
                {
                    string extension = Path.GetExtension(fn);
                    newfileName = Guid.NewGuid().ToString() + extension;
                    string filename = Path.Combine(_host.WebRootPath + "/img/", newfileName);
                    await img.CopyToAsync(new FileStream(filename, FileMode.Create));
                }
                else
                {
                    return(new JsonResult(new
                    {
                        success = false,
                        error = "Invalid Image"
                    }));
                }
            }

            //  prodInfo.CreatedDateTime = DateTime.Now;
            var Information = new ProdInfo
            {
                CreatedById     = UserId,
                ProdCode        = prodInfo.ProdCode,
                ProdDescription = prodInfo.ProdDescription,
                ProdName        = prodInfo.ProdName,
                ProdCategory    = prodInfo.ProdCategory,
                CostPrice       = prodInfo.CostPrice,
                RetailPrice     = prodInfo.RetailPrice,
                WholePrice      = prodInfo.WholePrice,
                CreatedDateTime = InDateTime,

                ImgFile = newfileName
            };

            AddPhoto = await _db.TempProdImg.ToListAsync();

            foreach (var item in AddPhoto)
            {
                var AddPhoto = new ProdImg
                {
                    ImgFile = item.ImgFile,
                    ProdId  = Information.Id
                };
                _db.ProdImg.Add(AddPhoto);
            }
            _db.TempProdImg.RemoveRange(AddPhoto);
            _db.ProdInfo.Add(Information);

            await _db.SaveChangesAsync();

            var  Prod           = _db.ProdInfo.FirstOrDefault(pr => pr.ProdCode == prodInfo.ProdCode);
            bool CreateProdInWh = _InveTrans.CreateProdInWh(Prod.Id, SelectedWarehouse, OpenQty);

            StatusMessage = "تمت اضافة مادة جديدة";
            return(new JsonResult(new
            {
                success = true
            }));
        }