private void AddRowsToTable() { //Sol_SupplyInventory Sol_SupplyInventory = new Sol_SupplyInventory(); Sol_SupplyInventory_Sp sol_SupplyInventory_Sp = new Sol_SupplyInventory_Sp(Properties.Settings.Default.WsirDbConnectionString); MembershipUser membershipUser = membershipUser = Membership.GetUser(Properties.Settings.Default.UsuarioNombre); if (membershipUser == null) { MessageBox.Show("User does not exits, cannot add shipping containers entry"); return; } Guid userID = (Guid)membershipUser.ProviderUserKey; int quantity = 0; foreach (DataGridViewRow row in dataGridViewShippingContainers.Rows) { if (row.IsNewRow) { continue; } Int32.TryParse(row.Cells[2].Value.ToString(), out quantity); if (quantity == 0) { continue; } Sol_SupplyInventory sol_SupplyInventory = new Sol_SupplyInventory(); ////SupplyInventoryTypes //"0", "Order" //"R", "Received Order" //"A", "Adjustment" //"S", "Shipped" sol_SupplyInventory.SupplyInventoryType = "S"; sol_SupplyInventory.UserID = userID; sol_SupplyInventory.Date = Main.rc.FechaActual; sol_SupplyInventory.DateOrdered = DateTime.Parse("1753-1-1 12:00:00"); sol_SupplyInventory.ProductID = (int)row.Cells[4].Value; sol_SupplyInventory.ContainerID = (int)row.Cells[1].Value; sol_SupplyInventory.Quantity = quantity; sol_SupplyInventory.ShipmentID = shipmentId; sol_SupplyInventory.ReferenceNumber = String.Empty; sol_SupplyInventory_Sp.Insert(sol_SupplyInventory); } //dataGridViewShippingContainers.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders); }
private void CreateAdjustemnt() { bool flagDone = false; //classes of tables sol_SupplyInventory = new Sol_SupplyInventory(); if (sol_SupplyInventory_Sp == null) { sol_SupplyInventory_Sp = new Sol_SupplyInventory_Sp(Properties.Settings.Default.WsirDbConnectionString); } //if (MessageBox.Show("Do you want to continue", "Closing Voucher", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != System.Windows.Forms.DialogResult.Yes) // return; //int totalqty = 0; int nrows = listViewUnstagedProducts.Items.Count; sol_SupplyInventory.SupplyInventoryType = "A"; // O = Order, R = Received Order, A = Adjustment, S = Shipped string c; //computer name //c = Properties.Settings.Default.SettingsWsWorkStationName.Trim(); //if (String.IsNullOrEmpty(c)) // c = Main.myHostName; //sol_SupplyInventory.ComputerName = c; // MembershipUser membershipUser = membershipUser = Membership.GetUser(Properties.Settings.Default.UsuarioNombre); if (membershipUser == null) { MessageBox.Show("User does not exits, cannot create Adjustment!"); return; } Guid userId = (Guid)membershipUser.ProviderUserKey; sol_SupplyInventory.UserID = userId; sol_SupplyInventory.Date = Main.rc.FechaActual; // ;// Properties.Settings.Default.FechaActual; sol_SupplyInventory.DateOrdered = DateTime.Parse("1753-1-1 12:00:00"); sol_SupplyInventory_Sp.Insert(sol_SupplyInventory); for (int i = 0; i < nrows; i++) { //int quantity c = listViewUnstagedProducts.Items[i].SubItems[1].Text; c = c.Replace("(", ""); c = c.Replace(")", ""); c = c.Replace(",", ""); int quantity = Convert.ToInt32(c); c = this.arrayListViewQuantity[i].ToString(); int oldQuantity = (int)this.arrayListViewQuantity[i]; if (oldQuantity == quantity) { continue; } int adjustmenQuantity = quantity - oldQuantity; sol_SupplyInventory.Quantity = adjustmenQuantity; //totalqty = totalqty + (adjustmenQuantity); //int categoryID sol_SupplyInventory.ContainerID = (int)this.arrayListViewContainerId[i]; //add row sol_SupplyInventory_Sp.Insert(sol_SupplyInventory); flagDone = true; } if (flagDone) { MessageBox.Show("Adjustment created."); } }
//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 buttonUnNow_Click(object sender, EventArgs e) { dataGridViewCurrentShipment.Focus(); if (!Main.CheckUserPermission(Properties.Settings.Default.WsirConnectionString, Properties.Settings.Default.UsuarioNombre, "SolUnshipShipment", true)) { return; } if (dataGridViewCurrentShipment.SelectedRows.Count < 1) { MessageBox.Show("Please select a Shipment to Unship", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } RBillNumber = dataGridViewCurrentShipment.SelectedRows[0].Cells[0].Value.ToString(); string status = dataGridViewCurrentShipment.SelectedRows[0].Cells[3].Value.ToString(); string strShipmentId = dataGridViewCurrentShipment.SelectedRows[0].Cells[5].Value.ToString(); string rBillDate = dataGridViewCurrentShipment.SelectedRows[0].Cells[2].Value.ToString(); if (status.ToLower() != "s") { MessageBox.Show("Only Shipments already shipped can be Unshipped", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //update shipment status int shipmentId = 0; Int32.TryParse(strShipmentId, out shipmentId); if (shipmentId < 1) { MessageBox.Show("Shipment ID invalid!"); } else { sol_Shipment = sol_Shipment_Sp.Select(shipmentId); //if (sol_Shipment.ERBillTransmitted) //{ // MessageBox.Show("Shipment already transmitted!"); // return; //} //update stage status sol_Stage_Sp.UpdateStatusByShipmentId(shipmentId, "P"); //I-InProgress; P-Picked S-Shipped sol_Shipment_Sp.UpdateStatus(shipmentId, "I"); //I-InProgress; P-Picked S-Shipped //sol_Shipment_Sp.UpdateERBillTransmitted(shipmentId, false); //delete supply inventory entries //Sol_SupplyInventory sol_SupplyInventory; if (sol_SupplyInventory_Sp == null) { sol_SupplyInventory_Sp = new Sol_SupplyInventory_Sp(Properties.Settings.Default.WsirDbConnectionString); } sol_SupplyInventory_Sp._DeleteAllByShipmentID(shipmentId); //refresh shipments ReadCurrentShipments(); MessageBox.Show("UnShipped!"); dataGridViewCurrentShipment.Focus(); } }