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["CompanyID"].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["CompanyID"].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 txtRepID if (sender == txtRepID) { if (e.KeyCode == Keys.PageDown || e.KeyCode == Keys.F3) { return; } if (e.KeyCode.ToString() == "F2") { if (oRep.ViewByID()) { ShowVendor(); } if (txtRepID.Text == "") { return; } oRep.Items.Load(this.CompanyID, Convert.ToInt32(txtRepID.Text)); Grid.DataSource = oRep.Items.dtItems; Grid.DataBind(); Grid.Focus(); MoveLast(); return; } if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab) { if (txtRepID.Text.Trim().Length == 0) { Clear(); txtRepID.Focus(); } if (oRep.Find(Convert.ToInt32(txtRepID.Text))) { ShowVendor(); oRep.Items.Load(this.CompanyID, Convert.ToInt32(txtRepID.Text)); Grid.DataSource = oRep.Items.dtItems; Grid.DataBind(); Grid.Focus(); MoveLast(); } else { Clear(); txtRepID.Focus(); /* * oRep.ID = Convert.ToInt32(txtRepID.Text); * oRep.Items.AddEmpty(); * Grid.DataSource = oRep.Items.dtItems; * Grid.DataBind(); * Grid.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 (!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["Cost"].Activate(); Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false); return; } else if (Grid.ActiveRow.Cells["Cost"] == Grid.ActiveCell) { Grid.ActiveRow.Cells["HTS_Number"].Activate(); Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false); return; } else if (Grid.ActiveRow.Cells["HTS_Number"] == Grid.ActiveCell) { Grid.ActiveRow.Cells["HTS_Rate"].Activate(); Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false); return; } else if (Grid.ActiveRow.Cells["HTS_Rate"] == Grid.ActiveCell) { Grid.ActiveRow.Cells["HTS_Price"].Activate(); Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false); return; } else if (Grid.ActiveRow.Cells["HTS_Price"] == Grid.ActiveCell) { Grid.ActiveRow.Cells["Country"].Activate(); Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false); return; } if (Grid.GetRow(ChildRow.Last) == Grid.ActiveRow) { oRep.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 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 Rep?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { MessageBox.Show("Operation Cancelled"); return; } break; case Keys.PageDown: this.Save(); Grid.DataBind(); Clear(); txtRepID.Clear(); txtRepID.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) { //MessageBox.Show(e.KeyCode.ToString()); #region Grid if (sender == Grid) { if (e.KeyCode == Keys.F3) { deleteOrder(); Clear(); txtCardSetID.Enabled = true; txtCardSetID.Focus(); return; } 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["InvCode"].Value = oProduct.InvCode; Grid.ActiveRow.Cells["Price"].Value = oProduct.Cost; Grid.ActiveRow.Cells["Cases"].Activate(); Grid.PerformAction(UltraGridAction.EnterEditMode, false, false); } } if (e.KeyCode == Keys.Return) { if (!Contain(Grid.ActiveRow.Cells["ProductID"].Text)) //(!oCardSet.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["InvCode"].Value = oProduct.InvCode; Grid.ActiveRow.Cells["Price"].Value = oProduct.Cost; Grid.ActiveRow.Cells["Cases"].Activate(); Grid.ActiveCell = Grid.ActiveRow.Cells["Cases"]; 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 "Cases": if (e.KeyCode == Keys.Return) { Grid.ActiveRow.Cells["Units"].Activate(); Grid.PerformAction(UltraGridAction.EnterEditMode, false, false); } if (e.KeyCode == Keys.Right) { Grid.PerformAction(UltraGridAction.NextCellByTab, false, false); Grid.ActiveCell = Grid.ActiveRow.Cells["Units"]; Grid.PerformAction(UltraGridAction.EnterEditMode, false, false); } if (e.KeyCode == Keys.Left) { Grid.PerformAction(UltraGridAction.PrevCellByTab, false, false); Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"]; Grid.PerformAction(UltraGridAction.EnterEditMode, false, false); } break; case "Units": if (e.KeyCode == Keys.Return) { if (Grid.ActiveRow.Cells["ProductID"].Text != "" && !Contain(Grid.ActiveRow.Cells["ProductID"].Text)) { if (Grid.GetRow(ChildRow.Last) == Grid.ActiveRow) { // oCardSet.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["Units"].Value = 0; } 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["Units"]; Grid.PerformAction(UltraGridAction.EnterEditMode, false, false); } if (e.KeyCode == Keys.Up) { Grid.PerformAction(UltraGridAction.PrevRowByTab, false, false); Grid.ActiveCell = Grid.ActiveRow.Cells["Units"]; Grid.PerformAction(UltraGridAction.EnterEditMode, false, false); } if (e.KeyCode == Keys.Left) { Grid.PerformAction(UltraGridAction.PrevCellByTab, false, false); Grid.ActiveCell = Grid.ActiveRow.Cells["Cases"]; 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 txtCardSetID if (sender == txtCardSetID) { if (e.KeyCode == Keys.F2) { if (oCardSet.View()) { txtCardSetID.Text = oCardSet.CardsetID; txtRangeStart.Text = oCardSet.RangeStart.ToString(); txtRangeEnd.Text = oCardSet.RangeEnd.ToString(); txtAmount.Text = oCardSet.TotalCredit.ToString(); Grid.DataSource = oCardSet.Items; Grid.DataBind(); GridDetail.DataSource = GetDetail(); return; } else { Grid.Height = 529; } return; } if (e.KeyCode.ToString() == "Return" || e.KeyCode.ToString() == "Tab") { if (txtCardSetID.Text.Trim() == "") { txtCardSetID.Clear(); txtCardSetID.Focus(); return; } if (oCardSet.Find(txtCardSetID.Text)) { txtCardSetID.Text = oCardSet.CardsetID; txtRangeStart.Text = oCardSet.RangeStart.ToString(); txtRangeEnd.Text = oCardSet.RangeEnd.ToString(); txtAmount.Text = oCardSet.TotalCredit.ToString(); Grid.DataSource = oCardSet.Items; // Grid.DataSource = oCardSet.Items.dtItems; //oCardSet.Items; // MoveLast(); txtCardSetID.Enabled = false; return; } else { Grid.Height = 529; txtRangeStart.Enabled = true; txtRangeStart.Focus(); return; } } } #endregion #region txtRangeStart if (sender == txtRangeStart) { if (e.KeyCode.ToString() == "F2") { if (oVendor.View()) { this.txtRangeStart.Text = oVendor.ID; if (!oVendor.Find(txtRangeStart.Text)) { this.txtRangeStart.Focus(); return; } // oCardSet.Items.Load(CompanyID, txtCardSetID.Text); // Grid.DataSource = oCardSet.Items.dtItems; Grid.Focus(); return; } } if (e.KeyCode.ToString() == "Return" || e.KeyCode.ToString() == "Tab") { if (!oVendor.Find(txtRangeStart.Text)) { this.txtRangeStart.Focus(); return; } // oCardSet.Items.Load(CompanyID, txtCardSetID.Text); // Grid.DataSource = oCardSet.Items.dtItems; 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: deleteOrder(); break; case Keys.PageDown: break; case Keys.Delete: if (!e.Control) { Grid.ActiveRow.Delete(); } break; //case Keys.<some key>: // ......; // break; } #endregion }