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 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);
        }