private void AgregarPropiedades(Button btn, int IdCaja, string titulo) { //btn.Name = Convert.ToString(cajas.Rows[contador]["id_caja"]); btn.Name = Convert.ToString(IdCaja); agregarIdCaja(Convert.ToString(IdCaja), IdCaja); Color color = Color.DarkViolet; btn.BackColor = color; btn.Font = new Font("Microsoft Sans Serif", 14, FontStyle.Bold); btn.ForeColor = Color.White; btn.Size = new Size(232, 90); btn.Location = new Point(1, auxY); btn.Text = titulo; btn.TextAlign = ContentAlignment.MiddleLeft; btn.Click += (s, e) => { if (bandera == 0) { DetalleCaja form = new DetalleCaja(this, idCotizacion, obtenerIdCaja(btn.Name), 0); this.Enabled = false; form.Show(); } else { DetalleCaja form = new DetalleCaja(this, idCotizacion, obtenerIdCaja(btn.Name)); this.Enabled = false; form.Show(); } }; auxY = auxY + 92; }
private void Button2_Click(object sender, EventArgs e) { try { if (bandera == 0) { DetalleCaja form = new DetalleCaja(this, idCotizacion, Convert.ToInt32(lista.CurrentRow.Cells["id_caja"].Value), 0); this.Enabled = false; form.Show(); } else { DetalleCaja form = new DetalleCaja(this, idCotizacion, Convert.ToInt32(lista.CurrentRow.Cells["id_caja"].Value)); this.Enabled = false; form.Show(); } } catch { DialogResult pregunta; pregunta = MetroFramework.MetroMessageBox.Show(this, "Debes seleccionar una caja.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }