예제 #1
0
        private string GetBarCode(string name, string day, int Len)
        {
            try
            {
                var          db    = Database.Open();
                BarCodeModel model = db.UA_BarCodes.Find(db.UA_BarCodes.Name == name && db.UA_BarCodes.day == day);

                if (model == null)
                {
                    model      = new BarCodeModel();
                    model.Id   = Guid.NewGuid();
                    model.Name = name;
                    model.day  = day;
                    model.max  = 1;
                    db.UA_BarCodes.Insert(model);
                }
                else
                {
                    model.max += 1;
                    db.UA_BarCodes.Update(model);
                }
                return(model.Name + model.day + model.max.ToString().PadLeft(Len, '0'));
            }
            catch
            {
                return(null);
            }
        }
예제 #2
0
        public void AddProductToTempFile(string barcode)
        {
            try
            {
                BarCodeModel codeModel          = _iBarCodeManager.GetAll().ToList().Find(n => n.Barcode.Equals(barcode));
                bool         isExitsInInventory = _iScrapManager.IsThisBarcodeExitsInScrapInventory(barcode);
                if (codeModel != null && !isExitsInInventory)
                {
                    int productId = Convert.ToInt32(barcode.Substring(2, 3));
                    var aProduct  = _iProductManager.GetProductByProductId(productId);

                    var category    = _iCommonManager.GetAllProductCategory().ToList().Find(n => n.ProductCategoryId == aProduct.CategoryId);
                    var filePath    = GetTempScrapXmlFilePath();
                    var xmlDocument = XDocument.Load(filePath);
                    xmlDocument.Root?.Elements().Where(n => n.Attribute("Id")?.Value == barcode).Remove();
                    xmlDocument.Save(filePath);

                    xmlDocument.Element("Products")?.Add(
                        new XElement("Product", new XAttribute("Id", barcode),
                                     new XElement("ProductId", aProduct.ProductId),
                                     new XElement("ProductName", aProduct.ProductName),
                                     new XElement("Category", category.ProductCategoryName),
                                     new XElement("SubSubSubAccountCode", aProduct.SubSubSubAccountCode),
                                     new XElement("BarCode", barcode)

                                     ));
                    xmlDocument.Save(filePath);
                }
            }
            catch (Exception exception)
            {
                Log.WriteErrorLog(exception);
            }
        }
 public BarCodeModel GetBarcodeByBatchCode(string batchCode)
 {
     try
     {
         CommandObj.CommandText = "UDSP_GetBarcodeByBatchCode";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.Clear();
         CommandObj.Parameters.AddWithValue("@BatchCode", batchCode);
         ConnectionObj.Open();
         BarCodeModel  aModel = new BarCodeModel();
         SqlDataReader reader = CommandObj.ExecuteReader();
         if (reader.Read())
         {
             aModel.Barcode = reader["Barcode"].ToString();
         }
         reader.Close();
         return(aModel);
     }
     catch (Exception exception)
     {
         Log.WriteErrorLog(exception);
         throw new Exception("Could not get barcode by batchcode", exception.InnerException);
     }
     finally
     {
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
         ConnectionObj.Close();
     }
 }
예제 #4
0
 public int Add(BarCodeModel model)
 {
     try
     {
         CommandObj.CommandText = "UDSP_AddBarCode";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@PrintByUserId", model.PrintByUserId);
         CommandObj.Parameters.AddWithValue("@BarCode", model.Barcode);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         throw new Exception("Could not add barcode", exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
     }
 }
예제 #5
0
        public Microsoft.AspNetCore.Mvc.ActionResult MyImage()
        {
            var BC = new BarCodeModel();

            return(new ImageResult
            {
                Image = BC.BarcodeImage,
                ImageFormat = ImageFormat.Png
            });
        }
예제 #6
0
        //public ActionResult Delete(int id)
        //{
        //    rpproduct.Delete(id);
        //    return RedirectToAction("Index");
        //}

        public ActionResult BarCode(int id)
        {
            var    product   = rpproduct.Find(id);
            string trademark = rptrademark.Find(product.TradeMarkID).Name;
            string promodel  = rpproductmodel.Find(product.ProductModelID).Name;

            barcodecs objbar = new barcodecs();

            byte[]       url   = objbar.getBarcodeImage(product.SerialNumber, trademark + " " + promodel);
            BarCodeModel model = new BarCodeModel();

            model.ImageUrl = "data:image/jpg;base64," + Convert.ToBase64String((byte[])url);

            return(View(model));
        }
예제 #7
0
        public ActionResult Generate(ViewCreateBarCodeModel model)
        {
            var monthYear = DateTime.Now.Month.ToString("D2") +
                            Convert.ToInt32(DateTime.Now.Year.ToString().Substring(2, 2)).ToString("D2");
            var productionDateCodes = _iCommonManager.GetProductionDateCodeByMonthYear(monthYear).ToList();
            var productionLines     = _iCommonManager.GetAllProductionLines().ToList();

            string barCodePrefix = model.ProductId.ToString("D3") +
                                   productionDateCodes.Find(n => n.ProductionDateCodeId.Equals(3))
                                   .Code + DateTime.Now.Day + productionLines.Find(n => n.ProductionLineId == model.ProductionLineId).LineNumber;
            var maxSl = _iBarCodeManager.GetMaxBarCodeSlByPrefix(barCodePrefix);
            var user  = (ViewUser)Session["user"];

            model.GenerateByUserId = user.UserId;
            for (int i = 1; i <= model.Total; i++)
            {
                var          barcode       = barCodePrefix + (maxSl + i).ToString("D4");
                BarCodeModel aBarCodeModel = new BarCodeModel
                {
                    Barcode       = barcode,
                    PrintByUserId = user.UserId
                };
                model.BarCodes.Add(aBarCodeModel);

                GenerateBarCodeFromaGivenString(barcode);
            }

            bool result = _iBarCodeManager.SaveBarCodes(model);

            if (result)
            {
                ModelState.Clear();
            }

            ViewBag.ProductionDateCodeId = new SelectList(productionDateCodes, "ProductionDateCodeId", "Code", productionDateCodes.First().ProductionDateCodeId);
            ViewBag.ProductionLineId     = new SelectList(productionLines, "ProductionLineId", "LineNumber");

            return(View());
        }
예제 #8
0
        public int Update(BarCodeModel item)
        {
            if (item.Id == 0)
            {
                int nextID = _list.OrderByDescending(o => o.Id).Select(s => s.Id).FirstOrDefault() + 1;
                item.Id = nextID;
                _list.Add(item);
                return(nextID);
            }
            else
            {
                var myItem = _list.Where(w => w.Id == item.Id).FirstOrDefault();

                if (myItem == null)
                {
                    return(-1);
                }
                myItem.AlignmentPosition = item.AlignmentPosition;
                myItem.AlternateLabel    = item.AlternateLabel;
                myItem.AspectRatio       = item.AspectRatio;
                myItem.BackColor         = item.BackColor;
                myItem.BarHeight         = item.BarHeight;
                myItem.BarValue          = item.BarValue;
                myItem.BarWidth          = item.BarWidth;
                myItem.EncodedText       = item.EncodedText;
                myItem.EncodedType       = item.EncodedType;
                myItem.EncodedTypeText   = item.EncodedTypeText;
                myItem.EncodingTime      = item.EncodingTime;
                myItem.ForeColor         = item.ForeColor;
                myItem.Height            = item.Height;
                myItem.IncludeLabel      = item.IncludeLabel;
                myItem.LabelPosition     = item.LabelPosition;
                myItem.RotateFlip        = item.RotateFlip;
                myItem.Width             = item.Width;
                return(myItem.Id);
            }
        }
예제 #9
0
        public ActionResult Generate(ViewCreateBarCodeModel model)
        {
            try
            {
                var monthYear = DateTime.Now.Month.ToString("D2") +
                                Convert.ToInt32(DateTime.Now.Year.ToString().Substring(2, 2)).ToString("D2");
                var productionDateCodes = _iCommonManager.GetAllProductionDateCode().ToList();
                var courrentCode        = _iCommonManager.GetProductionDateCodeByMonthYear(monthYear).ToList().First();
                var productionLines     = _iCommonManager.GetAllProductionLines().ToList();
                var lineNo          = productionLines.Find(n => n.ProductionLineId == model.ProductionLineId).LineNumber;
                var selecteDatecode = productionDateCodes.Find(n => n.ProductionDateCodeId == model.ProductionDateCodeId)
                                      .Code;
                var date = Convert.ToDateTime(model.ProductionDate).Day.ToString("D2");

                string barCodePrefix = lineNo + model.ShiftNo + model.ProductId.ToString("D3") + date + selecteDatecode;
                //string barCodePrefix = productionLines.Find(n => n.ProductionLineId == model.ProductionLineId).LineNumber + model.ProductId.ToString("D3") + "09" + productionDateCodes.First().Code;
                string infix = date + selecteDatecode;

                var maxSl = _iBarCodeManager.GetMaxBarCodeSlByInfixAndByLineNo(infix, lineNo);
                //var maxSl = 413;
                if (maxSl == 0 && lineNo.Equals("1"))
                {
                    maxSl = 1000;
                }
                else if (maxSl == 0 && lineNo.Equals("2"))
                {
                    maxSl = 2000;
                }
                else if (maxSl == 0 && lineNo.Equals("3"))
                {
                    maxSl = 3000;
                }
                else if (maxSl == 0 && lineNo.Equals("4"))
                {
                    maxSl = 4000;
                }
                else if (maxSl == 0 && lineNo.Equals("5"))
                {
                    maxSl = 5000;
                }

                var user = (ViewUser)Session["user"];
                model.GenerateByUserId = user.UserId;
                for (int i = 1; i <= model.Total; i++)
                {
                    var          barcode       = barCodePrefix + (maxSl + i).ToString("D4");
                    BarCodeModel aBarCodeModel = new BarCodeModel
                    {
                        Barcode       = barcode,
                        PrintByUserId = user.UserId
                    };
                    model.BarCodes.Add(aBarCodeModel);

                    GenerateBarCodeFromaGivenString(barcode);
                }


                //for (int i = 3001; i <= 3158; i++)
                //{
                //    var barcode = "3B07428FN" + i.ToString("D4");
                //    BarCodeModel aBarCodeModel = new BarCodeModel
                //    {
                //        Barcode = barcode,
                //        PrintByUserId = user.UserId
                //    };
                //    model.BarCodes.Add(aBarCodeModel);

                //    GenerateBarCodeFromaGivenString(barcode);
                //}

                bool result = _iBarCodeManager.SaveBarCodes(model);
                if (result)
                {
                    ModelState.Clear();
                }

                ViewBag.ProductionDateCodeId = new SelectList(productionDateCodes, "ProductionDateCodeId", "Code", courrentCode.ProductionDateCodeId);
                ViewBag.ProductionLineId     = new SelectList(productionLines, "ProductionLineId", "LineNumber");

                return(View());
            }
            catch (Exception exception)
            {
                Log.WriteErrorLog(exception);
                return(PartialView("_ErrorPartial", exception));
            }
        }
예제 #10
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(BarCodeModel model)
 {
     return(dal.Update(model));
 }
예제 #11
0
 public bool Delete(BarCodeModel model)
 {
     throw new NotImplementedException();
 }
예제 #12
0
 public int GenerateBarCode(BarCodeModel model)
 {
     throw new NotImplementedException();
 }
예제 #13
0
        public ActionResult Index(int?PageIndex, long?customerID)
        {
            BarCodeModel vm = new BarCodeModel();

            vm.SearchCondition = new BarCodeSearchCondition();
            #region 订单类型
            IEnumerable <WMSConfig> wms = null;
            try
            {
                wms = ApplicationConfigHelper.GetWMS_Config("BarCodeType_" + base.UserInfo.ProjectName);
            }
            catch (Exception)
            {
            }

            if (wms == null)
            {
                wms = ApplicationConfigHelper.GetWMS_Config("BarCodeType");
            }
            List <SelectListItem> st = new List <SelectListItem>();
            foreach (WMSConfig w in wms)
            {
                st.Add(new SelectListItem()
                {
                    Value = w.Name, Text = w.Name
                });
            }
            vm.BarCodeType = st;
            #endregion
            #region 客户
            var CustomerListAll = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID).Where(t => t.StoreType == 2 || t.StoreType == 3);
            var CustomerListID  = CustomerListAll.Select(t => t.CustomerID);
            var CustomerList    = CustomerListAll.Select(c => new SelectListItem()
            {
                Value = c.CustomerID.ToString(), Text = c.CustomerName
            });
            ViewBag.CustomerList = CustomerList;
            if (base.UserInfo.UserType == 0)
            {
                vm.SearchCondition.CustomerID = base.UserInfo.CustomerOrShipperID;
            }
            else if (base.UserInfo.UserType == 2)
            {
                if (customerID.HasValue)
                {
                    vm.SearchCondition.CustomerID = customerID;
                }
                else
                {
                    var customerIDs = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID).Select(c => c.CustomerID);
                    if (customerIDs != null && customerIDs.Count() == 1)
                    {
                        vm.SearchCondition.CustomerID = customerIDs.First();
                    }
                }
            }
            #endregion
            #region 仓库
            IEnumerable <SelectListItem> WarehouseList = null;
            var WarehouseListAll = ApplicationConfigHelper.GetCacheInfo();
            if (vm.SearchCondition.CustomerID == null)
            {
                WarehouseList = WarehouseListAll.Where(c => c.UserID == base.UserInfo.ID && CustomerListID.Contains(c.CustomerID.Value)).Select(t => new { WarehouseID = t.WarehouseID, WarehouseName = t.WarehouseName }).Distinct()
                                .Select(c => new SelectListItem()
                {
                    Value = c.WarehouseID.ToString(), Text = c.WarehouseName
                });
                StringBuilder sb = new StringBuilder();

                foreach (var i in CustomerListID)
                {
                    sb.Append("" + i + ",");
                }
                if (sb.Length > 1)
                {
                    vm.SearchCondition.CustomerIDs = sb.Remove(sb.Length - 1, 1).ToString();
                }
                else
                {
                    vm.SearchCondition.CustomerIDs = "0";
                }
            }
            else
            {
                WarehouseList = WarehouseListAll.Where(c => (c.CustomerID == vm.SearchCondition.CustomerID && c.UserID == base.UserInfo.ID)).Select(t => new { WarehouseID = t.WarehouseID, WarehouseName = t.WarehouseName }).Distinct()
                                .Select(c => new SelectListItem()
                {
                    Value = c.WarehouseID.ToString(), Text = c.WarehouseName
                });
            }

            ViewBag.WarehouseList = WarehouseList;
            #endregion
            if (CustomerList.Count() == 1)
            {
                vm.SearchCondition.CustomerID = CustomerList.Select(c => c.Value).FirstOrDefault().ObjectToInt64();
            }
            if (WarehouseList.Count() == 1)
            {
                vm.SearchCondition.WarehouseID = WarehouseList.Select(c => c.Value).FirstOrDefault().ObjectToInt64();
            }


            vm.SearchCondition.StartCreateTime = DateTime.Parse(DateTime.Now.AddDays(-10).ToString("yyyy-MM-dd"));
            vm.SearchCondition.EndCreateTime   = DateTime.Now;
            var response = new BarCodeService().QueryBarCodeList(new GetBarCodeByConditionRequest()
            {
                SearchCondition = null,
                PageIndex       = PageIndex ?? 0,
                PageSize        = UtilConstants.PAGESIZE,
            });
            if (response.IsSuccess)
            {
                vm.BarCodeCollection = response.Result.BarCodeCollection;
                vm.PageIndex         = response.Result.PageIndex;
                vm.PageCount         = response.Result.PageCount;
            }
            return(View(vm));
        }
예제 #14
0
 public BarCodeVM()
 {
     BarCodeList = new List <BarCodeModel>();
     BarCode     = new BarCodeModel();
 }
예제 #15
0
 public Microsoft.AspNetCore.Mvc.ActionResult Edit(BarCodeModel postBarcode, int id = 1)
 {
     BarCodeDb.Update(postBarcode);
     return(View(BarCodeDb.Get(id)));
 }
예제 #16
0
        public bool Add(BarCodeModel model)
        {
            int rowAffected = _iBarCodeGateway.Add(model);

            return(rowAffected > 0);
        }
예제 #17
0
 public int Update(BarCodeModel model)
 {
     throw new NotImplementedException();
 }
예제 #18
0
 public bool GenerateBarCode(BarCodeModel model)
 {
     return(_iBarCodeGateway.GenerateBarCode(model) > 0);
 }
예제 #19
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(BarCodeModel model)
 {
     return(dal.Add(model));
 }