コード例 #1
0
ファイル: Bus.cs プロジェクト: antonevj/SIVSUR
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                DialogResult k = MessageBox.Show("Estas seguro  de eliminar este registro?", "aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                int rpta = 0;

                if (k == DialogResult.Yes)
                {
                    //capturar la fila del id para poder eliminar
                    int ID = (int)dataGridView1.CurrentRow.Cells["ID"].Value;

                    rpta = new LBus().Delete(ID);

                    if (rpta > 0)
                    {
                        MessageBox.Show("datos eliminados correctamente", "aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        mostrar_datos();
                    }
                }
            }
            else
            {
                MessageBox.Show("debe seleccionar un elemento");
            }
        }
コード例 #2
0
ファイル: DetalleBus.cs プロジェクト: antonevj/SIVSUR
        private void Button1_Click(object sender, EventArgs e)
        {
            if (!MyValidation())
            {
                return;
            }
            EBus obj = new EBus
            {
                ID                = txtID.Text.Length == 0 ? 0 : int.Parse(txtID.Text),
                Modelo            = txtModelo.Text.Trim().ToUpper(),
                Numero_De_Llantas = int.Parse(txtLlantas.Text.Trim().ToUpper()),
                Chasis            = txtChasis.Text.Trim().ToUpper(),
                Año_Fabricaciòn   = txtAÑo.Text.Trim().ToUpper(),
                Tipo_Combustible  = boxCombustible.Text.Trim().ToUpper(),
                rutina            = boxRutina.Text.Trim().ToUpper(),
                Placa             = txtPlaca.Text.Trim().ToUpper(),
                Capacidad         = txtCapacidad.Text,
                Estado            = chkEstado.Checked,
            };

            int rpta = 0;

            if (operacion == (byte)MisConstantes.OPERACION.Insercion)
            {
                rpta = new LBus().Create(obj);
            }
            else
            {
                rpta = new LBus().Update(obj);
            }

            if (rpta > 0)
            {
                MessageBox.Show("operacion realizada correctamente", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }