public void Clear()
 {
     //Grid.Rows.Dispose();
     txtDescription.Clear();
     txtRepID.Text       = String.Empty;
     txtDescription.Text = String.Empty;
     txtPassword.Text    = "";
     txtRepID.Text       = "";
 }
Example #2
0
        public void Clear()
        {
            txtName.Clear();
            txtOrderID.Clear();
            txtTeacher.Clear();
            txtStudent.Clear();
            oImprinting.ImprintItems.Clear();
            txtProductID.Clear();

            //ScannedItems.Items.Clear();
            txtEntryDate.Text = DateTime.Now.Date.ToString();
            Grid.DataBind();
        }
Example #3
0
        private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region txtOrderID
            if (sender == txtOrderID)
            {
                if (e.KeyCode.ToString() == "Return" || e.KeyCode.ToString() == "Tab")
                {
                    if (txtOrderID.Text.Trim() == "")
                    {
                        txtOrderID.Clear();
                        txtOrderID.Focus();
                        return;
                    }

                    Int32 OrderID;
                    try
                    {
                        OrderID = Convert.ToInt32(txtOrderID.Text);
                    }
                    catch (Exception ex)
                    {
                        Global.ShowNotifier(ex.Message);
                        Global.playSimpleSound(3);
                        txtOrderID.Clear();
                        txtOrderID.Focus();
                        return;
                    }

                    if (oImprinting.Find(OrderID, Global.CurrrentLine))
                    {
                        if (oImprinting.ImprintItems.Count == 0)
                        {
                            Global.ShowNotifier("This order does exist but has no items with this product type: " + Global.CurrrentLine);

                            txtOrderID.Clear();
                            txtOrderID.Focus();
                            return;
                        }

                        if (CompanyID != oImprinting.CompanyID)
                        {
                            Global.ShowNotifier("Different Order's Company/Season");
                            txtOrderID.Clear();
                            txtOrderID.Focus();
                            return;
                        }

                        txtTeacher.Text = oImprinting.Teacher;
                        txtStudent.Text = oImprinting.Student;


                        if (oImprinting.Imprinted)
                        {
                            Global.ShowNotifier("Order already printed");
                            //return;
                        }

                        this.ShowOrder();
                        txtOrderID.Enabled = false;
                        //txtBoxes.Enabled = false;
                        txtProductID.BackColor = Color.White;
                        txtProductID.Focus();
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Order not found...");
                        txtOrderID.Clear();
                        txtOrderID.Focus();
                        return;
                    }
                }
            }
            #endregion
            #region txtProductID
            if (sender == txtProductID)
            {
                if (e.KeyCode.ToString() == "F8")
                {
                    this.Grid.Focus();
                }

                if (e.KeyCode.ToString() == "F2")
                {
                    if (oImprinting.oProduct.View())
                    {
                        this.txtProductID.Text = oImprinting.oProduct.ID;
                        return;
                    }
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    txtDescription.Clear();
                    if (txtProductID.Text.ToUpper() == "DONE")
                    {
                        if (!oImprinting.IfDone())
                        {
                            Global.playSimpleSound(1);
                            txtDescription.Text = "You have products left";
                            Global.ShowNotifier(txtDescription.Text);
                            ActiveLeft();
                            txtProductID.Clear();
                            txtProductID.Focus();
                            return;
                        }

                        oImprinting.UpdateImprinted(true, Global.CurrrentLine);



                        Clear();
                        txtOrderID.Enabled = true;
                        txtOrderID.Focus();
                        return;
                    }

                    if (txtProductID.Text.ToUpper() == "ABORT")
                    {
                        Clear();
                        groupBox2.Focus();
                        txtOrderID.Enabled = true;
                        txtOrderID.Focus();
                        return;
                    }


                    Imprinting.ImprintItem oItem = oImprinting.GetItem(txtProductID.Text);
                    if (oItem == null)
                    {
                        oItem = oImprinting.GetItemTicket(txtProductID.Text);
                    }


                    if (oItem == null)
                    {
                        Global.playSimpleSound(2);
                        txtDescription.Text = "TICKET OR PRODUCT NOT IN ORDER";
                        Global.ShowNotifier(txtDescription.Text);
                        this.txtProductID.Clear();
                        this.txtProductID.Focus();
                        return;
                    }

                    txtProductID.Text = oItem.TicketID.ToString();
                    if (oItem.Printed)
                    {
                        Global.playSimpleSound(2);
                        txtDescription.Text = "TICKET ALREADY PRINTED";
                        Global.ShowNotifier(txtDescription.Text);

                        /*if (MessageBox.Show("Do you want reprint this Ticket?", "Re-print", MessageBoxButtons.YesNo, MessageBoxIcon.Warning,MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                         * {
                         *  oTicket.Find(Convert.ToInt32(txtProductID.Text));
                         *  frmTicket frm = new frmTicket(oTicket);
                         *  frm.Show();
                         *  if (!frm.Print())
                         *  {
                         *      Global.ShowNotifier("No Printed");
                         *      frm.Dispose();
                         *      return;
                         *  }
                         *  frm.Dispose();
                         *  oImprinting.ImprintItems[txtProductID.Text].Printed = true;
                         * }
                         * else*/
                        {
                            this.txtProductID.Clear();
                            this.txtProductID.Focus();
                            return;
                        }
                    }
                    else
                    {
                        oTicket.Find(Convert.ToInt32(txtProductID.Text));
                        frmTicket frm = new frmTicket(oTicket);
                        frm.Show();
                        if (!frm.Print())
                        {
                            Global.ShowNotifier("No Printed");
                            frm.Dispose();
                            return;
                        }
                        frm.Dispose();
                        oImprinting.ImprintItems[txtProductID.Text].Printed = true;
                    }


                    if (oImprinting.ImprintItems.Contains(txtProductID.Text))
                    {
                        this.txtDescription.Text = oImprinting.ImprintItems[txtProductID.Text].Description;
                        if (oImprinting.ImprintItems[txtProductID.Text].Printed)
                        {
                            this.ActiveRow(true);
                        }
                        else
                        {
                            this.ActiveRow(false);
                        }

                        // Grid.DataBind();

                        this.txtProductID.Clear();
                        return;
                    }
                }
            }
            #endregion

            #region txtGrid
            if (sender == this.Grid)
            {
                //MessageBox.Show(e.KeyData.ToString());
                if (Char.IsDigit(Convert.ToChar(e.KeyValue)))
                {
                    txtProductID.Focus();
                    txtProductID.Text += Convert.ToChar(e.KeyValue).ToString();
                    SendKeys.Send("{END}");
                    return;
                }

                if (e.KeyCode.ToString() == "F8")
                {
                    this.txtProductID.Focus();
                    return;
                }
                if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.PageDown)
                {
                    //return;
                }
            }

            #endregion
            #region Default Option
            //Default option
            switch (e.KeyCode)
            {
            case Keys.Tab:
                if (!e.Shift)
                {
                    this.SelectNextControl(this.ActiveControl, true, true, true, true);
                }
                break;

            case Keys.Enter:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Down:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Up:
                this.SelectNextControl(this.ActiveControl, false, true, true, true);
                break;

            case Keys.F8:
                this.Grid.Focus();
                break;

            case Keys.F3:
                break;

            case Keys.PageDown:

                break;


                //case Keys.<some key>:
                // ......;
                // break;
            }
            #endregion
        }
        private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region txtOrderID
            if (sender == txtOrderID)
            {
                if (e.KeyCode.ToString() == "Return" || e.KeyCode.ToString() == "Tab")
                {
                    if (txtOrderID.Text.Trim() == "")
                    {
                        txtOrderID.Clear();
                        txtOrderID.Focus();
                        return;
                    }

                    int split = txtOrderID.Text.IndexOf('.');
                    if (split > -1)
                    {
                        txtOrderID.Text = txtOrderID.Text.Substring(0, split).Trim();
                    }

                    Int32 OrderID;
                    try
                    {
                        OrderID = Convert.ToInt32(txtOrderID.Text);
                    }
                    catch (Exception ex)
                    {
                        Global.ShowNotifier(ex.Message);
                        Global.playSimpleSound(3);
                        txtOrderID.Clear();
                        txtOrderID.Focus();
                        return;
                    }
                    if (oPacking.Find(OrderID, Global.CurrrentLine))
                    {
                        if (oPacking.ScanItems.Count == 0)
                        {
                            MessageBox.Show("This order does exist but has no items with this product type: " + Global.CurrrentLine);
                            txtOrderID.Clear();
                            txtOrderID.Focus();
                            return;
                        }

                        if (CompanyID != oPacking.CompanyID)
                        {
                            MessageBox.Show("Different Order's Company/Season");
                            txtOrderID.Clear();
                            txtOrderID.Focus();
                            return;
                        }

                        txtTeacher.Text = oPacking.Teacher;
                        txtStudent.Text = oPacking.Student;

                        Order.PackByOrder oOB = new Order.PackByOrder();
                        if (oOB.Find(Convert.ToInt32(txtOrderID.Text), Global.CurrrentLine))
                        {
                            if (oOB.Packed) //  (oPacking.Packed)
                            {
                                MessageBox.Show("Order already packed by " + oOB.Packer + "   " + oOB.BoxesPacked.ToString() + " boxes");
                                txtBoxes.Enabled = true;
                                txtBoxes.Text    = oOB.BoxesPacked.ToString();
                                txtBoxes.Focus();
                                return;
                            }
                        }

                        /*
                         * if (oPacking.Packed)
                         * {
                         *  MessageBox.Show("Order already packed by " + oPacking.Packer + "   " + oPacking.BoxesPacked.ToString()+" boxes");
                         *  txtBoxes.Enabled = true;
                         *  txtBoxes.Text = oPacking.BoxesPacked.ToString();
                         *  txtBoxes.Focus();
                         *
                         *  return;
                         * }
                         */
                        this.ShowOrder();
                        txtOrderID.Enabled     = false;
                        txtBoxes.Enabled       = false;
                        txtProductID.BackColor = Color.White;
                        txtProductID.Focus();
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Order not found...");
                        txtOrderID.Clear();
                        txtOrderID.Focus();
                        return;
                    }
                }
            }
            #endregion
            #region txtProductID
            if (sender == txtProductID)
            {
                if (e.KeyCode.ToString() == "F8")
                {
                    this.Grid.Focus();
                }


                if (e.KeyCode.ToString() == "F2")
                {
                    if (oPacking.oProduct.View())
                    {
                        this.txtProductID.Text = oPacking.oProduct.ID;
                        return;
                    }
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    txtDescription.Clear();
                    if (txtProductID.Text.ToUpper() == "DONE")
                    {
                        if (!oPacking.IfDone())
                        {
                            Global.playSimpleSound(1);
                            txtDescription.Text = "You have products left";
                            ActiveLeft();
                            txtProductID.Clear();
                            txtProductID.Focus();
                            return;
                        }
                        txtBoxes.Clear();
                        txtBoxes.Enabled = true;
                        txtBoxes.Focus();
                        //txtOrderID.Enabled = true;
                        return;
                    }

                    if (txtProductID.Text.ToUpper() == "ABORT")
                    {
                        Clear();
                        groupBox2.Focus();
                        txtOrderID.Enabled = true;
                        txtOrderID.Focus();
                        return;
                    }
BarCode_2:
                    if (txtProductID.Text.Length < 12)
                    {
                        if (!oPacking.ScanItems.Contains(txtProductID.Text))
                        {
                            txtProductID.Text = oPacking.GetItem(txtProductID.Text);
                            if (txtProductID.Text == "")
                            {
                                Global.playSimpleSound(2);
                                txtDescription.Text = "PRODUCT NOT IN ORDER";
                                this.txtProductID.Clear();
                                this.txtProductID.Focus();
                                return;
                            }
                        }
                    }
                    //Check by Code



                    if (oPacking.ScanItems.Contains(txtProductID.Text))
                    {
                        if (oPacking.ScanItems[txtProductID.Text].Quantity < (oPacking.ScanItems[txtProductID.Text].Scanned + 1))
                        {
                            Global.playSimpleSound(3);
                            txtDescription.Text = "EXTRA PRODUCT !!!";
                            txtProductID.Clear();
                            return;
                        }

                        oPacking.ScanItems[txtProductID.Text].Scanned += 1;
                        //if (oPacking.ScanItems[txtProductID.Text].Scanned == oPacking.ScanItems[txtProductID.Text].Quantity)
                        //    DeleteRow();

                        this.txtDescription.Text = oPacking.ScanItems[txtProductID.Text].Description;
                        //this.ScannedItems.Text = oPacking.ScanItems[txtProductID.Text].ProductID + " - " + oPacking.ScanItems[txtProductID.Text].Description;
                        //this.ScannedItems.Items.Add(oPacking.ScanItems[txtProductID.Text].ProductID + " - " + oPacking.ScanItems[txtProductID.Text].Description);
                        if (oPacking.ScanItems[txtProductID.Text].Scanned == oPacking.ScanItems[txtProductID.Text].Quantity)
                        {
                            //oPacking.ScanItems[txtProductID.Text].Packed = "";
                            this.ActiveRow(true);
                        }
                        else
                        {
                            this.ActiveRow(false);
                        }

                        // Grid.DataBind();

                        this.txtProductID.Clear();
                        //this.txtDescription.Text = ""; //


                        return;
                    }
                    else
                    {
                        String Barcode2 = oPacking.GetSecondaryBarcode(txtProductID.Text);
                        if (Barcode2 != "")
                        {
                            txtProductID.Text = Barcode2;
                            goto BarCode_2;
                        }

                        Global.playSimpleSound(5);
                        txtDescription.Text = "PRODUCT NOT IN ORDER";
                        this.txtProductID.Clear();
                        this.txtProductID.Focus();
                        return;
                    }
                }
            }
            #endregion
            #region txtBoxes
            if (sender == txtBoxes)
            {
                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtBoxes.Text == "")
                    {
                        txtBoxes.Focus();
                        return;
                    }
                    if (txtBoxes.Text.ToUpper() == "DONE" || txtBoxes.Text.ToUpper() == "ONE")
                    {
                        txtBoxes.Text = "1";
                    }

                    try
                    {
                        oPacking.BoxesPacked = Convert.ToInt16(txtBoxes.Text);
                        //oPacking.Lines[Global.CurrrentLine].BoxesPacked = Convert.ToInt16(txtBoxes.Text);
                    }
                    catch
                    {
                        txtBoxes.Text = "";
                        txtBoxes.Focus();
                        return;
                    }

                    oPacking.UpdatePacked(true, Global.CurrrentLine);

                    PrintTitle();

                    Clear();
                    txtBoxes.Enabled   = false;
                    txtOrderID.Enabled = true;
                    txtOrderID.Focus();

                    return;
                }
            }
            #endregion
            #region txtGrid
            if (sender == this.Grid)
            {
                //MessageBox.Show(e.KeyData.ToString());
                if (Char.IsDigit(Convert.ToChar(e.KeyValue)))
                {
                    txtProductID.Focus();
                    txtProductID.Text += Convert.ToChar(e.KeyValue).ToString();
                    SendKeys.Send("{END}");
                    return;
                }

                if (e.KeyCode.ToString() == "F8")
                {
                    this.txtProductID.Focus();
                    return;
                }
                if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.PageDown)
                {
                    //return;
                }
            }

            #endregion
            #region Default Option
            //Default option
            switch (e.KeyCode)
            {
            case Keys.Tab:
                if (!e.Shift)
                {
                    this.SelectNextControl(this.ActiveControl, true, true, true, true);
                }
                break;

            case Keys.Enter:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Down:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Up:
                this.SelectNextControl(this.ActiveControl, false, true, true, true);
                break;

            case Keys.F8:
                this.Grid.Focus();
                break;

            case Keys.F3:
                break;

            case Keys.PageDown:

                break;


                //case Keys.<some key>:
                // ......;
                // break;
            }
            #endregion
        }
        private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region txtOrderID
            if (sender == txtOrderID)
            {
                if (e.KeyCode.ToString() == "Return" || e.KeyCode.ToString() == "Tab")
                {
                    if (txtOrderID.Text.Trim() == "")
                    {
                        txtOrderID.Clear();
                        txtOrderID.Focus();
                        return;
                    }

                    if (oOrder.Find(Convert.ToInt32(txtOrderID.Text)))
                    {
                        if (CompanyID != oOrder.CompanyID)
                        {
                            MessageBox.Show("Different Order's Company/Season");
                            txtOrderID.Clear();
                            txtOrderID.Focus();
                            return;
                        }

                        txtTeacher.Text = oOrder.Teacher;
                        txtStudent.Text = oOrder.Student;
                        this.ShowOrder(Convert.ToInt32(txtOrderID.Text));

                        if (oOrder.Packed)
                        {
                            MessageBox.Show("Order already packed " + oOrder.BoxesPacked.ToString() + " boxes");
                            txtBoxes.Enabled = true;
                            txtBoxes.Text    = oOrder.BoxesPacked.ToString();
                            txtBoxes.Focus();

                            /* Clear();
                             * txtOrderID.Clear();
                             * txtOrderID.Focus();*/
                            return;
                        }


                        txtOrderID.Enabled = false;
                        txtBoxes.Enabled   = false;
                        txtProductID.Focus();
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Order not found...");
                        txtOrderID.Clear();
                        txtOrderID.Focus();
                        return;
                    }
                }
            }
            #endregion
            #region txtProductID
            if (sender == txtProductID)
            {
                if (e.KeyCode.ToString() == "F8")
                {
                    this.Grid.Focus();
                }


                if (e.KeyCode.ToString() == "F2")
                {
                    if (oOrder.oProduct.View())
                    {
                        this.txtProductID.Text = oOrder.oProduct.ID;
                        return;
                    }
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    txtDescription.Clear();
                    if (txtProductID.Text.ToUpper() == "DONE")
                    {
                        if (!oOrder.IfDone())
                        {
                            Global.playSimpleSound(1);
                            txtDescription.Text = "You have products left";
                            ActiveLeft();
                            txtProductID.Clear();
                            txtProductID.Focus();
                            return;
                        }
                        txtBoxes.Clear();
                        txtBoxes.Enabled = true;
                        txtBoxes.Focus();
                        //txtOrderID.Enabled = true;
                        return;
                    }

                    if (txtProductID.Text.ToUpper() == "ABORT")
                    {
                        Clear();
                        groupBox2.Focus();
                        txtOrderID.Enabled = true;
                        txtOrderID.Focus();
                        return;
                    }
BarCode_2:
                    if (txtProductID.Text.Length < 12)
                    {
                        txtProductID.Text = oOrder.GetItem(txtProductID.Text);
                        if (txtProductID.Text == "")
                        {
                            Global.playSimpleSound(2);
                            txtDescription.Text = "PRODUCT NOT IN ORDER";
                            this.txtProductID.Clear();
                            this.txtProductID.Focus();
                            return;
                        }
                    }
                    //Check by Code



                    if (oOrder.ScanItems.Contains(txtProductID.Text))
                    {
                        if (oOrder.ScanItems[txtProductID.Text].Quantity < (oOrder.ScanItems[txtProductID.Text].Scanned + 1))
                        {
                            Global.playSimpleSound(3);
                            txtDescription.Text = "EXTRA PRODUCT !!!";
                            txtProductID.Clear();
                            return;
                        }

                        oOrder.ScanItems[txtProductID.Text].Scanned += 1;
                        //if (oOrder.ScanItems[txtProductID.Text].Scanned == oOrder.ScanItems[txtProductID.Text].Quantity)
                        //    DeleteRow();

                        this.txtDescription.Text = oOrder.ScanItems[txtProductID.Text].Description;
                        //this.ScannedItems.Text = oOrder.ScanItems[txtProductID.Text].ProductID + " - " + oOrder.ScanItems[txtProductID.Text].Description;
                        //this.ScannedItems.Items.Add(oOrder.ScanItems[txtProductID.Text].ProductID + " - " + oOrder.ScanItems[txtProductID.Text].Description);
                        if (oOrder.ScanItems[txtProductID.Text].Scanned == oOrder.ScanItems[txtProductID.Text].Quantity)
                        {
                            //oOrder.ScanItems[txtProductID.Text].Packed = "";
                            this.ActiveRow(true);
                        }
                        else
                        {
                            this.ActiveRow(false);
                        }

                        Grid.DataBind();

                        this.txtProductID.Clear();
                        //this.txtDescription.Text = ""; //


                        return;
                    }
                    else
                    {
                        String Barcode2 = oOrder.GetSecondaryBarcode(txtProductID.Text);
                        if (Barcode2 != "")
                        {
                            txtProductID.Text = Barcode2;
                            goto BarCode_2;
                        }

                        Global.playSimpleSound(5);
                        txtDescription.Text = "PRODUCT NOT IN ORDER";
                        this.txtProductID.Clear();
                        this.txtProductID.Focus();
                        return;
                    }
                }
            }
            #endregion
            #region txtBoxes
            if (sender == txtBoxes)
            {
                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtBoxes.Text == "")
                    {
                        txtBoxes.Focus();
                        return;
                    }
                    if (txtBoxes.Text.ToUpper() == "DONE" || txtBoxes.Text.ToUpper() == "ONE")
                    {
                        txtBoxes.Text = "1";
                    }

                    oOrder.BoxesPacked = Convert.ToInt16(txtBoxes.Text);
                    oOrder.UpdatePacked(true);

                    Clear();
                    txtBoxes.Enabled   = false;
                    txtOrderID.Enabled = true;
                    txtOrderID.Focus();
                    return;
                }
            }
            #endregion
            #region txtGrid
            if (sender == this.Grid)
            {
                if (e.KeyCode.ToString() == "F8")
                {
                    this.txtProductID.Focus();
                    return;
                }
                if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.PageDown)
                {
                    //return;
                }
            }

            #endregion
            #region Default Option
            //Default option
            switch (e.KeyCode)
            {
            case Keys.Tab:
                if (!e.Shift)
                {
                    this.SelectNextControl(this.ActiveControl, true, true, true, true);
                }
                break;

            case Keys.Enter:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Down:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Up:
                this.SelectNextControl(this.ActiveControl, false, true, true, true);
                break;

            case Keys.F8:
                this.Grid.Focus();
                break;

            case Keys.F3:
                break;

            case Keys.PageDown:

                break;


                //case Keys.<some key>:
                // ......;
                // break;
            }
            #endregion
        }