Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. namespace SistemaFarmacia
  2. {
  3. public partial class frmNuevaVenta : Form
  4. {
  5. private List<VTemp2> Medicamentos { get; set; } // de acá tomo los medicamentos
  6. public frmNuevaVenta()
  7. {
  8. InitializeComponent();
  9. Farmacia contexto = new Farmacia();
  10. Medicamentos = contexto.VTemp2.ToList(); // de acá asigno los datos desde sql
  11. }
  12.  
  13. private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) // este método me permite hacer el "autocompletado" en la lista
  14. {
  15. string titleText = dataGridView1.Columns[0].HeaderText;
  16. if (titleText.Equals("Medicamento"))
  17. {
  18. TextBox autoText = e.Control as TextBox;
  19. if (autoText != null)
  20. {
  21. autoText.AutoCompleteMode = AutoCompleteMode.Suggest;
  22. autoText.AutoCompleteSource = AutoCompleteSource.CustomSource;
  23. AutoCompleteStringCollection DataCollection = new AutoCompleteStringCollection();
  24. addItems(DataCollection); // llamo al método que matchea
  25. autoText.AutoCompleteCustomSource = DataCollection;
  26. }
  27. }
  28. }
  29.  
  30. public void addItems(AutoCompleteStringCollection col) // este es el método que matchea con sql
  31. {
  32. foreach (VTemp2 item in Medicamentos)
  33. {
  34. col.Add(item.NOMBRE); // tendria que agregar un ID oculto, para luego referenciar al medicamento (tiene id, pero no lo traje)
  35. }
  36. }
  37.  
  38. private void Cerrar(object sender, EventArgs e)
  39. {
  40. this.Close();
  41. }
  42.  
  43. private void button1_Click(object sender, EventArgs e)
  44. {
  45. frmBuscarVentClientes form = new frmBuscarVentClientes(new List<int[,]>()); // tengo pensado pasar al proximo form una lista con int1 = ID medicamento y int2 = CANTIDAD para luego asignarle un cliente
  46. form.FormClosed += new System.Windows.Forms.FormClosedEventHandler(Cerrar);
  47. form.MdiParent = frmMDI.ActiveForm;
  48. form.StartPosition = FormStartPosition.CenterScreen;
  49. form.FormClosed += F_FormClosed;
  50. form.Show();
  51. this.Enabled = false;
  52. }
  53. private void F_FormClosed(object sender, FormClosedEventArgs e)
  54. {
  55. this.Enabled = true;
  56. }
  57.  
  58. private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  59. {
  60.  
  61. }
  62.  
  63. private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
  64. {
  65.  
  66. }
  67.  
  68. private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e)
  69. {
  70. //if (e.KeyChar==13 || e.KeyChar==11)
  71. //{
  72. // Console.WriteLine("asd");
  73. //}
  74. }
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement