コード例 #1
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFPago.Text))
            {
                MessageBox.Show("Debe de llenar los campos", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                try
                {
                    using (SICOVE1Entities2 db = new SICOVE1Entities2())
                    {
                        string Id  = dgvFPagos.CurrentRow.Cells[0].Value.ToString();
                        int    IdC = int.Parse(Id);
                        formaPago                 = db.tb_FormaPago.Where(VerificarId => VerificarId.IdFormaPago == IdC).First();
                        formaPago.Nombre          = txtFPago.Text;
                        db.Entry(formaPago).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    MessageBox.Show("La Forma de Pago se ha Actualizado con éxito");
                    dgvFPagos.Rows.Clear();
                    cargardatos();
                    txtFPago.Clear();
                    txtFPago.Focus();

                    btnGuardar.Enabled = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(" Algo salio mal...  ¡Intente de nuevo! ");
                }
            }
        }
コード例 #2
0
        private void btnEminiar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFPago.Text))
            {
                MessageBox.Show("Debe de llenar los campos", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                try
                {
                    using (SICOVE1Entities2 db = new SICOVE1Entities2())
                    {
                        string Id = dgvFPagos.CurrentRow.Cells[0].Value.ToString();

                        formaPago = db.tb_FormaPago.Find(int.Parse(Id));
                        db.tb_FormaPago.Remove(formaPago);
                        db.SaveChanges();
                    }
                    MessageBox.Show("La Forma de Pago se ha Eliminado con éxito");
                    dgvFPagos.Rows.Clear();
                    cargardatos();
                    txtFPago.Clear();
                    txtFPago.Focus();

                    btnGuardar.Enabled = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(" Algo salio mal...  ¡Intente de nuevo! ");
                }
            }
        }
コード例 #3
0
        private void btnEminiar_Click(object sender, EventArgs e)
        {
            try
            {
                using (SICOVE1Entities db = new SICOVE1Entities())
                {
                    string Id = dgvFPagos.CurrentRow.Cells[0].Value.ToString();

                    formaPago = db.tb_FormaPago.Find(int.Parse(Id));
                    db.tb_FormaPago.Remove(formaPago);
                    db.SaveChanges();
                }
                MessageBox.Show("La Forma de Pago se ha Eliminado con éxito");
                dgvFPagos.Rows.Clear();
                cargardatos();
                txtFPago.Clear();
                txtFPago.Focus();

                btnGuardar.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(" Algo salio mal...  ¡Intente de nuevo! ");
            }
        }