private void ParseBarcode(string pBarCode) { // pBarCode = RPI.BarCode; if (pBarCode.Length > 21) // Assume it is a 2d barcode { BarcodeUtil2 gs1 = new BarcodeUtil2(); Dictionary <String, String> DGS1; DGS1 = gs1.decodeBarcodeGS1Pharma(pBarCode); string gtin = DGS1["01"]; string expirationdt = DGS1["17"]; string lot = ""; DGS1.TryGetValue("10", out lot); string SerialNumber = ""; DGS1.TryGetValue("21", out SerialNumber); RPI.Lot = lot; // RPI.SerialNumber = SerialNumber; RPI.ItemNumber = gtin.Substring(3, 10); //the day could be 00 if (expirationdt.Substring(4, 2) == "00") { expirationdt = expirationdt.Substring(0, 4) + "28"; } RPI.ExpireDate = DateTime.ParseExact(expirationdt, "yyMMdd", CultureInfo.InvariantCulture); RPI.Save(); } }
protected override void OnChanged(string propertyName, object oldValue, object newValue) { if (IsLoading) { return; } // if (classInfo == null) return; if (propertyName == "LastBarcodescan" && newValue.ToString().Length > 15) { BarcodeUtil2 gs1 = new BarcodeUtil2(); Dictionary <String, String> DGS1; DGS1 = gs1.decodeBarcodeGS1Pharma(newValue.ToString()); string gtin = DGS1["01"]; string expirationdt = DGS1["17"]; string lot = ""; DGS1.TryGetValue("10", out lot); string SerialNumber = ""; DGS1.TryGetValue("21", out SerialNumber); ReceiverPackageItems Ritem = new ReceiverPackageItems(Session); Ritem.BarCode = newValue.ToString(); Ritem.Lot = lot; // Ritem.SerialNumber = SerialNumber; Ritem.ItemNumber = gtin.Substring(3, 10); //the day could be 00 if (expirationdt.Substring(4, 2) == "00") { expirationdt = expirationdt.Substring(0, 4) + "28"; } Ritem.ReceiverPackageId = this; Ritem.ExpireDate = DateTime.ParseExact(expirationdt, "yyMMdd", CultureInfo.InvariantCulture); Ritem.Save(); int x = 1; } base.OnChanged(propertyName, oldValue, newValue); }