Example #1
0
        private void buttoneRBill_Click(object sender, EventArgs e)
        {
            dataGridViewCurrentShipment.Focus();

            if (!Main.CheckUserPermission(Properties.Settings.Default.WsirConnectionString, Properties.Settings.Default.UsuarioNombre, "SolViewShipment", true))
            {
                return;
            }

            if (dataGridViewCurrentShipment.SelectedRows.Count < 1)
            {
                MessageBox.Show("Please select a Shipment to tramsmit", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }


            RBillNumber = dataGridViewCurrentShipment.SelectedRows[0].Cells[0].Value.ToString();
            string status = dataGridViewCurrentShipment.SelectedRows[0].Cells[3].Value.ToString();

            if (status.ToLower() != "s")
            {
                MessageBox.Show("Only Shipments marked as Shipped please", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (sol_Shipment_Sp == null)
            {
                sol_Shipment_Sp = new Sol_Shipment_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }
            sol_Shipment = sol_Shipment_Sp.SelectByRBillNumber(RBillNumber);
            if (sol_Shipment == null)
            {
                MessageBox.Show(String.Format("Invalid RBill Number: {0}, please verify it!", RBillNumber), "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (sol_Shipment.ERBillTransmitted)
            {
                //MessageBox.Show("Shipment already transmitted!");
                //return;
                DialogResult result = MessageBox.Show("This R-Bill has already been submitted.  Are you sure you want to send it again?", "", MessageBoxButtons.YesNoCancel);    //.YesNo);
                if (result != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }
            }

            if (sol_Agencie_Sp == null)
            {
                sol_Agencie_Sp = new Sol_Agencie_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }
            sol_Agencie = sol_Agencie_Sp.Select(sol_Shipment.AgencyID);
            if (sol_Agencie.Name.ToLower().Trim() != "abcrc")
            {
                MessageBox.Show("Shipment's agency is not ABCRC!");
                return;
            }

            ShippingShipments.eRBill(sol_Shipment, sol_Shipment_Sp);
        }
        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);
        }