Exemple #1
0
 public void tipoBotonClic(DataGridViewCellEventArgs e)
 {
     //si el click es en el boton actualizar
     if (e.RowIndex >= 0)
     {
         if (e.ColumnIndex == btnUpdate.Index)
         {
             frmInsertarOfertas frm = new frmInsertarOfertas();
             frm.MdiParent   = this.MdiParent;
             frm.WindowState = FormWindowState.Maximized;
             frm.Show();
             frm.TipoInsercion = 1;
             frm.PkOfertas     = Convert.ToString(tblOfertas.Rows[e.RowIndex].Cells[0].Value);
             frm.NombreOferta  = Convert.ToString(tblOfertas.Rows[e.RowIndex].Cells[1].Value);
             frm.FechaInicio   = Convert.ToString(tblOfertas.Rows[e.RowIndex].Cells[2].Value);
             frm.FechaFin      = Convert.ToString(tblOfertas.Rows[e.RowIndex].Cells[3].Value);
             frm.Descripcion   = Convert.ToString(tblOfertas.Rows[e.RowIndex].Cells[4].Value);
             this.Dispose();
         }
         //si el click es en el boton eliminar
         if (e.ColumnIndex == btnEliminar.Index)
         {
             if (MessageBox.Show("Esta seguro de eliminar este registro?", "Eliminar Registro", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 if (MessageBox.Show("Esta totalmente seguro?", "Eliminar Registro", MessageBoxButtons.YesNo) == DialogResult.Yes)
                 {
                     int codigo = Convert.ToInt32(tblOfertas.Rows[e.RowIndex].Cells[0].Value);
                     OfertaBLL.DeleteOferta(codigo);
                     MessageBox.Show("Registro eliminado");
                     this.cargarDatosOfertas();
                 }
             }
         }
     }
 }
Exemple #2
0
        private void insertarRegistro()
        {
            oferta                      = new Oferta();
            oferta.nombre               = txtNombreOferta.Text;
            oferta.fechaInicio          = Convert.ToDateTime(dtFechaInicio.Text);
            oferta.fechaFin             = Convert.ToDateTime(dtFechaFin.Text);
            oferta.descripcion          = txtDescripcion.Text;
            oferta.intIdUsuarioCreacion = IdUsuario.IdUsuarioConectado;
            if (tipoInsercion == 0)
            {
                OfertaBLL.InsertObjetoOferta(oferta);
                MessageBox.Show("El registro se agrego correctamente");
            }

            if (tipoInsercion == 1)
            {
                oferta.id_Ofertas = Convert.ToInt16(txtPkOfertas.Text);
                OfertaBLL.UpdateOferta(oferta);
                MessageBox.Show("El registro se ha actualizado correctamente");
                frmOfertas frm = new frmOfertas();
                frm.MdiParent   = this.MdiParent;
                frm.WindowState = FormWindowState.Maximized;
                frm.Show();
                this.Dispose();
            }
        }
Exemple #3
0
 private void cargarDatosOfertas()
 {
     tblOfertas.DataSource = OfertaBLL.SelectAll();
 }