private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { DataGridViewRow Row = this.dataGridView1.Rows[e.RowIndex]; listaTramos.Add(new TramoElegido(Convert.ToInt32(Row.Cells["Codigo"].Value.ToString()), Row.Cells["Origen"].Value.ToString(), Row.Cells["Destino"].Value.ToString(), Convert.ToDecimal(Row.Cells["Precio"].Value.ToString()))); listBox1.Items.Add(Row.Cells["Origen"].Value.ToString() + " - " + Row.Cells["Destino"].Value.ToString()); if (listaTramos.Count != 0) { TramoElegido a = listaTramos.ElementAt(0); TramoElegido b = listaTramos.ElementAt(listaTramos.Count - 1); lblOrigen.Text = "Origen:" + a.origen; lblDestino.Text = "Desinto:" + b.destino; filtroElProceso = true; txtBoxFiltroOrigen.Text = b.destino; txtBoxFiltroOrigen.ReadOnly = true; filtroOrigen = b.destino; filtroDestino = txtBoxFiltroDestino.Text; filtro = string.Format("{0} Like '%{1}%'", "Origen", filtroOrigen); filtro += string.Format("And {0} Like '%{1}%'", "Destino", filtroDestino); dt.DefaultView.RowFilter = filtro; precio += b.precio; lblPrecio.Text = "Precio:" + precio; } } }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { DataGridViewRow Row = this.dataGridView1.Rows[e.RowIndex]; listaTramos.Add(new TramoElegido(Convert.ToInt32(Row.Cells["Codigo"].Value.ToString()), Row.Cells["Origen"].Value.ToString(), Row.Cells["Destino"].Value.ToString(), Convert.ToDecimal(Row.Cells["Precio"].Value.ToString()))); listBox2.Items.Add(Row.Cells["Origen"].Value.ToString() + " - " + Row.Cells["Destino"].Value.ToString()); if (listaTramos.Count != 0) { TramoElegido a = listaTramos.ElementAt(0); TramoElegido b = listaTramos.ElementAt(listaTramos.Count - 1); lblOrigen.Text = "Origen:" + a.origen; lblDestino.Text = "Desinto:" + b.destino; filtroElProceso = true; txtBoxFiltroOrigen.Text = b.destino; txtBoxFiltroOrigen.ReadOnly = true; filtroOrigen = b.destino; filtroDestino = txtBoxFiltroDestino.Text; actualizarFiltro(); Precio += b.precio; lblPrecio.Text = "Precio:" + Precio; } } //listBox1.Items. }
private void btnCrearTramo_Click(object sender, EventArgs e) { tramo = new TramoElegido(0, txtBoxFiltroOrigen.Text, "", 0); frmNuevoTramo nuevoTramo = new frmNuevoTramo(ref tramo); nuevoTramo.Show(); this.Enabled = false; nuevoTramo.FormClosing += NuevoTramo_FormClosing; }
public frmNuevoTramo(ref TramoElegido _unTramo) { InitializeComponent(); unTramo = _unTramo; cBoxOrigen.SelectedIndexChanged += new EventHandler(cBoxOrigen_SelectedIndexChanged); cBoxDestino.SelectedIndexChanged += new EventHandler(cBoxDestino_SelectedIndexChanged); btnAceptar.Click += new EventHandler(btnAceptar_Click); #region Eventos Load += new EventHandler(frmNuevoTramo_Load); #endregion }
private void listBox1_Click(object sender, EventArgs e) { if (listaTramos.Count - 1 >= 0) { precio = precio - listaTramos.ElementAt(listaTramos.Count - 1).precio; lblPrecio.Text = "Precio:" + precio; listaTramos.RemoveAt(listaTramos.Count - 1); listBox1.Items.RemoveAt(listBox1.Items.Count - 1); if (listaTramos.Count == 0) { Limpiar(); } else { filtroElProceso = true; TramoElegido Ultimotramo = listaTramos.Last(); txtBoxFiltroOrigen.Text = Ultimotramo.destino; filtroOrigen = Ultimotramo.destino; actualizarFiltro(); } } }
private void NuevoTramo_FormClosing(object sender, FormClosingEventArgs e) { if (tramo.origen != "" && tramo.destino != "" && tramo.precio != 0) { listBox2.Items.Add(tramo.origen + "-" + tramo.destino); //DIZ NUTTZ listaTramos.Add(tramo); //Tendria que chequar que no esten vacios los valores. filtroElProceso = true; txtBoxFiltroOrigen.Text = tramo.destino; Precio += tramo.precio; lblPrecio.Text = "Precio:" + Precio; filtroOrigen = tramo.destino; //nuevosTramos = abm.mostrarTramosExistentes(); } this.Enabled = true; nuevosTramos = abm.mostrarTramosExistentes(); dataGridView1.DataSource = nuevosTramos; TramoElegido Ultimotramo = listaTramos.Last(); txtBoxFiltroOrigen.Text = Ultimotramo.destino; filtroOrigen = Ultimotramo.destino; filtroElProceso = true; actualizarFiltro(); }
private void listBox2_SelectedIndexChanged(object sender, EventArgs e) { if (listaTramos.Count - 1 >= 0) { Precio = Precio - listaTramos.ElementAt(listaTramos.Count - 1).precio; //lblPrecio.Text = "Precio:" + Precio; if (!cambioElIndiceElProceso) { cambioElIndiceElProceso = true; listaTramos.RemoveAt(listaTramos.Count - 1); listBox2.Items.RemoveAt(listBox2.Items.Count - 1); cambioElIndiceElProceso = false; } if (listaTramos.Count == 0) { //Limpiar(); nuevosTramos.DefaultView.RowFilter = ""; //listBox1.Items.Clear(); listBox2.Items.Clear(); listaTramos.Clear(); lblOrigen.Text = "Origen:"; lblDestino.Text = "Desinto:"; Precio = 0; txtBoxFiltroDestino.Clear(); txtBoxFiltroOrigen.Clear(); txtBoxFiltroOrigen.ReadOnly = false; } else { TramoElegido Ultimotramo = listaTramos.Last(); txtBoxFiltroOrigen.Text = Ultimotramo.destino; filtroOrigen = Ultimotramo.destino; actualizarFiltro(); } } }