private void buttonSubmit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxTagNumber.Text))
            {
                MessageBox.Show("Please, enter a valid tag number!");
                textBoxTagNumber.Focus();
                return;
            }

            if (sol_Stage_Sp == null)
            {
                sol_Stage_Sp = new Sol_Stage_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }

            sol_Stage = sol_Stage_Sp._SelectByTagNumberStatus(textBoxTagNumber.Text, "");   //I");
            if (sol_Stage != null)
            {
                MessageBox.Show("Tag number already exists, try another one please.");
                textBoxTagNumber.Focus();
                return;
            }

            tagNumber  = textBoxTagNumber.Text;
            cancelFlag = false;
            Close();
        }
        private void buttonParse_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textBoxInput.Text))
            {
                MessageBox.Show("Nothing to parse! TextBox empty.");
                return;
            }

            // Display the ProgressBar control.
            progressBar1.Visible = true;
            // Set Minimum to 1 to represent the first file being copied.
            progressBar1.Minimum = 1;
            // Set the initial value of the ProgressBar.
            progressBar1.Value = 1;
            // Set the Step property to a value of 1 to represent each file being copied.
            progressBar1.Step = 1;


            string[] tags       = textBoxInput.Text.Split('\n');
            string   strBadTags = "";

            //badTags = new string[tags.GetLength(0)];
            // Set Maximum to the total number of files to copy.
            progressBar1.Maximum = tags.GetLength(0);
            bool flagAdded = false;

            foreach (string ren in tags)
            {
                // Perform the increment on the ProgressBar.
                progressBar1.PerformStep();
                string renx = ren.Trim();
                if (String.IsNullOrEmpty(renx))
                {
                    continue;
                }

                int ps = renx.LastIndexOf(',');
                if (ps < 0)
                {
                    ps = -1;
                }
                string tagNumber = renx.Substring(ps + 1);
                if (String.IsNullOrEmpty(tagNumber))
                {
                    continue;
                }

                //was a barcode read?
                //string x = tagNumber;
                //if (x.Length > 7)
                //{
                //    x = x.Substring(x.Length - 7);
                //    int intValue = 0;
                //    Int32.TryParse(x, out intValue);
                //    if (intValue > 0)
                //        tagNumber = String.Format("{0}", intValue);
                //    else
                //        continue;

                //}

                ps        = 0;
                sol_Stage = sol_Stage_Sp._SelectByTagNumberStatus(tagNumber, "I");
                if (
                    //SearchStagedContainerOnShipment(tagNumber) ||
                    sol_Stage == null)
                {
                    //badTags[ps++] = tagNumber + " - Tag number does not exist or already in shipment\n";
                    strBadTags += tagNumber + " - Tag number does not exist or already in shipment" + Environment.NewLine;

                    continue;
                }
                //switch containers
                ShippingShipments.SwitchContainers(
                    ref ShippingShipments.listViewCurrentStagedContainers,
                    ref ShippingShipments.listViewContainersOnShipment, sol_Stage.TagNumber, true, null);

                flagAdded = true;
            }

            // Perform the increment on the ProgressBar.
            progressBar1.Value = progressBar1.Maximum;


            //tags not processed
            if (!String.IsNullOrEmpty(strBadTags))
            {
                SirLib.CajaDeMensaje.Show("Tags not processed", "Error parsing tags numbers.", strBadTags, SirLib.CajaDeMensajeImagen.Error);
            }

            string men = "Done!";

            if (flagAdded)
            {
                if (String.IsNullOrEmpty(strBadTags))
                {
                    men += " - All tags added.";
                }
                else
                {
                    men += " - With some tags not added.";
                }
            }
            else
            {
                men += " - Nothing added";
            }


            MessageBox.Show(men);
            // Set the Step property to a value of 1 to represent each file being copied.
            progressBar1.Value = 1;
            textBoxInput.Text  = "";
        }
Exemple #3
0
        private void buttonVoidStagedContainer_Click(object sender, EventArgs e)
        {
            if (!Main.CheckUserPermission(Properties.Settings.Default.WsirConnectionString, Properties.Settings.Default.UsuarioNombre, "SolModifyContainer", true))
            {
                return;
            }

            ListView.SelectedListViewItemCollection selectedItems = listViewCurrentStagedContainers.SelectedItems;
            if (selectedItems.Count < 1)
            {
                MessageBox.Show("Please select a Staged Container");
                return;
            }


            ////ListViewItem itm;   // = new ListViewItem();
            //foreach (ListViewItem item in selectedItems)
            //{
            //    tagNumber = item.SubItems[0].Text;
            //}

            //ShippingForm = 2;   //StagedContainers
            //StagedContainerButtonView = true;
            //Close();


            bool firstTime = true;
            //int stageId = 0;
            string tagNumber = "";

            //selected items
            foreach (ListViewItem item in selectedItems)
            {
                try
                {
                    //stageId = Int32.Parse(item.SubItems[0].Text);
                    tagNumber = item.SubItems[0].Text;
                }
                catch
                {
                    continue;
                }

                if (firstTime)
                {
                    firstTime = false;
                    if (MessageBox.Show("Are you sure you want to delete Staged Container:" + item.SubItems[0].Text + "?", "Delete Staged Container", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != System.Windows.Forms.DialogResult.Yes)
                    {
                        return;
                    }
                }


                //read order
                //sol_Stage = sol_Stage_Sp.Select(stageId);
                sol_Stage = sol_Stage_Sp._SelectByTagNumberStatus(tagNumber, "I");  // .Select(stageId);
                //not found?
                if (sol_Stage == null)
                {
                    continue;
                }

                ////marked as deleted
                //sol_Stage.Status = "D";
                //sol_Stage_Sp.Update(sol_Stage);

                sol_Stage_Sp.Delete(sol_Stage.StageID);


                //sol_OrdersDetail_Sp._DeleteAllByOrderID_OrderType(
            }

            //refresh list or remove item above???
            ReadCurrentStagedContainers();
        }
        private void buttonClose_Click(object sender, EventArgs e)
        {
            if (comboBoxProducts.SelectedIndex < 0)
            {
                MessageBox.Show("Please enter a Product");
                comboBoxProducts.Focus();
                return;
            }

            if (String.IsNullOrEmpty(textBoxTagNumber.Text))
            {
                MessageBox.Show("Please enter a Tag number");
                textBoxTagNumber.Focus();
                controlWithFocus = textBoxTagNumber;
                return;
            }

            if (comboBoxContainers.SelectedIndex < 0)
            {
                MessageBox.Show("Please enter a Container Type");
                comboBoxContainers.Focus();
                return;
            }

            int quantity = 0;

            try
            {
                quantity = Int32.Parse(textBoxQuantity.Text);
            }
            catch
            {
                MessageBox.Show("Please enter a valid quantity.");
                textBoxQuantity.Focus();
                return;
            }

            if (String.IsNullOrEmpty(textBoxDozen.Text))
            {
                MessageBox.Show("Please enter number of dozens");
                textBoxDozen.Focus();
                return;
            }

            decimal dozen = 0;

            try
            {
                dozen = decimal.Parse(textBoxDozen.Text);
            }
            catch
            {
                MessageBox.Show("Please enter a valid number of dozens.");
                textBoxDozen.Focus();
                return;
            }

            //add
            if (sol_Agency != null &&
                sol_Agency.AutoGenerateTagNumber &&
                buttonClicked == "&New"
                )
            {
                //update
                UpdateStagedContainer();
            }
            else
            {
                if (buttonClicked == "&New")
                {
                    /* I-InProgress; P-Picked S-Shipped D -Void "" = any */
                    sol_Stage = sol_Stage_Sp._SelectByTagNumberStatus(textBoxTagNumber.Text, "");   //I");
                    if (sol_Stage != null)
                    {
                        MessageBox.Show("Tag number already exists, try another one please.");
                        textBoxTagNumber.Focus();
                        controlWithFocus = textBoxTagNumber;
                        return;
                    }

                    AddStagedContanier();
                }
                else
                {
                    //update
                    UpdateStagedContainer();
                }
            }

            //view state
            EnableControls(false);

            EnableButtons("close");

            //for upon exit
            flagChange = false;

            sol_Agency = null;
        }