Ejemplo n.º 1
0
        private void SupplyInventoryReceive_Load(object sender, EventArgs e)
        {
            if (Properties.Settings.Default.TouchOriented)
            {
                toolStripButtonVirtualKb.Visible = true;
            }

            //read sbol containers
            sol_Container_Sp = new Sol_Container_Sp(Properties.Settings.Default.WsirDbConnectionString);
            readContainers();
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        //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);
        }