Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace SistemaFarmacia
- {
- public partial class frmNuevaVenta : Form
- {
- private List<VTemp2> Medicamentos { get; set; } // de acá tomo los medicamentos
- public frmNuevaVenta()
- {
- InitializeComponent();
- Farmacia contexto = new Farmacia();
- Medicamentos = contexto.VTemp2.ToList(); // de acá asigno los datos desde sql
- }
- private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) // este método me permite hacer el "autocompletado" en la lista
- {
- string titleText = dataGridView1.Columns[0].HeaderText;
- if (titleText.Equals("Medicamento"))
- {
- TextBox autoText = e.Control as TextBox;
- if (autoText != null)
- {
- autoText.AutoCompleteMode = AutoCompleteMode.Suggest;
- autoText.AutoCompleteSource = AutoCompleteSource.CustomSource;
- AutoCompleteStringCollection DataCollection = new AutoCompleteStringCollection();
- addItems(DataCollection); // llamo al método que matchea
- autoText.AutoCompleteCustomSource = DataCollection;
- }
- }
- }
- public void addItems(AutoCompleteStringCollection col) // este es el método que matchea con sql
- {
- foreach (VTemp2 item in Medicamentos)
- {
- col.Add(item.NOMBRE); // tendria que agregar un ID oculto, para luego referenciar al medicamento (tiene id, pero no lo traje)
- }
- }
- private void Cerrar(object sender, EventArgs e)
- {
- this.Close();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- 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
- form.FormClosed += new System.Windows.Forms.FormClosedEventHandler(Cerrar);
- form.MdiParent = frmMDI.ActiveForm;
- form.StartPosition = FormStartPosition.CenterScreen;
- form.FormClosed += F_FormClosed;
- form.Show();
- this.Enabled = false;
- }
- private void F_FormClosed(object sender, FormClosedEventArgs e)
- {
- this.Enabled = true;
- }
- private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- }
- private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
- {
- }
- private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e)
- {
- //if (e.KeyChar==13 || e.KeyChar==11)
- //{
- // Console.WriteLine("asd");
- //}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement