Exemple #1
0
 void TypeKeyDown(object sender, KeyEventArgs e)
 {
     if (!bItemTypeOpen && e.KeyCode == Keys.F5)
     {
         frmListOfItemTypes flit = new frmListOfItemTypes();
         bItemTypeOpen = true;
         try
         {
             if (InputTextBox("TYPE").Text.Length != 0)
             {
                 flit.SelectedItemType = Convert.ToInt32(InputTextBox("TYPE").Text);
             }
         }
         catch
         {
             InputTextBox("TYPE").Text = "";
         }
         flit.ShowDialog();
         if (flit.SelectedItemType == -1)
         {
             InputTextBox("SUPPLIER").Focus();
         }
         else
         {
             InputTextBox("TYPE").Text = flit.SelectedItemType.ToString();
             InputTextBox("CATEGORY").Focus();
         }
         bItemTypeOpen = false;
     }
 }
Exemple #2
0
 void dGrid_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.F3 && !bF3Registered)
     {
         bF5Registered     = false;
         bEscapeRegistered = false;
         bF3Registered     = true;
         frmSingleInputBox fsfiGetOriginal = new frmSingleInputBox("Where the " + dGrid.Columns[dGrid.SelectedCells[0].ColumnIndex].Name + " is currently...", ref sEngine);
         fsfiGetOriginal.tbResponse.Text = dGrid.CurrentCell.Value.ToString();
         fsfiGetOriginal.ShowDialog();
         if (fsfiGetOriginal.Response != "$NONE")
         {
             frmSingleInputBox fsfiGetNew = new frmSingleInputBox("Change the " + dGrid.Columns[dGrid.SelectedCells[0].ColumnIndex].Name + " from " + fsfiGetOriginal.Response + " to...", ref sEngine);
             fsfiGetNew.ShowDialog();
             if (fsfiGetNew.Response != "$NONE")
             {
                 bool bNoneConverted = false;
                 while (!bNoneConverted) // Has to be done otherwise the grid sorts elements as it's changing them and ends up missing some
                 {
                     bNoneConverted = true;
                     for (int i = 0; i < dGrid.Rows.Count; i++)
                     {
                         if (dGrid.SelectedCells[0].ColumnIndex != 4 && dGrid.SelectedCells[0].ColumnIndex != 8 && dGrid.Rows[i].Cells[dGrid.SelectedCells[0].ColumnIndex].FormattedValue.ToString() == fsfiGetOriginal.Response)
                         {
                             dGrid.Rows[i].Cells[dGrid.SelectedCells[0].ColumnIndex].Value = fsfiGetNew.Response;
                             bNoneConverted = false;
                             //i = 0;
                         }
                         else if ((dGrid.SelectedCells[0].ColumnIndex == 4 || dGrid.SelectedCells[0].ColumnIndex == 8) && dGrid.Rows[i].Cells[dGrid.SelectedCells[0].ColumnIndex].FormattedValue.ToString() != "" && Convert.ToDecimal(dGrid.Rows[i].Cells[dGrid.SelectedCells[0].ColumnIndex].FormattedValue.ToString()).Equals(Convert.ToDecimal(fsfiGetOriginal.Response)))
                         {
                             dGrid.Rows[i].Cells[dGrid.SelectedCells[0].ColumnIndex].Value = ScalableForm.FormatMoneyForDisplay(fsfiGetNew.Response);
                             bNoneConverted = false;
                             //i = 0;
                         }
                     }
                 }
             }
         }
     }
     else if (e.KeyCode == Keys.Escape && ((dGrid.CurrentCell != null && !dGrid.CurrentCell.IsInEditMode && !bEscapeRegistered) || (bEscapeRegistered && (nRowEscRegistered != dGrid.CurrentCell.RowIndex) || (nColumnEscRegistered != dGrid.CurrentCell.ColumnIndex))))// && lastKey != Keys.Escape)
     {
         bEscapeRegistered    = true;
         nColumnEscRegistered = dGrid.CurrentCell.ColumnIndex;
         nRowEscRegistered    = dGrid.CurrentCell.RowIndex;
         bF5Registered        = false;
         bF3Registered        = false;
         AskToSave();
     }
     else if (dGrid.CurrentCell.ColumnIndex == 2 && e.KeyCode == Keys.F5 && !bShowingType && !bF5Registered)
     {
         bEscapeRegistered = false;
         bF5Registered     = true;
         bF3Registered     = false;
         bShowingType      = true;
         frmListOfItemTypes flot = new frmListOfItemTypes();
         flot.SelectedItemType = Convert.ToInt32(dGrid.CurrentCell.Value.ToString());
         flot.ShowDialog();
         if (flot.SelectedItemType != -1)
         {
             dGrid.CurrentCell.Value = flot.SelectedItemType.ToString();
         }
         bShowingType = false;
         e.Handled    = true;
     }
     else if (dGrid.CurrentCell.ColumnIndex == 3 && e.KeyCode == Keys.F5 && !bF5Registered)
     {
         bEscapeRegistered = false;
         bF5Registered     = true;
         bF3Registered     = false;
         frmCategorySelect fcs = new frmCategorySelect(ref sEngine);
         fcs.ShowDialog();
         if (fcs.SelectedItemCategory != "$NULL")
         {
             dGrid.CurrentCell.Value = fcs.SelectedItemCategory;
         }
     }
     else if (dGrid.CurrentCell.ColumnIndex == 5 && e.KeyCode == Keys.F5 && !bF5Registered)
     {
         bEscapeRegistered = false;
         bF5Registered     = true;
         bF3Registered     = false;
         frmListOfVATRates flov = new frmListOfVATRates(ref sEngine);
         flov.ShowDialog();
         if (flov.sSelectedVATCode != "NULL")
         {
             dGrid.CurrentCell.Value = flov.sSelectedVATCode;
         }
     }
     else if (dGrid.CurrentCell.ColumnIndex == 7 && e.KeyCode == Keys.F5 && !bF5Registered)
     {
         bEscapeRegistered = false;
         bF5Registered     = true;
         bF3Registered     = false;
         frmListOfSuppliers flos = new frmListOfSuppliers(ref sEngine);
         flos.ShowDialog();
         if (flos.sSelectedSupplierCode != "NULL")
         {
             dGrid.CurrentCell.Value = flos.sSelectedSupplierCode;
         }
     }
     else if (dGrid.CurrentCell.ColumnIndex == 10 && e.KeyCode == Keys.F5 && !bF5Registered)
     {
         bEscapeRegistered = false;
         bF5Registered     = true;
         bF3Registered     = false;
         frmSearchForItemV2 fsfi = new frmSearchForItemV2(ref sEngine);
         fsfi.ShowDialog();
         if (fsfi.GetItemBarcode() != "NONE_SELECTED")
         {
             dGrid.CurrentCell.Value = fsfi.GetItemBarcode();
         }
     }
     else if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Right || e.KeyCode == Keys.Up || e.KeyCode == Keys.Left)
     {
         bF3Registered     = false;
         bF5Registered     = false;
         bEscapeRegistered = false;
     }
     else if (e.KeyCode == Keys.Enter)
     {
         e.Handled = true;
     }
 }