private void ScanCode(string dcdData) { if (dcdData.StartsWith("[")) { #region Scan Package/Unit ID new try { LabelPackage labelPackage = new LabelPackage(dcdData.Trim()); DataRow[] rs_package = null; bool _exists_package = false; if (labelPackage.PackageId != null && labelPackage.PackageId != "") { rs_package = dtList.Select(COL_ID + " = '" + labelPackage.PackageId + "'"); if (rs_package.Length > 0) { _exists_package = true; } //DialogResult mgb = new DialogResult(); if (_exists_package) { //mgb = MessageBox.Show("Package not exists in list !", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); //if (mgb == DialogResult.Yes) //{ // dr = dtList.Select("internalReference = '" + labelPackage.ProductName + "' AND " + COL_ID + " = '" + labelPackage.PackageId + "'").FirstOrDefault(); // if(dr == null) // addPackageNotInList(labelPackage.ProductName, labelPackage.PackageId); //} MessageBox.Show("Package already exists in the list !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } else { addPackageToList(labelPackage.ProductName, labelPackage.PackageId); if (BarcodeLocation != null && BarcodeLocation.Trim().Length > 0 && !btnSave.Enabled) { //enable button save btnSave.Enabled = true; btnClear.Enabled = true; } } } else { MessageBox.Show("Error scan!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } catch (Exception ex) { MessageBox.Show("Wrong Package/Unit ID QRCode format !"); //MessageBox.Show(ex.InnerException.ToString()); //MessageBox.Show("Error during loading information !", "Chu y", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } #endregion } else if (dcdData.Trim().StartsWith("PN:")) { #region Scan Package/Unit ID old try { TemCuon temCuon = new TemCuon(dcdData.Trim()); DataRow[] rs_package = null; bool _exists_package = false; if (temCuon.IdCuon != null && temCuon.IdCuon != "") { rs_package = dtList.Select(COL_ID + " = '" + temCuon.IdCuon + "'"); if (rs_package.Length > 0) { _exists_package = true; } //DialogResult mgb = new DialogResult(); if (_exists_package) { //mgb = MessageBox.Show("Package not exists in list !", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); //if (mgb == DialogResult.Yes) //{ // dr = dtList.Select("internalReference = '" + labelPackage.ProductName + "' AND " + COL_ID + " = '" + labelPackage.PackageId + "'").FirstOrDefault(); // if(dr == null) // addPackageNotInList(labelPackage.ProductName, labelPackage.PackageId); //} MessageBox.Show("Package already exists in the list !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } else { addPackageToList(temCuon.VnptPn, temCuon.IdCuon, Convert.ToInt32(temCuon.Type)); if (BarcodeLocation != null && BarcodeLocation.Trim().Length > 0 && !btnSave.Enabled) { //enable button save btnSave.Enabled = true; btnClear.Enabled = true; } } } else { MessageBox.Show("Error scan!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } catch (Exception ex) { MessageBox.Show("Wrong Package/Unit ID QRCode format !"); } #endregion } else if (Util.OnlyHexInString(dcdData.Trim())) { #region Scan Serial number try { string SerialNumber = dcdData.Trim(); DataRow[] rs_package = null; bool _exists_package = false; if (SerialNumber != null && SerialNumber != "") { rs_package = dtList.Select(COL_ID + " = '" + SerialNumber + "'"); if (rs_package.Length > 0) { _exists_package = true; } //DialogResult mgb = new DialogResult(); if (_exists_package) { //mgb = MessageBox.Show("Package not exists in list !", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); //if (mgb == DialogResult.Yes) //{ // dr = dtList.Select("internalReference = '" + labelPackage.ProductName + "' AND " + COL_ID + " = '" + labelPackage.PackageId + "'").FirstOrDefault(); // if(dr == null) // addPackageNotInList(labelPackage.ProductName, labelPackage.PackageId); //} MessageBox.Show("Package/Serial number already exists in the list !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } else { addPackageToList(null, SerialNumber); if (BarcodeLocation != null && BarcodeLocation.Trim().Length > 0 && !btnSave.Enabled) { //enable button save btnSave.Enabled = true; btnClear.Enabled = true; } } } else { MessageBox.Show("Error scan!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } catch (Exception ex) { MessageBox.Show("Wrong Package/Unit ID QRCode format !"); //MessageBox.Show(ex.InnerException.ToString()); //MessageBox.Show("Error during loading information !", "Chu y", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } #endregion } else { #region Scan location ApiResponse res = new ApiResponse(); res.Status = false; try { string url = "locations/search?query=barcode==\"" + dcdData.Trim() + "\""; res = HTTP.GetJson(url); } catch (Exception ex) { MessageBox.Show("Error during load location information !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } if (res.Status && Util.IsJson(res.RawText)) { try { List <LocationInfo> RootObject = JsonConvert.DeserializeObject <List <LocationInfo> >(res.RawText, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); List <LocationInfo> ListLocations = RootObject as List <LocationInfo>; this.lblLocationBarcode.Text = ListLocations[0].name; BarcodeLocation = dcdData; if (this.dtList.Rows.Count > 0 && !btnSave.Enabled) { //enable button save btnSave.Enabled = true; btnClear.Enabled = true; } } catch (Exception ex) { MessageBox.Show("Error during load location information !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } #endregion } }
private void btnAllocate_Click(object sender, EventArgs e) { if (!loadInfoTransfer()) { return; } if (this._state == "done") { MessageBox.Show("The selected transaction has completed, action not implemented !"); return; } bool status_reserve = true; List <string> List_allocate_lot = new List <string>(); if (txtNumberPerLot.Text.Trim().Length > 0 && txtNumberLot.Text.Trim().Length > 0 && Common.ConvertInt(txtNumberLot.Text.Trim()) > 0) { //allocate lot string url_lot = "sequences/" + Config.LotReserveId + "/reserve/" + txtNumberLot.Text.Trim(); HttpResponse res_lot = HTTP.Instance.Post(url_lot, null); if (res_lot.StatusCode == System.Net.HttpStatusCode.OK) { try { var serializer_lot = new JavaScriptSerializer(); dynamic data_lot = serializer_lot.Deserialize(res_lot.RawText, typeof(object)); List_allocate_lot = Common.CreateSequential(Convert.ToInt32(data_lot["nextNumber"]), Common.ConvertInt(data_lot["step"]), Convert.ToInt32(data_lot["length"]), Convert.ToInt32(txtNumberLot.Text.Trim()), data_lot["prefix"]); } catch (Exception ex) { status_reserve = false; }; } else { status_reserve = false; } } if (status_reserve) { long maxID = 0; using (erpEntities dbContext = new erpEntities()) { wh_transfer_details wtd = dbContext.wh_transfer_details.OrderByDescending(u => u.id).FirstOrDefault(); if (wtd != null) { maxID = wtd.id + 1; } } this._dt_lots = checkStructureDatatable(_dt_lots); TransferDetailsRepository TransferDetails = new TransferDetailsRepository(); List <wh_transfer_details> list_transfer_details = new List <wh_transfer_details>(); if (List_allocate_lot.Count > 0) { foreach (string lot in List_allocate_lot) { wh_transfer_details wtd = new wh_transfer_details(); wtd.created = DateTime.Now; wtd.src_package_number = txtSourceNumber.Text.Trim(); wtd.dest_location_id = Common.ConvertInt(gluDestinationLocation.EditValue); wtd.dest_package_number = PackageID; wtd.done_quantity = Common.ConvertDouble(txtNumberPerLot.Text); wtd.id = maxID; wtd.man_id = this.ManId; try { wtd.man_pn = this.ManPn; } catch (Exception ex) { wtd.man_pn = null; } wtd.product_id = this.ProductId; wtd.product_name = ProductName; wtd.src_location_id = Common.ConvertInt(gluSourceLocation.EditValue); wtd.status = 0; wtd.transfer_id = this.TransferId; wtd.transfer_item_id = this.TransferItemId; wtd.trace_number = lot; wtd.internal_reference = InternalReference; wtd.reference = Reference; list_transfer_details.Add(wtd); //add to table list package addPackageDataRow(InternalReference, Reference, wtd.src_package_number, wtd.dest_package_number, wtd.trace_number, Common.ConvertInt(wtd.src_location_id), Common.ConvertInt(wtd.dest_location_id), Common.ConvertDouble(wtd.done_quantity), Common.ConvertInt(wtd.transfer_id), Common.ConvertInt(wtd.transfer_item_id), Common.ConvertInt(wtd.product_id), Common.ConvertInt(wtd.man_id)); //Print Lot LabelPackage labelLot = new LabelPackage(wtd.internal_reference, lot, "", this.transfer_info["transferNumber"], this._supplier, this._project); labelLot.Template(); maxID++; } } vgListLot.DataSource = _dt_lots; TransferDetails.Add(list_transfer_details.ToArray()); //delete package parent CheckAllocate = true; this.quantityChange += (Common.ConvertDouble(txtNumberPerLot.Text) * Convert.ToInt32(txtNumberLot.Text.Trim())); } }
private void ScanCode(string dcdData) { if (dcdData.StartsWith("[")) { #region Scan Package/Unit ID new if (this._LocationInfo == null) { MessageBox.Show("Request scan location before scan the package!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } try { string scanValue = dcdData.Replace(System.Environment.NewLine, "").Trim(); LabelPackage labelPackage = new LabelPackage(scanValue); //Util.Logs(labelPackage.PackageId); if (labelPackage.PackageId != null && labelPackage.PackageId != "") { //Check package exists in inventory ApiResponse res = new ApiResponse(); res.Status = false; string url = ""; int _id = 0; bool isPackage = true; if (Util.getTypePackage(labelPackage.PackageId, null) % 2 == 0) { isPackage = false; Lots lot = new Lots(); Lots lotInfo = lot.getInfo(labelPackage.PackageId); if (lotInfo == null) { MessageBox.Show("Unit ID is not exists in inventory !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } else { url = "adjustment-details/search?query=adjustmentId==" + _Adjustment.id.ToString() + ";lotId==" + lotInfo.id.ToString(); _id = lotInfo.id; } } else if (Util.getTypePackage(labelPackage.PackageId, null) % 2 != 0) { isPackage = true; Packages package = new Packages(); Packages packageInfo = package.getInfo(labelPackage.PackageId); if (packageInfo == null) { MessageBox.Show("Package is not exists in inventory !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } else { url = "adjustment-details/search?query=adjustmentId==" + _Adjustment.id.ToString() + ";packageId==" + packageInfo.id.ToString(); _id = packageInfo.id; } } if (url.Length == 0) { MessageBox.Show("Wrong Package/Unit ID QRCode format !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } try { res = HTTP.GetJson(url); } catch (Exception ex) { MessageBox.Show("Server error !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } List <AdjustmentDetail> ListDetail; if (res.Status && Util.IsJson(res.RawText)) { List <AdjustmentDetail> RootObject = JsonConvert.DeserializeObject <List <AdjustmentDetail> >(res.RawText, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); ListDetail = RootObject as List <AdjustmentDetail>; if (checkExistsInTable(labelPackage.PackageId)) { return; } else { if (ListDetail.Count == 0) { DialogResult mgb = new DialogResult(); mgb = MessageBox.Show("Package/Unit ID is not exists in inventory adjustment! Do you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (mgb != DialogResult.Yes) { return; } addPackageFromStock(_id, labelPackage.PackageId, isPackage, labelPackage.ProductName, _LocationInfo.barcode, null, 0); //addPackageToList(labelPackage.PackageId, 0, labelPackage.ProductName, _LocationInfo.barcode); //enable button save if (_LocationInfo != null && !btnSave.Enabled) { btnSave.Enabled = true; } } else { if (labelPackage.PackageId.StartsWith(PREFIX_LOT) || ListDetail.Count == 1) { addPackageToList(ListDetail[0]); } else if (labelPackage.PackageId.StartsWith(PREFIX_PACK)) { foreach (AdjustmentDetail item in ListDetail) { addPackageToList(item); } } //enable button save if (_LocationInfo != null && !btnSave.Enabled) { btnSave.Enabled = true; } } } } else { MessageBox.Show("Server error !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } } else { MessageBox.Show("Wrong Package/Unit ID QRCode format !"); } } catch (Exception ex) { MessageBox.Show("Error scan!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } #endregion } else if (dcdData.Trim().StartsWith("PN:")) { #region Scan Package/Unit ID old if (_LocationInfo == null) { MessageBox.Show("Request scan location before scan the package!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } try { string scanValue = dcdData.Replace(System.Environment.NewLine, "").Trim(); TemCuon temCuon = new TemCuon(scanValue); if (temCuon.IdCuon != null && temCuon.IdCuon != "") { //Check package exists in inventory ApiResponse res = new ApiResponse(); res.Status = false; string url = ""; int _id = 0; bool isPackage = true; if (Convert.ToInt32(temCuon.Type) == 0) { isPackage = false; Lots lot = new Lots(); Lots lotInfo = lot.getInfo(temCuon.IdCuon); if (lotInfo == null) { DialogResult mgb = new DialogResult(); mgb = MessageBox.Show("Uid is not exists in inventory! Do you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (mgb != DialogResult.Yes) { return; } if (checkExistsInTable(temCuon.IdCuon, Convert.ToInt32(temCuon.Type))) { return; } addPackageToList(null, temCuon.IdCuon, Convert.ToDouble(temCuon.SoLuong), temCuon.VnptPn, _LocationInfo.barcode, temCuon.Type); } url = "adjustment-details/search?query=adjustmentId==" + _Adjustment.id.ToString() + ";lotId==" + lotInfo.id.ToString(); _id = lotInfo.id; } else if (Convert.ToInt32(temCuon.Type) == 1) { isPackage = true; Packages package = new Packages(); Packages packageInfo = package.getInfo(temCuon.IdCuon); if (packageInfo == null) { DialogResult mgb = new DialogResult(); mgb = MessageBox.Show("Package is not exists in inventory! Do you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (mgb != DialogResult.Yes) { return; } if (checkExistsInTable(temCuon.IdCuon, Convert.ToInt32(temCuon.Type))) { return; } addPackageToList(temCuon.IdCuon, null, Convert.ToDouble(temCuon.SoLuong), temCuon.VnptPn, _LocationInfo.barcode, temCuon.Type); } url = "adjustment-details/search?query=adjustmentId==" + _Adjustment.id.ToString() + ";packageId==" + packageInfo.id.ToString(); _id = packageInfo.id; } if (url.Length == 0) { MessageBox.Show("Wrong Package/Unit ID QRCode format !"); return; } try { res = HTTP.GetJson(url); } catch (Exception ex) { MessageBox.Show("Server error !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } List <AdjustmentDetail> ListDetail; if (res.Status && Util.IsJson(res.RawText)) { List <AdjustmentDetail> RootObject = JsonConvert.DeserializeObject <List <AdjustmentDetail> >(res.RawText, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); ListDetail = RootObject as List <AdjustmentDetail>; if (checkExistsInTable(temCuon.IdCuon, Convert.ToInt32(temCuon.Type))) { return; } else { if (ListDetail.Count == 0) { DialogResult mgb = new DialogResult(); mgb = MessageBox.Show("Package/Unit ID is not exists in inventory adjustment! Do you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (mgb != DialogResult.Yes) { return; } addPackageFromStock(_id, temCuon.IdCuon, isPackage, temCuon.VnptPn, _LocationInfo.barcode, temCuon.Type, Convert.ToDouble(temCuon.SoLuong)); //addPackageToList(temCuon.IdCuon, 0, temCuon.VnptPn, _LocationInfo.barcode, Convert.ToInt32(temCuon.Type)); //enable button save if (_LocationInfo != null && !btnSave.Enabled) { btnSave.Enabled = true; } } else { if (Convert.ToInt32(temCuon.Type) == 0 || ListDetail.Count == 1) { addPackageToList(ListDetail[0]); } else if (Convert.ToInt32(temCuon.Type) == 1) { foreach (AdjustmentDetail item in ListDetail) { addPackageToList(item); } } //enable button save if (_LocationInfo != null && !btnSave.Enabled) { btnSave.Enabled = true; } } } } else { MessageBox.Show("Server error !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } } else { MessageBox.Show("Wrong Package/Unit ID QRCode format !"); } } catch (Exception ex) { MessageBox.Show("Error scan!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } #endregion } else if (Util.OnlyHexInString(dcdData.Trim())) { #region scan serial number string SerialNumber = dcdData.Trim(); checkScan(null, SerialNumber, null); #endregion } else { #region Scan location locationBarcode = dcdData.Replace(System.Environment.NewLine, "").Trim(); try { ApiResponse res = new ApiResponse(); res.Status = false; string url = "locations/check-child"; var param = new { locationId = this._Adjustment.locationId, barcode = locationBarcode }; res = HTTP.Post(url, param); if (res.Status) { if (Convert.ToBoolean(res.RawText)) { if (_LocationInfo != null) { DialogResult mgb = new DialogResult(); mgb = MessageBox.Show("Are you sure you want to update new scan location?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (mgb != DialogResult.Yes) { return; } } _LocationInfo = getLocationInfo(locationBarcode); if (_LocationInfo == null) { return; } this.lblLocationBarcode.Text = _LocationInfo.name; //enable button save if (this.dtList.Rows.Count > 0 && !btnSave.Enabled) { btnSave.Enabled = true; } } else { MessageBox.Show("Location is not exists in adjustment name!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); //btnSave.Enabled = false; //this.dtList.Rows.Clear(); //this.dgCuonList.Refresh(); this.locationBarcode = null; //this.lblLocationBarcode.Text = null; } } else { //btnSave.Enabled = false; //this.dtList.Rows.Clear(); //this.dgCuonList.Refresh(); } } catch (Exception ex) { MessageBox.Show("Error during load location information !"); } #endregion } }
private void ScanCode(string dcdData) { //Obtain the string and code id. //MessageBox.Show(dcdData); if (dcdData.StartsWith("[")) { #region New label LabelPackage labelPackage = null; try { labelPackage = new LabelPackage(dcdData.Trim()); } catch { MessageBox.Show("Wrong Package/UnitID QRCode format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (labelPackage.PackageId.StartsWith(PREFIX_LOT)) { #region Scan uid try { if (labelPackage.PackageId != null && labelPackage.PackageId != "") { if (checkReservedInOtherList(labelPackage.PackageId, false)) { MessageBox.Show("Package/Uid already exists in another reserved list!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } DataRow[] rs_package = dtList.Select(COL_LOT_ID + " = '" + labelPackage.PackageId + "'"); if (rs_package.Length > 0) { //DialogResult mgb = new DialogResult(); //mgb = MessageBox.Show("Package not exists in list !", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); //if (mgb == DialogResult.Yes) //{ // dr = dtList.Select("internalReference = '" + labelPackage.ProductName + "' AND " + COL_ID + " = '" + labelPackage.PackageId + "'").FirstOrDefault(); // if(dr == null) // addPackageNotInList(labelPackage.ProductName, labelPackage.PackageId); //} MessageBox.Show("Unit ID " + labelPackage.PackageId + " already exists in the list !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } else { //Validate Unit ID Lots lot = new Lots(); Lots lotInfo = lot.getInfo(labelPackage.PackageId); if (lotInfo == null) { MessageBox.Show("Unit ID " + labelPackage.PackageId + " is not exists in inventory !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } Packages PackageInfo = validateLot(lotInfo.id); if (PackageInfo == null) { return; } if (PackageInfo.packageNumber == null) { if (this.dtList.Rows.Count == 0) { addPackageToList("", labelPackage.PackageId); } else { DataRow[] rs = dtList.Select(COL_PACK_ID + " = ''"); if (rs.Length > 0) { addPackageToList("", labelPackage.PackageId); } else { if (Convert.ToString(this.dtList.Rows[0][COL_PACK_ID]).Length > 0) { MessageBox.Show("Request scan unit ID in package " + Convert.ToString(this.dtList.Rows[0][COL_PACK_ID])); } else { MessageBox.Show("Request scan free unit ID !"); } return; } } } else { if (this.dtList.Rows.Count == 0) { addPackageToList(PackageInfo.packageNumber, labelPackage.PackageId); } else { DataRow[] rs = dtList.Select(COL_PACK_ID + " = '" + PackageInfo.packageNumber + "'"); if (rs.Length > 0) { addPackageToList(PackageInfo.packageNumber, labelPackage.PackageId); } else { if (Convert.ToString(this.dtList.Rows[0][COL_PACK_ID]).Length > 0) { MessageBox.Show("Request scan unit ID in package " + Convert.ToString(this.dtList.Rows[0][COL_PACK_ID])); } else { MessageBox.Show("Request scan free unit ID !"); } return; } } } if (DestPackageNumber != null && DestPackageNumber.Trim().Length > 0 && !btnSave.Enabled) { //enable button save btnSave.Enabled = true; btnClear.Enabled = true; } } } else { MessageBox.Show("Error scan!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } catch (Exception ex) { //MessageBox.Show(ex.InnerException.ToString()); //MessageBox.Show("Error during loading information !", "Chu y", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } #endregion } else if (labelPackage.PackageId.StartsWith(PREFIX_PACK)) { #region Scan package if (DestPackageNumber != null && DestPackageNumber.Length > 0) { DialogResult mgb = new DialogResult(); mgb = MessageBox.Show("Are you sure you want to update the package number?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (mgb != DialogResult.Yes) { return; } } if (!checkExistsPackage(labelPackage.PackageId)) { return; } if (checkReservedInOtherList(labelPackage.PackageId, true)) { MessageBox.Show("Package/Uid already exists in another reserved list!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } DestPackageNumber = labelPackage.PackageId; txtDestPackageNumber.Text = DestPackageNumber; if (this.dtList.Rows.Count > 0 && !btnSave.Enabled) { //enable button save btnSave.Enabled = true; btnClear.Enabled = true; } #endregion } else { MessageBox.Show("Wrong Package/UnitID QRCode format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } #endregion } else if (dcdData.Trim().StartsWith("PN:")) { #region Old label TemCuon labelPackage = null; try { labelPackage = new TemCuon(dcdData.Trim()); } catch { MessageBox.Show("Wrong Package/UnitID QRCode format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (Convert.ToInt32(labelPackage.Type) == 0) { #region Scan Unit ID try { if (labelPackage.IdCuon != null && labelPackage.IdCuon != "") { if (checkReservedInOtherList(labelPackage.IdCuon, false)) { MessageBox.Show("Package/Uid already exists in another reserved list!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } DataRow[] rs_package = dtList.Select(COL_LOT_ID + " = '" + labelPackage.IdCuon + "'"); if (rs_package.Length > 0) { MessageBox.Show("Unit ID " + labelPackage.IdCuon + " already exists in the list !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } else { //Validate Unit ID Lots lot = new Lots(); Lots lotInfo = lot.getInfo(labelPackage.IdCuon); if (lotInfo == null) { MessageBox.Show("Unit ID " + labelPackage.IdCuon + " is not exists in inventory !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } Packages PackageInfo = validateLot(lotInfo.id); if (PackageInfo == null) { return; } if (PackageInfo.packageNumber == null) { if (this.dtList.Rows.Count == 0) { addPackageToList("", labelPackage.IdCuon); } else { DataRow[] rs = dtList.Select(COL_PACK_ID + " = ''"); if (rs.Length > 0) { addPackageToList("", labelPackage.IdCuon); } else { if (Convert.ToString(this.dtList.Rows[0][COL_PACK_ID]).Length > 0) { MessageBox.Show("Request scan unit ID in package " + Convert.ToString(this.dtList.Rows[0][COL_PACK_ID])); } else { MessageBox.Show("Request scan free unit ID !"); } return; } } } else { if (this.dtList.Rows.Count == 0) { addPackageToList(PackageInfo.packageNumber, labelPackage.IdCuon); } else { DataRow[] rs = dtList.Select(COL_PACK_ID + " = '" + PackageInfo.packageNumber + "'"); if (rs.Length > 0) { addPackageToList(PackageInfo.packageNumber, labelPackage.IdCuon); } else { if (Convert.ToString(this.dtList.Rows[0][COL_PACK_ID]).Length > 0) { MessageBox.Show("Request scan unit ID in package " + Convert.ToString(this.dtList.Rows[0][COL_PACK_ID])); } else { MessageBox.Show("Request scan free unit ID !"); } return; } } } if (DestPackageNumber != null && DestPackageNumber.Trim().Length > 0 && !btnSave.Enabled) { //enable button save btnSave.Enabled = true; btnClear.Enabled = true; } } } else { MessageBox.Show("Error scan!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } catch (Exception ex) { //MessageBox.Show(ex.InnerException.ToString()); //MessageBox.Show("Error during loading information !", "Chu y", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } #endregion } else if (Convert.ToInt32(labelPackage.Type) == 1) { #region Scan package if (DestPackageNumber != null && DestPackageNumber.Length > 0) { DialogResult mgb = new DialogResult(); mgb = MessageBox.Show("Are you sure you want to update the package number?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (mgb != DialogResult.Yes) { return; } } if (!checkExistsPackage(labelPackage.IdCuon)) { return; } if (checkReservedInOtherList(labelPackage.IdCuon, true)) { MessageBox.Show("Package/Uid already exists in another reserved list!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } DestPackageNumber = labelPackage.IdCuon; txtDestPackageNumber.Text = DestPackageNumber; if (this.dtList.Rows.Count > 0 && !btnSave.Enabled) { //enable button save btnSave.Enabled = true; btnClear.Enabled = true; } #endregion } else { MessageBox.Show("Wrong Package/UnitID QRCode format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } #endregion } else if (Util.OnlyHexInString(dcdData.Trim())) { #region Serial number string SerialNumber = dcdData.Trim(); checkScan(SerialNumber, null); #endregion } else { MessageBox.Show("Wrong Package/UnitID QRCode format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } }