Beispiel #1
0
        public static void GridNavigation(UltraGrid grid, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Up:
                grid.PerformAction(UltraGridAction.ExitEditMode, false, false);
                grid.PerformAction(UltraGridAction.AboveCell, false, false);
                e.Handled = true;
                grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                break;

            case Keys.Down:
                grid.PerformAction(UltraGridAction.ExitEditMode, false, false);
                grid.PerformAction(UltraGridAction.BelowCell, false, false);
                e.Handled = true;
                grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                break;

            case Keys.Enter:
                grid.PerformAction(UltraGridAction.ExitEditMode, false, false);
                grid.PerformAction(UltraGridAction.BelowCell, false, false);
                e.Handled = true;
                grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                break;
            }
        }
Beispiel #2
0
        private void gKits_MouseUp(object sender, MouseEventArgs e)
        {
            //' declare objects to get value from cell and display
            Infragistics.Win.UIElement mouseupUIElement;
            Infragistics.Win.UltraWinGrid.UltraGridCell mouseupCell;

            if (e.Button == MouseButtons.Right || e.Button == MouseButtons.Left)
            {
                //' retrieve the UIElement from the location of the MouseUp
                mouseupUIElement = gKits.DisplayLayout.UIElement.ElementFromPoint(new Point(e.X, e.Y));

                //' retrieve the Cell from the UIElement
                mouseupCell = mouseupUIElement.GetContext(typeof(Infragistics.Win.UltraWinGrid.UltraGridCell))
                              as Infragistics.Win.UltraWinGrid.UltraGridCell;;

                //' if there is a cell object reference, set to active cell and edit
                if (!(mouseupCell == null))
                {
                    UltraGridRow aUGRow;
                    gKits.ActiveCell = mouseupCell;

                    aUGRow           = gKits.ActiveCell.Row;
                    gKits.ActiveRow  = aUGRow;
                    gKits.ActiveCell = aUGRow.Cells["Quantity"];


                    gKits.PerformAction(UltraGridAction.EnterEditMode, false, false);
                }
            }
        }
Beispiel #3
0
        private void dgvArticulos_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                UltraGrid     grid       = sender as UltraGrid;
                UltraGridCell activeCell = grid == null ? null : grid.ActiveCell;

                // if there is an active cell, its not in edit mode and can enter edit mode
                if (null != activeCell && false == activeCell.IsInEditMode && activeCell.CanEnterEditMode)
                {
                    // if the character is not a control character
                    if (char.IsControl(e.KeyChar) == false)
                    {
                        // try to put cell into edit mode
                        grid.PerformAction(UltraGridAction.EnterEditMode);

                        // if this cell is still active and it is in edit mode...
                        if (grid.ActiveCell == activeCell && activeCell.IsInEditMode)
                        {
                            // get its editor
                            EmbeddableEditorBase editor = activeCell.EditorResolved;

                            // if the editor supports selectable text
                            if (editor.SupportsSelectableText)
                            {
                                // select all the text so it can be replaced
                                editor.SelectionStart  = 0;
                                editor.SelectionLength = editor.TextLength;

                                if (editor is EditorWithMask)
                                {
                                    // just clear the selected text and let the grid
                                    // forward the keypress to the editor
                                    editor.SelectedText = string.Empty;
                                }
                                else
                                {
                                    // then replace the selected text with the character
                                    editor.SelectedText = new string(e.KeyChar, 1);

                                    // mark the event as handled so the grid doesn't process it
                                    e.Handled = true;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Beispiel #4
0
        public static void SetUltraGridActiveCell(ref UltraGrid ultraGrid, int RowIndexNo, string ColumnName, bool EnterEditMode)
        {
            try
            {
                if (ultraGrid != null && RowIndexNo >= 0 && ultraGrid.Rows.Count >= RowIndexNo + 1)
                {
                    ultraGrid.ActiveCell = ultraGrid.Rows[RowIndexNo].Cells[ColumnName];

                    if (EnterEditMode)
                    {
                        ultraGrid.PerformAction(UltraGridAction.EnterEditMode);
                    }
                }
            }
            catch { }
        }
 protected void InsertRow(UltraGrid grid, string column1 = null, string column2 = null)
 {
     try
     {
         var row = grid.DisplayLayout.Bands[0].AddNew();
         var stt = grid.Rows.Count;
         if (column1 != null)
         {
             row.Cells[column1].Value = stt;
         }
         if (column2 == null)
         {
             return;
         }
         row.Cells[column2].Activate();
         grid.PerformAction(UltraGridAction.EnterEditMode);
     }
     catch (Exception ex)
     {
         Log2File.LogExceptionToFile(ex);
     }
 }
        private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region Grid
            if (sender == Grid)
            {
                if (Grid.ActiveCell != null)
                {
                    switch (Grid.ActiveCell.Column.Key)
                    {
                    case "Received":

                        if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Down || e.KeyCode == Keys.Tab)
                        {
                            Grid.PerformAction(UltraGridAction.NextRowByTab, false, false);
                            Grid.ActiveCell = Grid.ActiveRow.Cells["Received"];
                            Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                        }
                        if (e.KeyCode == Keys.Up)
                        {
                            Grid.PerformAction(UltraGridAction.PrevRowByTab, false, false);
                            Grid.ActiveCell = Grid.ActiveRow.Cells["Received"];
                            Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                        }

                        break;
                    }
                }
                return;
            }
            #endregion

            #region txtOrderID
            if (sender == txtOrderID)
            {
                if (e.KeyCode == Keys.F2)
                {
                    if (oPurchase.View(true))
                    {
                        oReceive.FindPurchase(oPurchase.ID);
                        txtOrderID.Text  = oReceive.ID;
                        txtVendorID.Text = oReceive.VendID;
                        oVendor.Find(oReceive.VendID);
                        txtName.Text = oVendor.Name;


                        if (oReceive.RItems.Count > 0)
                        {
                            Grid.DataSource = oReceive.RItems;
                            Grid.DataBind();
                            MoveFirst();
                            txtOrderID.Enabled = false;
                        }
                        else
                        {
                            MessageBox.Show("This PO was already received...");
                        }
                        return;
                    }
                    this.txtName.Text = oVendor.Name;
                    return;
                }
                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtOrderID.Text.Trim() == "")
                    {
                        txtOrderID.Clear();
                        txtOrderID.Focus();
                        return;
                    }

                    if (oReceive.FindPurchase(txtOrderID.Text))
                    {
                        txtVendorID.Enabled = true;

                        txtVendorID.Text = oReceive.VendID;
                        oVendor.Find(oReceive.VendID);
                        txtName.Text = oVendor.Name;

                        Grid.DataSource = oReceive.Items;
                        MoveFirst();

                        txtOrderID.Enabled = false;
                        return;
                    }
                    else
                    {
                        txtVendorID.Enabled = true;
                        txtVendorID.Focus();

                        return;
                    }
                }
            }
            #endregion

            #region txtVendorID
            if (sender == txtVendorID)
            {
                if (e.KeyCode.ToString() == "F2")
                {
                    if (oVendor.View())
                    {
                        this.txtVendorID.Text = oVendor.ID;
                        if (!oVendor.Find(txtVendorID.Text))
                        {
                            this.txtVendorID.Focus();
                            return;
                        }
                        this.txtName.Text = oVendor.Name;
                        Grid.Focus();
                        return;
                    }
                    this.txtName.Text = oVendor.Name;
                }
                if (e.KeyCode.ToString() == "Return" || e.KeyCode.ToString() == "Tab")
                {
                    if (!oVendor.Find(txtVendorID.Text))
                    {
                        this.txtVendorID.Focus();
                        return;
                    }
                    this.txtName.Text = oVendor.Name;

                    //Grid.DataSource = oVendor.ReOrders.GetDataTable(oVendor);
                    Grid.Focus();
                    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.F3:
                Delete();
                break;

            case Keys.PageDown:
                break;


                //case Keys.<some key>:
                // ......;
                // break;
            }
            #endregion
        }
Beispiel #7
0
        public static void SetUltraGridActiveCell(ref UltraGrid ultraGrid, int RowIndexNo, string ColumnName, bool EnterEditMode)
        {
            try
            {
                if (ultraGrid != null && RowIndexNo >= 0 && ultraGrid.Rows.Count >= RowIndexNo + 1)
                {
                    ultraGrid.ActiveCell = ultraGrid.Rows[RowIndexNo].Cells[ColumnName];

                    if (EnterEditMode)
                        ultraGrid.PerformAction(UltraGridAction.EnterEditMode);
                }
            }
            catch { }
        }
Beispiel #8
0
        public void Grid_KeyDown(Object sender, KeyEventArgs e)
        {
            UltraGrid Grid = (UltraGrid)sender;

            switch (e.KeyCode)
            {
            case Keys.Up:
                Grid.PerformAction(UltraGridAction.ExitEditMode, false, false);
                Grid.PerformAction(UltraGridAction.AboveCell, false, false);
                e.Handled = true;
                Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                break;

            case Keys.Down:
                Grid.PerformAction(UltraGridAction.ExitEditMode, false, false);
                Grid.PerformAction(UltraGridAction.BelowCell, false, false);
                e.Handled = true;
                Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                break;

            case Keys.Right:
                Grid.PerformAction(UltraGridAction.ExitEditMode, false, false);
                Grid.PerformAction(UltraGridAction.NextCell, false, false);
                e.Handled = true;
                Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                break;

            case Keys.Left:
                Grid.PerformAction(UltraGridAction.ExitEditMode, false, false);
                Grid.PerformAction(UltraGridAction.PrevCell, false, false);
                e.Handled = true;
                Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                break;

            case Keys.Enter:
                Type       TypeInfo   = this.GetType();
                Object[]   Args       = { Grid.ActiveCell };
                MethodInfo MethodInfo = TypeInfo.GetMethod(String.Format("{0}_CellKeyEnter", Grid.Name));
                if (MethodInfo != null)
                {
                    MethodInfo.Invoke(this, Args);
                }
                Grid.PerformAction(UltraGridAction.ExitEditMode, false, false);
                Grid.PerformAction(UltraGridAction.NextCell, false, false);
                e.Handled = true;
                Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                break;

            case Keys.Escape:
                break;
            }
        }
        private void txtControl_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region txtSearch
            if (sender == txtSearch)
            {
                if (e.KeyCode == Keys.Tab)
                {
                    Grid.Focus();
                    return;
                }
                if (e.KeyCode == Keys.Enter)
                {
                    if (Grid.Rows.Count > 0)
                    {
                        UltraGridRow aUGRow = Grid.Rows[0];
                        Grid.ActiveRow = aUGRow;
                        if (Grid.ActiveRow != null)
                        {
                            sSelectedID = Grid.ActiveRow.Cells["ID"].Text;
                        }
                        this.Close();
                    }
                    else
                    {
                        this.Close();
                    }

                    return;
                }
            }
            #endregion

            #region Grid
            if (sender == Grid)
            {
                if (e.KeyCode == Keys.Tab)
                {
                    txtSearch.Focus();
                    return;
                }
                if (e.KeyCode == Keys.Enter)
                {
                    if (Grid.Rows.Count > 0)
                    {
                        if (Grid.ActiveRow != null)
                        {
                            sSelectedID = Grid.ActiveRow.Cells["ID"].Text;
                        }
                        this.Close();
                    }

                    return;
                }
            }
            #endregion

            #region Default Option
            //Default option
            switch (e.KeyCode)
            {
            case Keys.Up:
                if (Grid.Focused)
                {
                    if (Grid.Rows.Count == 0)
                    {
                    }
                    else if (Grid.ActiveRow == Grid.Rows[0])
                    {
                        txtSearch.Focus();
                    }
                    else
                    {
                        Grid.PerformAction(UltraGridAction.AboveCell, false, false);
                    }
                }
                e.Handled = true;
                break;

            case Keys.Down:
                if (txtSearch.Focused && Grid.Rows.Count > 0)
                {
                    Grid.Focus();
                }
                Grid.PerformAction(UltraGridAction.BelowCell, false, false);
                e.Handled = true;

                break;

            case Keys.Right:
                //UltraGrid1.PerformAction(ExitEditMode, False, False)
                Grid.PerformAction(UltraGridAction.NextCellByTab, false, false);
                e.Handled = true;
                //UltraGrid1.PerformAction(EnterEditMode, False, False)
                break;

            case Keys.Left:
                //UltraGrid1.PerformAction(ExitEditMode, False, False)
                Grid.PerformAction(UltraGridAction.PrevCellByTab, false, false);
                e.Handled = true;
                //UltraGrid1.PerformAction(EnterEditMode, False, False)
                break;

            case Keys.Enter:
                DataGrid_MouseUp(null, null);
                e.Handled = true;
                break;
            }
            #endregion
        }
        private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region txtPrizeID
            if (sender == txtPrizeID)
            {
                if (e.KeyCode == Keys.PageDown || e.KeyCode == Keys.F3)
                {
                    return;
                }


                if (e.KeyCode.ToString() == "F2")
                {
                    if (oPrize.View())
                    {
                        ShowPrize();
                        txtDescription.Focus();
                        Grid.DataSource = oPrize.Items.dtItems;
                        Grid.DataBind();
                        Grid.Focus();
                        MoveLast();
                        return;
                    }
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtPrizeID.Text.Trim().Length == 0)
                    {
                        Clear();
                        txtPrizeID.Focus();
                    }

                    if (oPrize.Find(txtPrizeID.Text))
                    {
                        txtDescription.Text = oPrize.Description;
                        Grid.DataSource     = oPrize.Items.dtItems;
                        Grid.DataBind();
                        Grid.Focus();
                        MoveLast();
                    }
                    else
                    {
                        Clear();
                        oPrize.Items.dtItems.Rows.Clear();
                        oPrize.ID = txtPrizeID.Text;
                        oPrize.Items.AddEmpty();
                        Grid.DataSource = oPrize.Items.dtItems;
                        Grid.DataBind();
                        txtDescription.Focus();
                    }


                    return;
                }
            }
            #endregion
            #region Grid

            if (sender == Grid)
            {
                if (e.KeyCode == Keys.F2)
                {
                    UltraGridRow gridRow;
                    gridRow = Grid.ActiveRow;
                    if (gridRow != null)
                    {
                        if (Grid.ActiveRow.Cells["ProductID"] == Grid.ActiveCell)
                        {
                            if (oProduct.View())
                            {
                                if (!oPrize.Items.Contains(Grid.ActiveRow.Cells["ProductID"].Text))
                                {
                                    Grid.ActiveRow.Cells["ProductID"].Value   = oProduct.ID;
                                    Grid.ActiveRow.Cells["Description"].Value = oProduct.Description;
                                    Grid.ActiveRow.Cells["Amount"].Activate();
                                    Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                                    return;
                                }
                                else
                                {
                                    MessageBox.Show("Item already entered");
                                    Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"];
                                    Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                                    return;
                                }
                            }
                        }
                    }
                }


                if (e.KeyCode == Keys.Delete)
                {
                }


                if (e.KeyCode == Keys.Enter)
                {
                    Infragistics.Win.UltraWinGrid.UltraGridRow gridRow;
                    gridRow = Grid.ActiveRow;
                    if (gridRow != null)
                    {
                        if (Grid.ActiveRow.Cells["ProductID"] == Grid.ActiveCell)
                        {
                            if (oProduct.Find(Grid.ActiveRow.Cells["ProductID"].Text))
                            {
                                if (!Contain(Grid.ActiveRow.Cells["ProductID"].Text))
                                {
                                    Grid.ActiveRow.Cells["ProductID"].Value   = oProduct.ID;
                                    Grid.ActiveRow.Cells["Description"].Value = oProduct.Description;
                                    Grid.ActiveRow.Cells["BreakLevel"].Activate();
                                    Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                                    return;
                                }
                                else
                                {
                                    MessageBox.Show("Item already entered");
                                    Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"];
                                    Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                                    return;
                                }
                            }
                            return;
                        }
                        if (Grid.ActiveRow.Cells["Amount"] == Grid.ActiveCell)
                        {
                            gridRow = gridRow.GetSibling(Infragistics.Win.UltraWinGrid.SiblingRow.Next);
                            if (gridRow != null)
                            {
                                MoveDown();
                                return;
                            }
                            else   //if (Grid.ActiveRow.Cells["ProductID"].Text && Grid.ActiveRow.Cells["0"].Text)
                            {
                                if (Grid.ActiveRow.Cells["ProductID"].Text != "" && !Contain(Grid.ActiveRow.Cells["ProductID"].Text))
                                {
                                    if (Grid.GetRow(ChildRow.Last) == Grid.ActiveRow)
                                    {
                                        oPrize.Items.AddEmpty();
                                        Grid.DataBind();
                                        MoveLast();
                                        //Grid.PerformAction(UltraGridAction.LastRowInBand, false, false);
                                    }
                                    else
                                    {
                                        Grid.PerformAction(UltraGridAction.NextRowByTab, false, false);
                                        Grid.ActiveRow.Cells["ProductID"].Activate();
                                        Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                                    }
                                }
                                else
                                {
                                    Grid.ActiveRow.Cells["ProductID"].Activate();
                                    Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                                    Grid.ActiveRow.Cells["BreakLevel"].Value = 0;
                                    Grid.ActiveRow.Cells["Amount"].Value     = 0;
                                }
                                return;
                            }
                        }

                        if (Grid.ActiveRow.Cells["BreakLevel"] == Grid.ActiveCell)
                        {
                            Grid.PerformAction(UltraGridAction.NextRowByTab, false, false);
                            Grid.ActiveRow.Cells["Amount"].Activate();
                            Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                            return;
                        }

                        if (Grid.ActiveRow.Cells["Quantity"] == Grid.ActiveCell)
                        {
                            Grid.PerformAction(UltraGridAction.NextRowByTab, false, false);
                            Grid.ActiveRow.Cells["ProductID"].Activate();
                            Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                            return;
                        }
                    }
                }

                if (e.KeyCode == Keys.Down)
                {
                    MoveDown();
                    return;
                }
                if (e.KeyCode == Keys.Up)
                {
                    Infragistics.Win.UltraWinGrid.UltraGridRow gridRow;
                    gridRow = Grid.ActiveRow;
                    gridRow = gridRow.GetSibling(Infragistics.Win.UltraWinGrid.SiblingRow.Previous);
                    if (gridRow != null)
                    {
                        gridRow.Activate();
                        //' set ActiveCell
                        Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"];
                        Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                    }
                    return;
                }
            }
            #endregion
            #region txtDescription
            if (sender == txtDescription)
            {
                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    oPrize.Description = txtDescription.Text;
                    txtProductTypeID.Focus();
                    MoveLast();
                    return;
                }
            }
            #endregion
            #region txtProductTypeID
            if (sender == txtProductTypeID)
            {
                if (e.KeyCode.ToString() == "F2")
                {
                    if (oPack.View())
                    {
                        txtProductTypeID.Text = oPack.ID;
                        txtPTDescription.Text = oPack.Description;
                    }
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtProductTypeID.Text.Trim().Length == 0)
                    {
                        txtProductTypeID.Focus();
                    }

                    if (oPack.Find(txtProductTypeID.Text))
                    {
                        txtProductTypeID.Text = oPack.ID;
                        txtPTDescription.Text = oPack.Description;
                    }
                    Grid.Focus();
                    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.F3:
                oPrize.Delete();
                Clear();
                oPrize.Items.dtItems.Rows.Clear();
                Grid.DataBind();
                txtPrizeID.Clear();
                txtPrizeID.Focus();
                break;

            case Keys.PageDown:
                this.Save();
                //oPrize.Description = txtDescription.Text;
                //oPrize.Save();
                Grid.DataBind();
                Clear();
                txtPrizeID.Clear();
                txtPrizeID.Focus();
                break;

            case Keys.Delete:
                if (e.Control)
                {
                    DeleteItem();
                }
                break;

                //case Keys.<some key>:
                // ......;
                // break;
            }
            #endregion
        }
        private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region gKits

            if (sender == gKits)
            {
                if (e.KeyCode == Keys.F8)
                {
                    txtKitID.Focus();
                }
                if (e.KeyCode == Keys.F2)
                {
                    UltraGridRow gridRow;
                    gridRow = gKits.ActiveRow;
                    if (gridRow != null)
                    {
                        if (gKits.ActiveRow.Cells["KitID"] == gKits.ActiveCell)
                        {
                            if (oKit.View())
                            {
                                gKits.ActiveRow.Cells["KitID"].Value = oKit.ID;
                                gKits.ActiveRow.Cells["Name"].Value  = oKit.Description;
                                gKits.ActiveRow.Cells["Quantity"].Activate();
                                gKits.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                                //this.txtKitID.Text = oKit.ID;
                                //this.txtKitName.Text = oKit.Description;
                                //this.txtQuantity.Clear();
                                return;
                            }
                        }
                    }
                }


                if (e.KeyCode == Keys.Delete)
                {
                    //foreach(UltraGridRow rowSelected in gKits.Rows)
                    // MessageBox.Show(rowSelected.Index.ToString());

                    //MessageBox.Show("Delete");

                    //oCustomer.Kits.dtKits.Rows

                    // oCustomer.Kits.RemoveAt(0);
                }

                if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Enter)
                {
                    Infragistics.Win.UltraWinGrid.UltraGridRow gridRow;
                    gridRow = gKits.ActiveRow;
                    gridRow = gridRow.GetSibling(Infragistics.Win.UltraWinGrid.SiblingRow.Next);
                    if (gridRow != null)
                    {
                        gridRow.Activate();
                        //' set ActiveCell
                        gKits.ActiveCell = gKits.ActiveRow.Cells["Quantity"];
                        gKits.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                    }

                    //SendKeys.Send("{TAB}");
                }
                if (e.KeyCode == Keys.Up)
                {
                    Infragistics.Win.UltraWinGrid.UltraGridRow gridRow;
                    gridRow = gKits.ActiveRow;
                    gridRow = gridRow.GetSibling(Infragistics.Win.UltraWinGrid.SiblingRow.Previous);
                    if (gridRow != null)
                    {
                        gridRow.Activate();
                        //' set ActiveCell
                        gKits.ActiveCell = gKits.ActiveRow.Cells["Quantity"];
                        gKits.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                    }

                    //SendKeys.Send("{TAB}");
                }
                return;
            }
            #endregion
            #region txtCustomerID

            if (sender == txtCustomerID)
            {
                if (e.KeyCode.ToString() == "F2")
                {
                    if (oCustomer.View())
                    {
                        this.txtCustomerID.Text = oCustomer.ID;
                        this.txtName.Text       = oCustomer.Name;
                        gKits.DataSource        = oCustomer.Kits.GetDataTable(oCustomer);

                        txtKitID.Focus();

                        return;
                    }

                    this.txtName.Text = oCustomer.Name;
                    //txtKitID.Focus();
                    return;
                }
                if (e.KeyCode.ToString() == "Return" || e.KeyCode.ToString() == "Tab")
                {
                    if (!oCustomer.Find(txtCustomerID.Text))
                    {
                        this.txtCustomerID.Focus();
                        return;
                    }
                    this.txtName.Text = oCustomer.Name;
                    gKits.DataSource  = oCustomer.Kits.GetDataTable(oCustomer);


                    txtKitID.Focus();
                    return;
                }
            }
            #endregion
            #region txtKitID
            if (sender == txtKitID)
            {
                if (e.KeyCode.ToString() == "F8")
                {
                    this.gKits.Focus();
                }

                if (e.KeyCode.ToString() == "F2")
                {
                    if (oKit.View())
                    {
                        this.txtKitID.Text   = oKit.ID;
                        this.txtKitName.Text = oKit.Description;
                        this.txtQuantity.Clear();
                        this.txtQuantity.Focus();
                        return;
                    }
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (oKit.Find(txtKitID.Text))
                    {
                        this.txtKitID.Text   = oKit.ID;
                        this.txtKitName.Text = oKit.Description;
                        this.txtQuantity.Clear();
                        this.txtQuantity.Focus();
                        return;
                    }
                    else
                    {
                        this.txtKitID.Clear();
                        this.txtKitID.Focus();
                        return;
                    }
                }
                return;
            }
            #endregion
            #region txtQuantity
            if (sender == this.txtQuantity)
            {
                //MessageBox.Show(e.KeyCode.ToString());
                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (this.txtQuantity.Text != "")
                    {
                        //this.AddItem();


                        try
                        {
                            DataRow rowNew = oCustomer.Kits.dtKits.NewRow();
                            rowNew["KitID"]    = txtKitID.Text;
                            rowNew["Name"]     = oKit.Description;
                            rowNew["Quantity"] = txtQuantity.Text;
                            oCustomer.Kits.dtKits.Rows.Add(rowNew);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);     //"Unable to add new customer for given ID");
                        }

                        this.txtQuantity.Text = "";
                        this.txtKitID.Text    = "";
                        this.txtKitID.Focus();
                        return;
                    }
                    else
                    {
                        this.txtQuantity.Focus();
                        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.F3:
                deleteOrder();
                break;

            case Keys.PageDown:
                break;


                //case Keys.<some key>:
                // ......;
                // break;
            }
            #endregion
        }
        private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region txtAccountID
            if (sender == txtAccountID)
            {
                if (e.KeyCode == Keys.PageDown || e.KeyCode == Keys.F3)
                {
                    return;
                }


                if (e.KeyCode.ToString() == "F2")
                {
                    if (oeMail.View(this.DomainID))
                    {
                        txtAccountID.Text = oeMail.User;
                        ShowVendor();
                    }

                    if (txtAccountID.Text == "")
                    {
                        return;
                    }

                    txtDescription.Focus();
                    Grid.DataSource = oeMail.Items.dt;
                    Grid.DataBind();
                    Grid.Focus();
                    oeMail.Items.AddEmpty();
                    MoveLast();
                    return;
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtAccountID.Text.Trim().Length == 0)
                    {
                        Clear();
                        txtAccountID.Focus();
                    }

                    if (oeMail.Find(txtAccountID.Text))
                    {
                        txtAccountID.Text = oeMail.User;
                        ShowVendor();

                        Grid.DataSource = oeMail.Items.dt;
                        Grid.DataBind();
                        Grid.Focus();
                        oeMail.Items.AddEmpty();
                        MoveLast();
                    }
                    else
                    {
                        Clear();
                        oeMail.Items.AddEmpty();
                        Grid.DataSource = oeMail.Items.dt;
                        Grid.DataBind();
                        txtPassword.Focus();
                    }


                    return;
                }
            }
            #endregion
            #region txtDescription
            if (sender == txtDescription)
            {
                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    //oeMail..Description = txtDescription.Text;
                    Grid.Focus();
                    MoveLast();
                    return;
                }
            }
            #endregion
            #region Grid

            if (sender == Grid)
            {
                if (e.KeyCode == Keys.F2)
                {
                    UltraGridRow gridRow;
                    gridRow = Grid.ActiveRow;
                    if (gridRow != null)
                    {
                        if (Grid.ActiveRow.Cells["destination"] == Grid.ActiveCell)
                        {/*
                          * if (oRep.View())
                          * {
                          *     if (!Contain(Grid.ActiveRow.Cells["ProductID"].Text))
                          *     {
                          *
                          *         Grid.ActiveRow.Cells["ProductID"].Value = oRep.ID;
                          *         Grid.ActiveRow.Cells["InvCode"].Value = oRep.InvCode;
                          *         Grid.ActiveRow.Cells["Description"].Value = oRep.Description;
                          *         Grid.ActiveRow.Cells["Price"].Activate();
                          *         Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                          *         return;
                          *     }
                          *     else
                          *     {
                          *         MessageBox.Show("Item already entered");
                          *         Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"];
                          *         Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                          *         return;
                          *     }
                          * }
                          */
                        }
                    }
                }


                if (e.KeyCode == Keys.Delete)
                {
                }


                if (e.KeyCode == Keys.Enter)
                {
                    if (Grid.ActiveRow != null)
                    {
                        if (Grid.ActiveRow.Cells["destination"].Text != "" && !Contain(Grid.ActiveRow.Cells["destination"].Text))
                        {
                            if (Grid.ActiveRow.Cells["destination"] == Grid.ActiveCell)
                            {/*
                              *             if (oRep.Find(Grid.ActiveRow.Cells["ProductID"].Text))
                              *             {
                              *                 if (!Contain(Grid.ActiveRow.Cells["ProductID"].Text))
                              *                 {
                              *
                              *                     Grid.ActiveRow.Cells["ProductID"].Value = oRep.ID;
                              *                     Grid.ActiveRow.Cells["InvCode"].Value = oRep.InvCode;
                              *                     Grid.ActiveRow.Cells["Description"].Value = oRep.Description;
                              *                     Grid.ActiveRow.Cells["Price"].Activate();
                              *                     Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                              *                     return;
                              *                 }
                              *                 else
                              *                 {
                              *                     MessageBox.Show("Item already entered");
                              *                     Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"];
                              *                     Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                              *                     return;
                              *                 }
                              *             }
                              */
                            }

                            if (Grid.GetRow(ChildRow.Last) == Grid.ActiveRow)
                            {
                                oeMail.Items.AddEmpty();
                                Grid.DataBind();
                                MoveLast();
                                //Grid.PerformAction(UltraGridAction.LastRowInBand, false, false);
                            }
                            else
                            {
                                Grid.PerformAction(UltraGridAction.NextRowByTab, false, false);
                                Grid.ActiveRow.Cells["destination"].Activate();
                                Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                            }
                        }
                        else
                        {
                            Grid.ActiveRow.Cells["destination"].Activate();
                            Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                        }
                        return;
                    }
                }

                if (e.KeyCode == Keys.Down)
                {
                    MoveDown();
                    return;
                }
                if (e.KeyCode == Keys.Up)
                {
                    Infragistics.Win.UltraWinGrid.UltraGridRow gridRow;
                    gridRow = Grid.ActiveRow;
                    gridRow = gridRow.GetSibling(Infragistics.Win.UltraWinGrid.SiblingRow.Previous);
                    if (gridRow != null)
                    {
                        gridRow.Activate();
                        //' set ActiveCell
                        Grid.ActiveCell = Grid.ActiveRow.Cells["destination"];
                        Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                    }
                    return;
                    //SendKeys.Send("{TAB}");
                }
            }
            #endregion
            #region txtProductID
            if (sender == txtRepID)
            {
                if (e.KeyCode.ToString() == "F2")
                {
                    if (oRep.ViewByID())
                    {
                        txtRepID.Text       = oRep.ID.ToString();
                        txtDescription.Text = oRep.Name;
                    }
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtRepID.Text.Trim().Length == 0)
                    {
                        txtRepID.Focus();
                    }

                    if (oRep.Find(txtRepID.Text))
                    {
                        txtRepID.Text       = oRep.ID.ToString();
                        txtDescription.Text = oRep.Name;
                    }
                }
            }
            #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.F3:
                this.Delete();
                txtAccountID.Focus();
                break;

            case Keys.PageDown:
                this.Save();
                Grid.DataBind();
                Clear();
                txtAccountID.Clear();
                txtAccountID.Focus();
                break;

            case Keys.Delete:
                if (e.Control)
                {
                    DeleteItem();
                }
                break;
                //case Keys.<some key>:
                // ......;
                // break;
            }
            #endregion
        }
Beispiel #13
0
        private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region txtBrochureID
            if (sender == txtBrochureID)
            {
                if (e.KeyCode == Keys.PageDown || e.KeyCode == Keys.F3)
                {
                    return;
                }


                if (e.KeyCode.ToString() == "F2")
                {
                    if (oBrochure.View())
                    {
                        ShowVendor();
                    }

                    if (txtBrochureID.Text == "")
                    {
                        return;
                    }

                    txtDescription.Focus();
                    Grid.DataSource = oBrochure.Items.dtItems;
                    Grid.DataBind();
                    Grid.Focus();
                    MoveLast();
                    return;
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtBrochureID.Text.Trim().Length == 0)
                    {
                        Clear();
                        txtBrochureID.Focus();
                    }

                    if (oBrochure.Find(txtBrochureID.Text))
                    {
                        ShowVendor();
                        Grid.DataSource = oBrochure.Items.dtItems;
                        Grid.DataBind();
                        Grid.Focus();
                        MoveLast();
                    }
                    else
                    {
                        Clear();
                        oBrochure.ID = txtBrochureID.Text;
                        oBrochure.Items.AddEmpty();
                        Grid.DataSource = oBrochure.Items.dtItems;
                        Grid.DataBind();
                        txtDescription.Focus();
                    }


                    return;
                }
            }
            #endregion
            #region txtDescription
            if (sender == txtDescription)
            {
                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    oBrochure.Description = txtDescription.Text;
                    Grid.Focus();
                    MoveLast();
                    return;
                }
            }
            #endregion
            #region Grid

            if (sender == Grid)
            {
                if (e.KeyCode == Keys.F2)
                {
                    UltraGridRow gridRow;
                    gridRow = Grid.ActiveRow;
                    if (gridRow != null)
                    {
                        if (Grid.ActiveRow.Cells["ProductID"] == Grid.ActiveCell)
                        {
                            if (oProduct.View())
                            {
                                if (!Contain(Grid.ActiveRow.Cells["ProductID"].Text))
                                {
                                    Grid.ActiveRow.Cells["ProductID"].Value   = oProduct.ID;
                                    Grid.ActiveRow.Cells["InvCode"].Value     = oProduct.InvCode;
                                    Grid.ActiveRow.Cells["Description"].Value = oProduct.Description;
                                    Grid.ActiveRow.Cells["Price"].Activate();
                                    Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                                    return;
                                }
                                else
                                {
                                    MessageBox.Show("Item already entered");
                                    Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"];
                                    Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                                    return;
                                }
                            }
                        }
                    }
                }


                if (e.KeyCode == Keys.Delete)
                {
                }


                if (e.KeyCode == Keys.Enter)
                {
                    if (Grid.ActiveRow.Cells["ProductID"].Text != "" && !Contain(Grid.ActiveRow.Cells["ProductID"].Text))
                    {
                        if (Grid.ActiveRow.Cells["ProductID"] == Grid.ActiveCell)
                        {
                            if (oProduct.Find(Grid.ActiveRow.Cells["ProductID"].Text))
                            {
                                if (!Contain(Grid.ActiveRow.Cells["ProductID"].Text))
                                {
                                    Grid.ActiveRow.Cells["ProductID"].Value   = oProduct.ID;
                                    Grid.ActiveRow.Cells["InvCode"].Value     = oProduct.InvCode;
                                    Grid.ActiveRow.Cells["Description"].Value = oProduct.Description;
                                    Grid.ActiveRow.Cells["Price"].Activate();
                                    Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                                    return;
                                }
                                else
                                {
                                    MessageBox.Show("Item already entered");
                                    Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"];
                                    Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                                    return;
                                }
                            }
                        }
                        else if (Grid.ActiveRow.Cells["Price"] == Grid.ActiveCell)
                        {
                            Grid.ActiveRow.Cells["Forecast"].Activate();
                            Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                            return;
                        }

                        if (Grid.GetRow(ChildRow.Last) == Grid.ActiveRow)
                        {
                            oBrochure.Items.AddEmpty();
                            Grid.DataBind();
                            MoveLast();
                            //Grid.PerformAction(UltraGridAction.LastRowInBand, false, false);
                        }
                        else
                        {
                            Grid.PerformAction(UltraGridAction.NextRowByTab, false, false);
                            Grid.ActiveRow.Cells["ProductID"].Activate();
                            Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                        }
                    }
                    else
                    {
                        Grid.ActiveRow.Cells["ProductID"].Activate();
                        Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                        Grid.ActiveRow.Cells["Price"].Value = 0;
                    }
                    return;
                }

                if (e.KeyCode == Keys.Down)
                {
                    MoveDown();
                    return;
                }
                if (e.KeyCode == Keys.Up)
                {
                    Infragistics.Win.UltraWinGrid.UltraGridRow gridRow;
                    gridRow = Grid.ActiveRow;
                    gridRow = gridRow.GetSibling(Infragistics.Win.UltraWinGrid.SiblingRow.Previous);
                    if (gridRow != null)
                    {
                        gridRow.Activate();
                        //' set ActiveCell
                        Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"];
                        Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                    }
                    return;
                    //SendKeys.Send("{TAB}");
                }
            }
            #endregion
            #region txtProductID
            if (sender == txtProductID)
            {
                if (e.KeyCode.ToString() == "F2")
                {
                    if (oProduct.View())
                    {
                        txtProductID.Text    = oProduct.ID;
                        txtPDescription.Text = oProduct.Description;
                    }
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtProductID.Text.Trim().Length == 0)
                    {
                        txtProductID.Focus();
                    }

                    if (oProduct.Find(txtProductID.Text))
                    {
                        txtProductID.Text    = oProduct.ID;
                        txtPDescription.Text = oProduct.Description;
                    }
                }
            }
            #endregion
            #region txtProductTypeID
            if (sender == txtProductTypeID)
            {
                if (e.KeyCode.ToString() == "F2")
                {
                    if (oPack.View())
                    {
                        txtProductTypeID.Text = oPack.ID;
                        txtPTDescription.Text = oPack.Description;
                    }
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtProductTypeID.Text.Trim().Length == 0)
                    {
                        txtProductTypeID.Focus();
                    }

                    if (oPack.Find(txtProductTypeID.Text))
                    {
                        txtProductTypeID.Text = oPack.ID;
                        txtPTDescription.Text = oPack.Description;
                    }
                }
            }
            #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.F3:
                if (MessageBox.Show("Do you really want to Delete this Brochure?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                {
                    MessageBox.Show("Operation Cancelled");
                    return;
                }
                oBrochure.Delete();
                Grid.DataBind();
                Clear();
                txtBrochureID.Clear();
                txtBrochureID.Focus();

                break;

            case Keys.PageDown:
                this.Save();
                Grid.DataBind();
                Clear();
                txtBrochureID.Clear();
                txtBrochureID.Focus();
                break;

            case Keys.Delete:
                if (e.Control)
                {
                    DeleteItem();
                }
                break;
                //case Keys.<some key>:
                // ......;
                // break;
            }
            #endregion
        }
 public static void GridNavigation(UltraGrid grid, KeyEventArgs e)
 {
   //Navigate the grid with arrow keys
   switch (e.KeyCode)
   {
     case Keys.Up:
       grid.PerformAction(UltraGridAction.ExitEditMode, false, false);
       grid.PerformAction(UltraGridAction.AboveCell, false, false);
       e.Handled = true;
       grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
       break;
     case Keys.Down:
       grid.PerformAction(UltraGridAction.ExitEditMode, false, false);
       grid.PerformAction(UltraGridAction.BelowCell, false, false);
       e.Handled = true;
       grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
       break;
     case Keys.Left:
       grid.PerformAction(UltraGridAction.ExitEditMode, false, false);
       grid.PerformAction(UltraGridAction.PrevCell, false, false);
       e.Handled = true;
       grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
       break;
     case Keys.Right:
       grid.PerformAction(UltraGridAction.ExitEditMode, false, false);
       grid.PerformAction(UltraGridAction.NextCell, false, false);
       e.Handled = true;
       grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
       break;
     case Keys.Enter:
       grid.PerformAction(UltraGridAction.ExitEditMode, false, false);
       grid.PerformAction(UltraGridAction.BelowCell, false, false);
       e.Handled = true;
       grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
       break;
   }
 }
        private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region txtCustomerID
            if (sender == txtCustomerID)
            {
                if (e.KeyCode == Keys.PageDown || e.KeyCode == Keys.F3)
                {
                    return;
                }


                if (e.KeyCode.ToString() == "F2")
                {
                    if (oCustomer.View())
                    {
                        ShowCustomer();

                        oTeachers.CustomerID = oCustomer.ID;
                        oTeachers.Load(oCustomer.ID);
                        Grid.DataSource = oTeachers.Table;
                        Grid.DataBind();
                        Grid.Focus();
                        MoveLast();
                        return;
                    }
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtCustomerID.Text.Trim().Length == 0)
                    {
                        Clear();
                        txtCustomerID.Focus();
                    }

                    if (oCustomer.Find(txtCustomerID.Text))
                    {
                        ShowCustomer();
                        oTeachers.CustomerID = oCustomer.ID;
                        oTeachers.Load(oCustomer.ID);
                        Grid.DataSource = oTeachers.Table;
                        Grid.DataBind();
                        Grid.Focus();
                        MoveLast();
                    }
                    else
                    {
                        Clear();
                        Grid.DataSource = oTeachers.Table;
                        Grid.DataBind();
                        txtName.Focus();
                    }


                    return;
                }
            }
            #endregion
            #region Grid

            if (sender == Grid)
            {
                if (e.KeyCode == Keys.F2)
                {
                    UltraGridRow gridRow;
                    gridRow = Grid.ActiveRow;
                    if (gridRow != null)
                    {
                        if (Grid.ActiveRow.Cells["Teacher"] == Grid.ActiveCell)
                        {
                            /*
                             * if (oProduct.View())
                             * {
                             *   if (!oImages.Items.Contains(Grid.ActiveRow.Cells["ProductID"].Text))
                             *  {
                             *
                             *      Grid.ActiveRow.Cells["ProductID"].Value = oProduct.ID;
                             *      Grid.ActiveRow.Cells["Description"].Value = oProduct.Description;
                             *      Grid.ActiveRow.Cells["Amount"].Activate();
                             *      Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                             *      return;
                             *  }
                             *  else
                             *  {
                             *      MessageBox.Show("Item already entered");
                             *      Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"];
                             *      Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                             *      return;
                             *  }
                             * }
                             */
                        }
                    }
                }


                if (e.KeyCode == Keys.Delete)
                {
                }


                if (e.KeyCode == Keys.Enter)
                {
                    Infragistics.Win.UltraWinGrid.UltraGridRow gridRow;
                    gridRow = Grid.ActiveRow;
                    if (gridRow != null)
                    {
                        if (Grid.ActiveCell.Text.Trim() != "" && Grid.ActiveRow.Cells["Teacher"] == Grid.ActiveCell)
                        {
                            if (Contain(Grid.ActiveRow.Cells["Teacher"].Text))
                            {
                                MessageBox.Show("Item already entered");
                                Grid.ActiveCell = Grid.ActiveRow.Cells["Teacher"];
                                Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                                Grid.ActiveRow.Cells["Teacher"].Value = "";
                            }
                            else
                            {
                                this.MoveLast();
                            }
                        }
                        return;
                    }
                }

                if (e.KeyCode == Keys.Down)
                {
                    MoveDown();
                    return;
                }
                if (e.KeyCode == Keys.Up)
                {
                    Infragistics.Win.UltraWinGrid.UltraGridRow gridRow;
                    gridRow = Grid.ActiveRow;
                    gridRow = gridRow.GetSibling(Infragistics.Win.UltraWinGrid.SiblingRow.Previous);
                    if (gridRow != null)
                    {
                        gridRow.Activate();
                        //' set ActiveCell
                        Grid.ActiveCell = Grid.ActiveRow.Cells["Teacher"];
                        Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                    }
                    return;
                }
            }
            #endregion
            #region txtName
            if (sender == txtName)
            {
                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    //  oImages.Description = txtName.Text;
                    Grid.Focus();
                    MoveLast();
                    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.F3:
                oTeachers.Delete();
                Clear();
                // oImages.Items.dtItems.Rows.Clear();
                Grid.DataBind();
                txtCustomerID.Clear();
                txtCustomerID.Focus();
                break;

            case Keys.PageDown:
                MoveLast();
                oTeachers.Save();
                Grid.DataBind();
                Clear();
                txtCustomerID.Clear();
                txtCustomerID.Focus();
                break;

            case Keys.Delete:
                if (e.Control)
                {
                    DeleteItem();
                }
                break;

                //case Keys.<some key>:
                // ......;
                // break;
            }
            #endregion
        }
Beispiel #16
0
        private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            //MessageBox.Show(e.KeyCode.ToString());
            #region Grid
            if (sender == Grid)
            {
                if (Grid.ActiveRow != null)
                {
                    if (e.KeyCode == Keys.Delete)
                    {
                        if (e.Shift && Grid.GetRow(ChildRow.Last) != Grid.ActiveRow)
                        {
                            Grid.ActiveRow.Delete();
                            MoveLast();
                            return;
                        }
                    }

                    switch (Grid.ActiveCell.Column.Key)
                    {
                    case "ProductID":
                    {
                        if (e.KeyCode == Keys.F2)
                        {
                            if (oProduct.View())
                            {
                                Grid.ActiveRow.Cells["ProductID"].Value   = oProduct.ID;
                                Grid.ActiveRow.Cells["Description"].Value = oProduct.Description;
                                Grid.ActiveRow.Cells["Price"].Value       = oProduct.Price;
                                Grid.ActiveRow.Cells["Quantity"].Value    = 1;
                                Grid.ActiveRow.Cells["Quantity"].Activate();
                                Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                            }
                        }
                        if (e.KeyCode == Keys.Return)
                        {
                            if (!Contain(Grid.ActiveRow.Cells["ProductID"].Text))         //(!oProduct.Items.Contains(Grid.ActiveRow.Cells["ProductID"].Text))
                            {
                                if (oProduct.Find(Grid.ActiveRow.Cells["ProductID"].Text))
                                {
                                    Grid.ActiveRow.Cells["ProductID"].Value   = oProduct.ID;
                                    Grid.ActiveRow.Cells["Description"].Value = oProduct.Description;
                                    Grid.ActiveRow.Cells["Price"].Value       = oProduct.Cost;
                                    Grid.ActiveRow.Cells["Quantity"].Value    = 1;
                                    Grid.ActiveRow.Cells["Quantity"].Activate();
                                    Grid.ActiveCell = Grid.ActiveRow.Cells["Quantity"];
                                    Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Item already entered");
                                Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"];
                                Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                                return;
                            }
                        }
                        if (e.KeyCode == Keys.Down)
                        {
                            Grid.PerformAction(UltraGridAction.NextRowByTab, false, false);
                            Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"];
                            Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                        }
                        if (e.KeyCode == Keys.Up)
                        {
                            Grid.PerformAction(UltraGridAction.PrevRowByTab, false, false);
                            Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"];
                            Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                        }
                        if (e.KeyCode == Keys.Right)
                        {
                            Grid.PerformAction(UltraGridAction.NextCellByTab, false, false);
                            Grid.ActiveCell = Grid.ActiveRow.Cells["Cases"];
                            Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                        }
                    }

                    break;

                    case "Quantity":
                        if (e.KeyCode == Keys.Return)
                        {
                            if (Grid.ActiveRow.Cells["ProductID"].Text != "" && !Contain(Grid.ActiveRow.Cells["ProductID"].Text))
                            {
                                if (Grid.GetRow(ChildRow.Last) == Grid.ActiveRow)
                                {
                                    oProduct.Items.AddEmpty();
                                    Grid.DataBind();
                                    MoveLast();
                                    //Grid.PerformAction(UltraGridAction.LastRowInBand, false, false);
                                }
                                else
                                {
                                    Grid.PerformAction(UltraGridAction.NextRowByTab, false, false);
                                    Grid.ActiveRow.Cells["ProductID"].Activate();
                                    Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                                }
                            }
                            else
                            {
                                Grid.ActiveRow.Cells["ProductID"].Activate();
                                Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                                Grid.ActiveRow.Cells["Quantity"].Value = 1;
                            }
                            return;
                        }
                        if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Down || e.KeyCode == Keys.Tab)
                        {
                            Grid.PerformAction(UltraGridAction.NextRowByTab, false, false);
                            Grid.ActiveCell = Grid.ActiveRow.Cells["Quantity"];
                            Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                        }
                        if (e.KeyCode == Keys.Up)
                        {
                            Grid.PerformAction(UltraGridAction.PrevRowByTab, false, false);
                            Grid.ActiveCell = Grid.ActiveRow.Cells["Quantity"];
                            Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                        }

                        break;

                    default:
                    {
                        if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Down || e.KeyCode == Keys.Tab)
                        {
                            Grid.PerformAction(UltraGridAction.NextRowByTab, false, false);
                            //Grid.ActiveCell = Grid.ActiveRow.Cells["Received"];
                            Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                        }
                        if (e.KeyCode == Keys.Up)
                        {
                            Grid.PerformAction(UltraGridAction.PrevRowByTab, false, false);
                            //Grid.ActiveCell = Grid.ActiveRow.Cells["Received"];
                            Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                        }
                    }
                    break;
                    }
                }
                return;
            }
            #endregion

            #region txtOrderID
            if (sender == txtProductID)
            {
                if (e.KeyCode == Keys.F2)
                {
                    if (oProduct.View())
                    {
                        txtProductID.Text = oProduct.ID;
                        // txtVendorID.Text = oProduct.VendID;
                        //  oVendor.Find(oProduct.VendID);
                        //  txtName.Text = oVendor.Name;

                        Grid.DataSource = oProduct.Items.dtItems; //oProduct.Items;
                        Grid.DataBind();
                        MoveLast();

                        txtProductID.Enabled = false;

                        return;
                    }
                    else
                    {
                        Grid.Height = 529;
                    }
                    //this.txtDescription.Text =
                    return;
                }
                if (e.KeyCode.ToString() == "Return" || e.KeyCode.ToString() == "Tab")
                {
                    if (txtProductID.Text.Trim() == "")
                    {
                        txtProductID.Clear();
                        txtProductID.Focus();
                        return;
                    }

                    if (oProduct.Find(txtProductID.Text))
                    {
                        // txtVendorID.Text = oProduct.VendID;
                        // oVendor.Find(oProduct.VendID);
                        // txtName.Text = oVendor.Name;


                        //Grid.DataSource = oProduct.Items;
                        Grid.DataSource = oProduct.Items.dtItems; //oProduct.Items;
                        MoveLast();

                        txtProductID.Enabled = false;
                        return;
                    }
                    else
                    {
                        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.F3:
                deleteOrder();
                break;

            case Keys.PageDown:
                break;

            case Keys.Delete:
                if (!e.Control)
                {
                    Grid.ActiveRow.Delete();
                }
                break;


                //case Keys.<some key>:
                // ......;
                // break;
            }
            #endregion
        }
Beispiel #17
0
 private void pGridInvertSelection(UltraGrid grid, UltraGridColumn checkColumn)
 {
     foreach (UltraGridRow row in grid.Rows)
     {
         row.Cells[checkColumn].Value = !(bool)row.Cells[checkColumn].Value;
     }
     grid.UpdateData();
     grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode);
 }