private void ShippingShipmentsInventory_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'dataSetContainersLookup.sol_Containers' table. You can move, or remove it, as needed. this.sol_ContainersTableAdapter.FillByType(this.dataSetContainersLookup.sol_Containers, 1); //1 = Shipping Containers confirmed = false; if (Properties.Settings.Default.TouchOriented) { toolStripButtonVirtualKb.Visible = true; } sol_Product_Sp = new Sol_Product_Sp(Properties.Settings.Default.WsirDbConnectionString); //read sbol containers sol_Container_Sp = new Sol_Container_Sp(Properties.Settings.Default.WsirDbConnectionString); sbolContainersID = new int[4]; sbolContainersName = new string[4]; if (Main.Sol_ControlInfo.WhiteBagID < 1 || Main.Sol_ControlInfo.BlueBagID < 1 || Main.Sol_ControlInfo.OneWayBagID < 1 || Main.Sol_ControlInfo.ABCRCPalletsID < 1 ) { MessageBox.Show("You have to define ALL containers for Straight BOL, cannot continue.\r\n Please go to Tools -> Settings -> ABCRC to do that."); Close(); return; } if (!ReadSBolContainers(Main.Sol_ControlInfo.WhiteBagID, 0) || !ReadSBolContainers(Main.Sol_ControlInfo.BlueBagID, 1) || !ReadSBolContainers(Main.Sol_ControlInfo.OneWayBagID, 2) || !ReadSBolContainers(Main.Sol_ControlInfo.ABCRCPalletsID, 3) ) { Close(); return; } AddRows2(); }
private bool CreateAdjustment(AdjustmentActionTypes adjActionTypes, int stageId, int productId) { sol_Stage = sol_Stage_Sp.Select(stageId); if (sol_Stage == null) { MessageBox.Show(String.Format("StageID not found ({0}) ", stageId)); return(false); } DateTime dt = sol_Stage.Date; if (checkBoxDate.Checked) { dt = Main.rc.FechaActual; } Sol_Stage sol_StageAdjustment = new Sol_Stage(); sol_StageAdjustment.ShipmentID = sol_ShipmentAdjustment.ShipmentID; sol_StageAdjustment.UserID = sol_Stage.UserID; sol_StageAdjustment.UserName = sol_Stage.UserName; //sol_StageAdjustment.Date = dt; sol_StageAdjustment.Date = Main.rc.FechaActual; // ; // Properties.Settings.Default.FechaActual;; sol_StageAdjustment.TagNumber = sol_Stage.TagNumber + "A"; sol_StageAdjustment.ContainerID = sol_Stage.ContainerID; sol_StageAdjustment.ContainerDescription = sol_Stage.ContainerDescription; sol_StageAdjustment.ProductID = sol_Stage.ProductID; sol_StageAdjustment.ProductName = sol_Stage.ProductName; sol_StageAdjustment.Dozen = 0; //not used anymore sol_Stage.Dozen * -1; sol_StageAdjustment.Quantity = sol_Stage.Quantity * -1; sol_StageAdjustment.Price = sol_Stage.Price; sol_StageAdjustment.Remarks = sol_Stage.Remarks; sol_StageAdjustment.Status = sol_Stage.Status; //in case there is no default value in the db sol_StageAdjustment.DateClosed = DateTime.Parse("1753-01-01 12:00:00.000"); switch (adjActionTypes) { case AdjustmentActionTypes.Return: //remove it //sol_StageAdjustment.TagNumber = sol_Stage.TagNumber; sol_StageAdjustment.Dozen = sol_Stage.Dozen * -1; sol_StageAdjustment.Quantity = sol_Stage.Quantity * -1; //sol_StageAdjustment.Status = sol_Stage.Status; sol_Stage_Sp.Insert(sol_StageAdjustment); //add an adjustment to return to inventory sol_StageAdjustment.ShipmentID = 0; sol_StageAdjustment.TagNumber = textBoxNewTagNumber.Text; //sol_Stage.TagNumber sol_StageAdjustment.Dozen = 0; //not used anymore sol_Stage.Dozen; sol_StageAdjustment.Quantity = sol_Stage.Quantity; sol_StageAdjustment.Status = "I"; //sol_Stage.Status; sol_Stage_Sp.Insert(sol_StageAdjustment); ////remove it from shipment //sol_Stage.ShipmentID = 0; //sol_Stage.TagNumber = textBoxNewTagNumber.Text; //sol_Stage.Status = "I"; //sol_Stage_Sp.Update(sol_Stage); MessageBox.Show( string.Format( @"Tag Number {0} has been added to inventory. Note: This tag is in inventory and is no longer linked to the previous shipment. Therefore, the new tag will not be removed if you delete the adjustment." , textBoxNewTagNumber.Text )); return(true); //break; case AdjustmentActionTypes.Remove: break; //case AdjustmentActionTypes.Add: // break; case AdjustmentActionTypes.Adjust: //create reverse adjustment to remove original quantity sol_Stage_Sp.Insert(sol_StageAdjustment); //create adjustment with new product if (productId > 0) { if (sol_Product_Sp == null) { sol_Product_Sp = new Sol_Product_Sp(Properties.Settings.Default.WsirDbConnectionString); } sol_Product = sol_Product_Sp.Select(productId); sol_StageAdjustment.ProductID = productId; sol_StageAdjustment.ProductName = sol_Product.ProName; //sol_StageAdjustment.Dozen = sol_Stage.Dozen; //sol_StageAdjustment.Quantity = sol_Stage.Quantity; } int newQuantity = 0; int.TryParse(textBoxNewQuantity.Text, out newQuantity); sol_StageAdjustment.Quantity = newQuantity; sol_StageAdjustment.Dozen = 0; //not used anymore newQuantityOfDozens; break; //case AdjustmentActionTypes.Change: // //create reverse adjustment to remove original product // sol_Stage_Sp.Insert(sol_StageAdjustment); // //create adjustment with new product // if (sol_Product_Sp == null) // sol_Product_Sp = new Sol_Product_Sp(Properties.Settings.Default.WsirDbConnectionString); // sol_Product = sol_Product_Sp.Select(productId); // sol_StageAdjustment.ProductID = productId; // sol_StageAdjustment.ProductName = sol_Product.ProName; // sol_StageAdjustment.Dozen = sol_Stage.Dozen; // sol_StageAdjustment.Quantity = sol_Stage.Quantity; // break; //case AdjustmentActionTypes.Delete: // break; default: break; } sol_Stage_Sp.Insert(sol_StageAdjustment); return(true); }
//SOAP v1.2, and binding is wsHttpBindin private bool Test_validate(Sol_Shipment sol_Shipment, Sol_Shipment_Sp sol_Shipment_Sp) { if (String.IsNullOrEmpty(Main.Sol_ControlInfo.ABCRCUserName)) { MessageBox.Show("Please go to Settings -> ABCRC and add User Name and Password", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (checkBoxViewERBill.Checked) { f1 = new eRBill_CheckList_ListView(); } //https://abcrcerbill.com/WcfAbcrcService/ //former: https://abcrcerbill.com/WsHttpsAbcrcService.svc WsHttpsAbcrcServiceClient client = new WsHttpsAbcrcServiceClient(); //"configName", "https://abcrcerbill.com/WsHttpsAbcrcService.svc"); client.ClientCredentials.UserName.UserName = Main.Sol_ControlInfo.ABCRCUserName; client.ClientCredentials.UserName.Password = Main.Sol_ControlInfo.ABCRCPassword; int intNumber = 0; string strValue = String.Empty; string vendorId = String.Empty; string tagNumber = String.Empty; string productCode = String.Empty; int iProductCode = 0; string quantity = String.Empty; try { AbcrcERBill eRBill = new AbcrcERBill(); strValue = sol_Shipment.RBillNumber; vendorId = string.Format("{0:d4}", Main.Sol_ControlInfo.VendorID); //parse it if (sol_Shipment.RBillNumber.Length < 7) { Int32.TryParse(sol_Shipment.RBillNumber, out intNumber); strValue = vendorId + string.Format("{0:d6}", intNumber); } eRBill.RBillNumber = strValue; ////temporaly change for testing //vendorId = "0000"; eRBill.CarrierCrisID = sol_Shipment.CarrierID; eRBill.PlantCrisID = sol_Shipment.PlantID; eRBill.TrailerNumber = sol_Shipment.TrailerNumber; eRBill.ProBillNumber = sol_Shipment.ProBillNumber; eRBill.ShippedDate = sol_Shipment.ShippedDate; eRBill.SealNumber = sol_Shipment.SealNumber; eRBill.LoadReference = sol_Shipment.LoadReference; //add used and empty bags AbcrcERBillBag bag; int nBags = 0, nMaxBags = 0; AbcrcOtherShippingContainer aosc; int nAosc = 0, nMaxAosc = 0; //open product table Sol_Product_Sp sol_Product_Sp = new Sol_Product_Sp(Properties.Settings.Default.WsirDbConnectionString); Sol_Product sol_Product; //open Container table Sol_Container_Sp sol_Container_Sp = new Sol_Container_Sp(Properties.Settings.Default.WsirDbConnectionString); Sol_Container sol_Container; //read containers in shipment and get number of bags Sol_Stage_Sp sol_Stage_Sp = new Sol_Stage_Sp(Properties.Settings.Default.WsirDbConnectionString); List <Sol_Stage> sol_StageList = sol_Stage_Sp._SelectAllByShipmentID(sol_Shipment.ShipmentID); if (sol_StageList.Count < 1) { MessageBox.Show("", "No containers found in shipment, cannot continue!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } nMaxBags = sol_StageList.Count; //read eRBill empty containers and get number of bags Sol_SupplyInventory_Sp sol_SupplyInventory_Sp = new Sol_SupplyInventory_Sp(Properties.Settings.Default.WsirDbConnectionString); List <Sol_SupplyInventory> sol_SupplyInventoryList = sol_SupplyInventory_Sp._SelectAllByShipmentID(sol_Shipment.ShipmentID); foreach (Sol_SupplyInventory ssi in sol_SupplyInventoryList) { if (ssi.ProductID < 1) { //Empty Bags - EmptyContainer nMaxAosc++; } } //set max bags if (nMaxBags > 0) { eRBill.Bags = new AbcrcERBillBag[nMaxBags]; } if (nMaxAosc > 0) { eRBill.AdditionalShippingContainers = new AbcrcOtherShippingContainer[nMaxAosc]; } //process shipment containers foreach (Sol_Stage ssi in sol_StageList) { //get ShippingContainerID for ItemTypeCrisID sol_Container = sol_Container_Sp.Select(ssi.ContainerID); //begin loop //get productCode for ShippingContainerTypeCrisID sol_Product = sol_Product_Sp.Select(ssi.ProductID); Int32.TryParse(sol_Product.ProductCode, out iProductCode); productCode = string.Format("{0:d4}", iProductCode); bag = new AbcrcERBillBag(); quantity = string.Format("{0:d5}", ssi.Quantity); if (ssi.TagNumber.Length < 8) { Int32.TryParse(ssi.TagNumber, out intNumber); tagNumber = string.Format("{0:d7}", intNumber); strValue = vendorId + productCode + quantity + tagNumber; } else if (ssi.TagNumber.Length == 20) { strValue = ssi.TagNumber; } else { string m = String.Format("Tag Number {0} has the wrong number of digits. eR-Bill can't be processed. Please correct the Tag Number and submit the eR-Bill again.", ssi.TagNumber); MessageBox.Show("", m, MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } bag.BagTag = strValue; //sol_Stage.TagNumber bag.ItemTypeCrisID = iProductCode; bag.ShippingContainerTypeCrisID = sol_Container.ShippingContainerTypeID; bag.UnitsShipped = ssi.Quantity; //ssi.Dozen * 12; //KEV - this was fixed in 5.0.4. Dozens are not used. if (checkBoxViewERBill.Checked) { addItem(bag.BagTag, bag.ItemTypeCrisID, bag.ShippingContainerTypeCrisID, bag.UnitsShipped, ref eRBill_CheckList_ListView.listView1); } eRBill.Bags[nBags++] = bag; //end loop } //process empty containers foreach (Sol_SupplyInventory ssi in sol_SupplyInventoryList) { //bag tag ? //Item Type ID //Shipping Container Type ID //Units Shipped //get ShippingContainerID for ItemTypeCrisID sol_Container = sol_Container_Sp.Select(ssi.ContainerID); //} if (ssi.ProductID < 1) { //Empty Bags - EmptyContainer //empty bags aosc = new AbcrcOtherShippingContainer(); //eRBill.AdditionalShippingContainers = new AbcrcOtherShippingContainer[1]; aosc.ShippingContainerTypeCrisID = sol_Container.ShippingContainerTypeID; aosc.ContainersShipped = ssi.Quantity; if (checkBoxViewERBill.Checked) { addItem("", 0, aosc.ShippingContainerTypeCrisID, aosc.ContainersShipped, ref eRBill_CheckList_ListView.listView2); } eRBill.AdditionalShippingContainers[nAosc++] = aosc; } } AbcrcValidationResponse response = client.ValidateErBill(eRBill); string c = String.Empty; foreach (AbcrcValidationMessage m in response.ValidationMessages) { c = c + "\r\n" + m.ValidationMessage; } c = c + "\r\n" + response.ErrorMessage; if (response.Error == false && response.IsValid == true) { //MessageBox.Show("Validation passed successful!"); c = String.Empty; //submit AbcrcSubmitResponse submitResponse = client.SubmitErBill(eRBill); foreach (AbcrcValidationMessage m in submitResponse.ValidationMessages) { c = c + "\r\n" + m.ValidationMessage; } c = c + "\r\n" + submitResponse.ErrorMessage; if (!(submitResponse.Error == false && submitResponse.IsValid == true)) { //CajaDeMensaje.Show("", "Validation not passed successful, debug it!", c, CajaDeMensajeImagen.Error); MessageBox.Show(c, "Even thought the erBill validation was succesfull, it was not received by the agency!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } } else { //CajaDeMensaje.Show("", "Validation not passed successful, debug it!", c, CajaDeMensajeImagen.Error); MessageBox.Show(c, "Validation not passed successful, debug it!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } } catch (Exception exception) { //MessageBox.Show(exception.Message); //CajaDeMensaje.Show("", exception.Message, exception.InnerException.Message, CajaDeMensajeImagen.Error); string m1 = String.Empty; try { m1 = exception.InnerException.Message; } catch { m1 = "Error when trying to create and validate eRBill's object. "; } //string m2 = exception.Message; MessageBox.Show(exception.Message, m1, MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } return(true); }
private void buttonPrintLabel_Click(object sender, EventArgs e) { //commands /* * {barCode} * {vendorId} * {productCode} * {quantity} * {tag} * {depotName} * {description} of the product * {dozen} * {date} * {stageId} */ string barCode = String.Empty; string vendorId = String.Empty; string productCode = String.Empty; string quantity = String.Empty; string tag = String.Empty; int intValue = 0; //sending raw directly to lp2844 UpcLabel label = new UpcLabel(""); string labelCommands = Properties.Settings.Default.SettingsWsLabelCommands; //open table connection if (sol_Agency_Sp == null) { sol_Agency_Sp = new Sol_Agencie_Sp(Properties.Settings.Default.WsirDbConnectionString); } if (sol_Product_Sp == null) { sol_Product_Sp = new Sol_Product_Sp(Properties.Settings.Default.WsirDbConnectionString); } //search for product sol_Product = sol_Product_Sp.Select(sol_Stage.ProductID); if (sol_Product != null) { intValue = 0; Int32.TryParse(sol_Product.ProductCode, out intValue); productCode = intValue.ToString("0000"); sol_Agency = sol_Agency_Sp.Select(sol_Product.AgencyID); if (sol_Agency != null) { intValue = 0; Int32.TryParse(sol_Agency.VendorID, out intValue); vendorId = intValue.ToString("0000"); } } intValue = 0; Int32.TryParse(textBoxDozen.Text, out intValue); string c = String.Format("{0}", intValue); labelCommands = labelCommands.Replace("{dozen}", c); int intQuantity = intValue * 12; c = String.Format("{0}", intQuantity); labelCommands = labelCommands.Replace("{quantity}", c); quantity = intQuantity.ToString("00000"); intValue = 0; Int32.TryParse(textBoxTagNumber.Text, out intValue); tag = intValue.ToString("0000000"); barCode = vendorId + productCode + quantity + tag; labelCommands = labelCommands.Replace("{barCode}", barCode); labelCommands = labelCommands.Replace("{vendorId}", sol_Agency.VendorID.Trim()); labelCommands = labelCommands.Replace("{productCode}", sol_Product.ProductCode.Trim()); labelCommands = labelCommands.Replace("{quantity}", sol_Stage.Quantity.ToString().Trim()); labelCommands = labelCommands.Replace("{tag}", textBoxTagNumber.Text.Trim()); labelCommands = labelCommands.Replace("{depotName}", Main.Sol_ControlInfo.BusinessName.Trim()); labelCommands = labelCommands.Replace("{description}", sol_Product.ProDescription.Trim()); //labelCommands = labelCommands.Replace("{dozen}", textBoxTagNumber.Text.Trim()); //labelCommands = labelCommands.Replace("{date}", textBoxTagNumber.Text.Trim()); //labelCommands = labelCommands.Replace("{stageId}", textBoxTagNumber.Text.Trim()); ////MessageBox.Show(labelCommands); //labelCommands = labelCommands.Replace("{tag}", textBoxTagNumber.Text.Trim()); ////labelCommands = labelCommands.Replace("{agency}", textBoxTagNumber.Text.Trim()); //labelCommands = labelCommands.Replace("{description}", comboBoxProducts.Text.Trim()); DateTime dt = Main.rc.FechaActual; // ; try { dt = DateTime.Parse(textBoxDate.Text); } catch { } labelCommands = labelCommands.Replace("{date}", dt.ToString("dd-MMM-yyyy")); labelCommands = labelCommands.Replace("{stageId}", sol_Stage.StageID.ToString()); try { //quitar (uncomment) label.Print(Properties.Settings.Default.SettingsWsLabelPrinter, labelCommands); //quitar (comment) //MessageBox.Show(labelCommands); } catch { MessageBox.Show("Label printer not found!"); } }
private void comboBoxProducts_SelectedIndexChanged(object sender, EventArgs e) { int Id = -1; try { Id = (int)comboBoxProducts.SelectedValue; } catch { return; } //delete row if it was new if (sol_Agency != null) { if (sol_Agency.AutoGenerateTagNumber) { if (buttonClicked == "&New") { DeleteStagedRow(); } } } //Sol_Product sol_Product = new Sol_Product(); if (sol_Product_Sp == null) { sol_Product_Sp = new Sol_Product_Sp(Properties.Settings.Default.WsirDbConnectionString); } sol_Product = sol_Product_Sp.Select(Id); comboBoxContainers.SelectedValue = sol_Product.ContainerID; //open table connection if (sol_Agency_Sp == null) { sol_Agency_Sp = new Sol_Agencie_Sp(Properties.Settings.Default.WsirDbConnectionString); } sol_Agency = sol_Agency_Sp.Select(sol_Product.AgencyID); //if (sol_Agency != null) //{ // Int32.TryParse(sol_Agency.VendorID, out intValue); // vendorId = intValue.ToString("0000"); //} if (sol_Agency.AutoGenerateTagNumber) { //add row if (AddStagedRow()) { textBoxTagNumber.Text = sol_Stage.TagNumber; textBoxTagNumber.ReadOnly = true; comboBoxContainers.Focus(); comboBoxProducts.Enabled = false; } else { buttonCancel.PerformClick(); } } else { textBoxTagNumber.ReadOnly = false; //textBoxTagNumber.Focus(); } //Sol_StandardDozen_Sp sol_StandardDozen_Sp = new Sol_StandardDozen_Sp(Properties.Settings.Default.WsirDbConnectionString); //Sol_StandardDozen sol_StandardDozen = sol_StandardDozen_Sp.Select(sol_Product.StandardDozenID); //textBoxDefaultDozen.Text = sol_StandardDozen.Quantity.ToString(); textBoxQuantity.Text = sol_Product.TargetQuantity.ToString(); textBoxDozen.Text = SolFunctions.Quantity2Dozen(sol_Product.TargetQuantity); }
//private void timer1_Tick(object sender, System.EventArgs e) //{ // DateTime t = DateTime.Now; // toolStripStatusLabelTimer.Text = t.ToShortTimeString(); // toolStripStatusLabelToday.Text = t.ToShortDateString(); //} private void textBoxTagNumber_Leave(object sender, EventArgs e) { if (String.IsNullOrEmpty(textBoxTagNumber.Text)) { return; } if (buttonClicked != "&New") { return; } //was a barcode read? string barCode = textBoxTagNumber.Text.Trim(); string x = barCode; if (x.Length > 7) { //x = x.Substring(x.Length - 7); //int intValue = 0; //Int32.TryParse(x, out intValue); //if (intValue > 0) // textBoxTagNumber.Text = String.Format("{0}", intValue); //else //{ // MessageBox.Show("Error parsing the Tag Number!"); // textBoxTagNumber.Focus(); // return; //} //search for product from barcode /* 0000 1006 00000 0004209 * 4 = vendorID * 4 = productCode = ItemTypes (CRIS) * 5 = quantity * 7 = tagNumber * 7 + 5 + 4 * */ x = barCode; if (x.Length > 19) { int i = x.Length - 16; x = x.Substring(i, 4); } if (sol_Product_Sp == null) { sol_Product_Sp = new Sol_Product_Sp(Properties.Settings.Default.WsirDbConnectionString); } //search for product sol_Product = sol_Product_Sp.SelectProductCode(x); if (sol_Product != null) { comboBoxProducts.SelectedValue = sol_Product.ProductID; textBoxQuantity.Focus(); //textBoxDozen.Focus(); } } }