Beispiel #1
0
        private void Cell_TextChanged(object sender, EventArgs e)
        {
            if (dgProducto.CurrentRow.Cells["idProducto"].Value != null && dgProducto.CurrentRow.Cells["idProducto"].Value.ToString().Length > 0 && int.Parse(dgProducto.CurrentRow.Cells["idProducto"].Value.ToString()) > 0)
            {
                dgProducto.CommitEdit(DataGridViewDataErrorContexts.Commit);
                DBM.CLS.CRUD  Tabla  = new DBM.CLS.CRUD();
                List <string> campos = new List <string>();
                campos.Add("idProducto");
                campos.Add("descripcion");
                campos.Add("precio");
                campos.Add("costo");
                campos.Add("stock");
                campos.Add("stockMinimo");
                campos.Add("inventariable");
                campos.Add("activo");

                List <string> valores = new List <string>();
                valores.Add(dgProducto.CurrentRow.Cells["idProducto"].Value.ToString());
                valores.Add(dgProducto.CurrentRow.Cells["descripcion"].Value.ToString());
                valores.Add(dgProducto.CurrentRow.Cells["precio"].Value.ToString());
                valores.Add(dgProducto.CurrentRow.Cells["costo"].Value.ToString());
                valores.Add(dgProducto.CurrentRow.Cells["stock"].Value.ToString());
                valores.Add(dgProducto.CurrentRow.Cells["stockMinimo"].Value.ToString());
                valores.Add((Convert.ToBoolean(dgProducto.CurrentRow.Cells["inventariable"].EditedFormattedValue)) ? "1" : "0");
                valores.Add((Convert.ToBoolean(dgProducto.CurrentRow.Cells["activoprod"].EditedFormattedValue)) ? "1" : "0");

                Tabla.Update("producto", campos, valores, "idProducto", dgProducto.CurrentRow.Cells["idProducto"].Value.ToString());
            }

            /*
             * CLS.NotaAsignatura objNotas = new CLS.NotaAsignatura();
             * objNotas.idNotaAsignatura = int.Parse(dgProducto.CurrentRow.Cells["idNotaAsignatura"].Value.ToString());
             * objNotas.A1 = dgProducto.CurrentRow.Cells["actividad1"].Value.ToString();
             * objNotas.A2 = dgProducto.CurrentRow.Cells["actividad2"].Value.ToString();
             * objNotas.A3 = dgProducto.CurrentRow.Cells["actividad3"].Value.ToString();
             *
             * double p1 = double.Parse(float.Parse(txtPa1.Text.Replace(",", "."), NumberStyles.Float, CultureInfo.InvariantCulture).ToString("F2").Replace(",", ".")) / 100;
             * double p2 = double.Parse(float.Parse(txtPa2.Text.Replace(",", "."), NumberStyles.Float, CultureInfo.InvariantCulture).ToString("F2").Replace(",", ".")) / 100;
             * double p3 = double.Parse(float.Parse(txtPa3.Text.Replace(",", "."), NumberStyles.Float, CultureInfo.InvariantCulture).ToString("F2").Replace(",", ".")) / 100;
             *
             * objNotas.PA1 = p1.ToString("N2");
             * objNotas.PA2 = p2.ToString("N2");
             * objNotas.PA3 = p3.ToString("N2");
             * objNotas.Promedio = objNotas.GetPromedio();
             *
             * dgProducto.CurrentRow.Cells["promedio"].Value = objNotas.GetPromedio();
             * //objNotas.UpdateNotas(int.Parse(cboPeriodo.SelectedValue.ToString()));
             */
        }
Beispiel #2
0
 private void btnRevocar_Click(object sender, EventArgs e)
 {
     try
     {
         DBM.CLS.CRUD Tabla = new DBM.CLS.CRUD();
         Tabla.Delete("permiso", "idRol", cboPerfil.SelectedValue.ToString() + " and idComando = " + dgOtorgados.CurrentRow.Cells["idComandoOtorgado"].Value.ToString());
         CargarPermisosDisponibles();
         CargarPermisosOtorgados();
         //.cambioSesionUsuario = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #3
0
        private void dgComando_RowLeave(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                dgComando.CommitEdit(DataGridViewDataErrorContexts.Commit);
                int           NewId  = 0;
                DBM.CLS.CRUD  Tabla  = new DBM.CLS.CRUD();
                List <string> campos = new List <string>();
                campos.Add("idComando");
                campos.Add("comando");

                List <string> valores = new List <string>();
                if (dgComando.CurrentRow.Cells["idComando"].Value != null && dgComando.CurrentRow.Cells["idComando"].Value.ToString().Length > 0)
                {
                    valores.Add(dgComando.CurrentRow.Cells["idComando"].Value.ToString());
                }
                else
                {
                    NewId = (Tabla.GetNewId("comando", "idComando") > 0) ? Tabla.GetNewId("comando", "idComando") : (Tabla.GetNewId("comando", "idComando") + 1);
                    valores.Add(NewId.ToString());
                    valores.Add(dgComando.CurrentRow.Cells["comando"].Value.ToString());

                    if (dgComando.CurrentRow.Cells["idComando"].Value == null || dgComando.CurrentRow.Cells["idComando"].Value.ToString().Length == 0)
                    {
                        if (dgComando.CurrentRow.Cells["comando"].Value.ToString().Length > 0)
                        {
                            Tabla.Insert("Comando", campos, valores);
                            dgComando.CurrentRow.Cells["idComando"].Value = NewId;
                            LlenarGridComando();
                            CargarPermisosOtorgados();
                            CargarPermisosDisponibles();

                            dgComando.CurrentCell          = dgComando.Rows[dgComando.RowCount - 1].Cells[0];
                            dgComando.CurrentCell.ReadOnly = false;
                            dgComando.BeginEdit(true);
                            dgComando.EndEdit();
                            dgComando.CurrentCell.ReadOnly = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ocurrió un error: " + ex.Message);
            }
        }
Beispiel #4
0
        private void Cell_TextChangedPerfil(object sender, EventArgs e)
        {
            if (dgPerfil.CurrentRow.Cells["idRol"].Value != null && dgPerfil.CurrentRow.Cells["idRol"].Value.ToString().Length > 0 && int.Parse(dgPerfil.CurrentRow.Cells["idRol"].Value.ToString()) > 0)
            {
                dgPerfil.CommitEdit(DataGridViewDataErrorContexts.Commit);
                DBM.CLS.CRUD  Tabla  = new DBM.CLS.CRUD();
                List <string> campos = new List <string>();
                campos.Add("idRol");
                campos.Add("Rol");

                List <string> valores = new List <string>();
                valores.Add(dgPerfil.CurrentRow.Cells["idRol"].Value.ToString());
                valores.Add(dgPerfil.CurrentRow.Cells["Rol"].Value.ToString());

                Tabla.Update("Rol", campos, valores, "idRol", dgPerfil.CurrentRow.Cells["idRol"].Value.ToString());
                LlenarCboPerfil();
            }
        }
Beispiel #5
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            DBM.CLS.CRUD  Tabla  = new DBM.CLS.CRUD();
            List <string> campos = new List <string>();

            campos.Add("idFamilia");
            campos.Add("familia");
            campos.Add("activo");


            List <string> valores = new List <string>();

            valores.Add(txtId.Text);
            valores.Add(TxtField1.Text);
            valores.Add("1");

            Tabla.Insert("familia", campos, valores);
        }
Beispiel #6
0
        private void btnUsuarioEditCancel_Click(object sender, EventArgs e)
        {
            DBM.CLS.CRUD Tabla = new DBM.CLS.CRUD();

            if (btnUsuarioEditCancel.Tag.ToString() == "1")
            {
                btnUsuarioEditCancel.Tag   = "2";
                btnUsuarioEditCancel.Image = Properties.Resources.cancel;

                btnUsuarioNewSave.Tag   = "2";
                btnUsuarioNewSave.Image = Resources.save;
                groupBoxUsuario.Controls.OfType <TextBox>().ToList().ForEach(o => o.ReadOnly = false);
                txtIdUsuario.ReadOnly = true;
                DataRow dr = Tabla.GetRecordByID("empleado", "idEmpleado", dgUsuario.CurrentRow.Cells["idEmpleado"].Value.ToString());

                txtIdUsuario.Text       = dr["idUsuario"].ToString();
                txtNombres.Text         = dr["nombres"].ToString();
                txtApellidos.Text       = dr["apellidos"].ToString();
                txtEmail.Text           = dr["email"].ToString();
                txtTelefono.Text        = dr["telefono"].ToString();
                cboPerfil.SelectedValue = dr["idRol"].ToString();

                txtPassword.ReadOnly  = true;
                txtPassword2.ReadOnly = true;

                chkChangePassword.Visible = true;

                txtNombres.Focus();
            }
            else
            {
                btnUsuarioEditCancel.Tag   = "1";
                btnUsuarioEditCancel.Image = Properties.Resources.edit;

                btnUsuarioNewSave.Tag   = "1";
                btnUsuarioNewSave.Image = Properties.Resources.new_;
                groupBoxUsuario.Controls.OfType <TextBox>().ToList().ForEach(o => o.ReadOnly = true);
                chkChangePassword.Checked = false;
                chkChangePassword.Visible = false;
                LimpiarForm();
            }
        }
Beispiel #7
0
        private void Cell_TextChangedComando(object sender, EventArgs e)
        {
            if (dgComando.CurrentRow.Cells["idComando"].Value != null && dgComando.CurrentRow.Cells["idComando"].Value.ToString().Length > 0 && int.Parse(dgComando.CurrentRow.Cells["idComando"].Value.ToString()) > 0)
            {
                dgComando.CommitEdit(DataGridViewDataErrorContexts.Commit);
                DBM.CLS.CRUD  Tabla  = new DBM.CLS.CRUD();
                List <string> campos = new List <string>();
                campos.Add("idComando");
                campos.Add("comando");

                List <string> valores = new List <string>();
                valores.Add(dgComando.CurrentRow.Cells["idComando"].Value.ToString());
                valores.Add(dgComando.CurrentRow.Cells["comando"].Value.ToString());

                Tabla.Update("comando", campos, valores, "idComando", dgComando.CurrentRow.Cells["idComando"].Value.ToString());

                CargarPermisosOtorgados();
                CargarPermisosDisponibles();
            }
        }
Beispiel #8
0
        //************************************************************************
        // MANTENIMIENTO PRODUCCTO GRIDVIEW
        //************************************************************************

        //*****************************************************************************
        //* MANTENIMIENTO PRODUCTO INDIVIDUAL(SIN GRIDVIEW)
        //*****************************************************************************
        private void btnUsuarioNewSave_Click(object sender, EventArgs e)
        {
            int NewId = 0;

            if (btnUsuarioNewSave.Tag.ToString() == "1")
            {
                btnUsuarioNewSave.Tag      = "2";
                btnUsuarioNewSave.Image    = Resources.save;
                btnUsuarioEditCancel.Tag   = "2";
                btnUsuarioEditCancel.Image = Properties.Resources.cancel;
                groupBoxUsuario.Controls.OfType <TextBox>().ToList().ForEach(o => o.ReadOnly = false);
                txtIdUsuario.ReadOnly = true;
                txtNombres.Focus();
                LimpiarForm();
                chkChangePassword.Visible = false;
            }
            else
            {
                if (txtNombres.TextLength > 0)
                {
                    DBM.CLS.QUERY query = new DBM.CLS.QUERY();
                    DBM.CLS.CRUD  Tabla = new DBM.CLS.CRUD();

                    List <string> campos = new List <string>();
                    campos.Add("idEmpleado");
                    campos.Add("nombres");
                    campos.Add("apellidos");
                    campos.Add("email");
                    campos.Add("telefono");
                    campos.Add("idRol");

                    List <string> valores = new List <string>();
                    if (txtIdUsuario.TextLength > 0)
                    {
                        valores.Add(txtIdUsuario.Text);
                    }
                    else
                    {
                        NewId = (Tabla.GetNewId("usuario", "idUsuario") > 0) ? Tabla.GetNewId("usuario", "idUsuario") : (Tabla.GetNewId("usuario", "idUsuario") + 1);
                        valores.Add(NewId.ToString());
                    }
                    valores.Add(txtNombres.Text);
                    valores.Add(txtEmail.Text);
                    valores.Add(txtTelefono.Text);

                    valores.Add(cboPerfil.SelectedValue.ToString());
                    bool actualizacion, continuar = false;
                    int  filaActual = 0;
                    if (txtIdUsuario.TextLength > 0)
                    {
                        actualizacion = true;
                        filaActual    = dgUsuario.CurrentRow.Index;
                        if (chkChangePassword.Checked)
                        {
                            campos.Add("password");
                            valores.Add(query.GetSHA1FromString(txtPassword.Text));
                            continuar = ComprobarDatos();
                            if (continuar)
                            {
                                Tabla.Update("usuario", campos, valores, "idUsuario", txtIdUsuario.Text);
                            }
                        }
                        else
                        {
                            Tabla.Update("usuario", campos, valores, "idUsuario", txtIdUsuario.Text);
                            continuar = true;
                        }
                    }
                    else
                    {
                        campos.Add("password");
                        valores.Add(query.GetSHA1FromString(txtPassword.Text));
                        actualizacion = false;
                        if (continuar = ComprobarDatos())
                        {
                            Tabla.Insert("usuario", campos, valores);
                        }
                    }
                    if (continuar)
                    {
                        chkChangePassword.Checked  = false;
                        btnUsuarioNewSave.Tag      = "1";
                        btnUsuarioNewSave.Image    = Properties.Resources.new_;
                        btnUsuarioEditCancel.Tag   = "1";
                        btnUsuarioEditCancel.Image = Properties.Resources.edit;
                        groupBoxUsuario.Controls.OfType <TextBox>().ToList().ForEach(o => o.ReadOnly = true);
                        LlenarGrid();
                        if (actualizacion)
                        {
                            dgUsuario.CurrentCell = dgUsuario.Rows[filaActual].Cells[0];
                        }
                        else
                        {
                            filaActual            = dgUsuario.Rows.Count - 1;
                            dgUsuario.CurrentCell = dgUsuario.Rows[dgUsuario.RowCount - 1].Cells[0];
                            //dgProducto.CurrentCell = dgProducto.Rows[filaActual].Cells[0];
                        }
                        LimpiarForm();
                        chkChangePassword.Visible = false;
                    }
                }
                else
                {
                    //MENSAJE VACIOS
                }
            }
        }
Beispiel #9
0
        //*****************************************************************************
        //* MANTENIMIENTO PRODUCTO INDIVIDUAL(SIN GRIDVIEW)
        //*****************************************************************************
        private void btnComandoNewSave_Click(object sender, EventArgs e)
        {
            int NewId = 0;

            if (btnComandoNewSave.Tag.ToString() == "1")
            {
                btnComandoNewSave.Tag      = "2";
                btnComandoNewSave.Image    = Properties.Resources.save;
                btnComandoEditCancel.Tag   = "2";
                btnComandoEditCancel.Image = Properties.Resources.cancel;

                groupBoxComando.Controls.OfType <TextBox>().ToList().ForEach(o => o.ReadOnly = false);
                txtIdComando.ReadOnly = true;

                LimpiarComandoForm();
                txtComando.Focus();
            }
            else
            {
                if (txtComando.TextLength > 0)
                {
                    DBM.CLS.CRUD  Tabla  = new DBM.CLS.CRUD();
                    List <string> campos = new List <string>();
                    campos.Add("idComando");
                    campos.Add("comando");

                    List <string> valores = new List <string>();
                    if (txtIdComando.TextLength > 0)
                    {
                        valores.Add(txtIdComando.Text);
                    }
                    else
                    {
                        NewId = (Tabla.GetNewId("comando", "idComando") > 0) ? Tabla.GetNewId("comando", "idComando") : (Tabla.GetNewId("comando", "idComando") + 1);
                        valores.Add(NewId.ToString());
                    }
                    valores.Add(txtComando.Text);

                    btnComandoNewSave.Tag      = "1";
                    btnComandoNewSave.Image    = Properties.Resources.new_;
                    btnComandoEditCancel.Tag   = "1";
                    btnComandoEditCancel.Image = Properties.Resources.edit;
                    groupBoxComando.Controls.OfType <TextBox>().ToList().ForEach(o => o.ReadOnly = true);

                    bool actualizacion;
                    int  filaActual = 0;
                    if (txtIdComando.TextLength > 0)
                    {
                        actualizacion = true;
                        filaActual    = dgComando.CurrentRow.Index;
                        Tabla.Update("comando", campos, valores, "idComando", txtIdComando.Text);
                    }
                    else
                    {
                        actualizacion = false;
                        Tabla.Insert("comando", campos, valores);
                    }

                    LlenarGridComando();

                    if (actualizacion)
                    {
                        dgComando.CurrentCell = dgComando.Rows[filaActual].Cells[0];
                    }
                    else
                    {
                        filaActual            = dgComando.Rows.Count - 1;
                        dgComando.CurrentCell = dgComando.Rows[dgComando.RowCount - 1].Cells[0];
                    }
                    LimpiarComandoForm();
                    CargarPermisosOtorgados();
                    CargarPermisosDisponibles();
                }
                else
                {
                    //MENSAJE VACIOS
                }
            }
        }
Beispiel #10
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (ComprobarDatos())
            {
                DBM.CLS.Transaccion Trans = new DBM.CLS.Transaccion();
                DBM.CLS.CRUD        Tabla = new DBM.CLS.CRUD();

                List <string> campos  = new List <string>();
                List <string> valores = new List <string>();

                campos.Add("idEgreso");
                campos.Add("idEgresoTipo");
                campos.Add("idCaja");
                campos.Add("idUsuario");
                campos.Add("fecha");
                campos.Add("cantidad");
                campos.Add("descripcion");
                campos.Add("nReferencia");

                if (txtId.TextLength > 0)
                {
                    valores.Add(txtId.Text);
                }
                else
                {
                    valores.Add((Tabla.GetNewId("egreso", "idEgreso") > 0) ? Tabla.GetNewId("egreso", "idEgreso").ToString() : (Tabla.GetNewId("egreso", "idEgreso") + 1).ToString());
                }

                valores.Add(cboTIpoEgreso.SelectedValue.ToString());
                valores.Add(txtIdCaja.Text);
                valores.Add(_SESION.idUsuario);
                valores.Add(txtFecha.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                string _cantidad = float.Parse(txtCantidad.Text.Replace(",", "."), NumberStyles.Float, CultureInfo.InvariantCulture).ToString("F2").Replace(",", ".");
                valores.Add(_cantidad);
                valores.Add(txtDescripcion.Text);
                valores.Add(txtNreferencia.Text);

                if (txtId.Text.Length > 0)
                {
                    //objEgreso.estado = Boolean.Parse(dgCaja.CurrentRow.Cells["estado"].Value.ToString());
                    if (Tabla.Update("egreso", campos, valores, "idEgreso", txtId.Text) > 0)
                    {
                        string QueryT = "";
                        MessageBox.Show("El registro se actualizó correctamente", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (float.Parse(cantidadOriginal) < float.Parse(_cantidad))
                        {
                            //MessageBox.Show("Es mayor", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            float    excedente = (float.Parse(_cantidad, NumberStyles.Float, CultureInfo.InvariantCulture) - float.Parse(cantidadOriginal, NumberStyles.Float, CultureInfo.InvariantCulture));
                            CLS.Caja objCaja   = new CLS.Caja();
                            QueryT = objCaja.RetiroCaja(excedente.ToString("F2").Replace(",", "."));
                        }
                        if (Double.Parse(cantidadOriginal) > Double.Parse(_cantidad))
                        {
                            //MessageBox.Show("Es menor", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            float    sobrante = (float.Parse(cantidadOriginal, NumberStyles.Float, CultureInfo.InvariantCulture) - float.Parse(_cantidad, NumberStyles.Float, CultureInfo.InvariantCulture));
                            CLS.Caja objCaja  = new CLS.Caja();
                            QueryT = objCaja.AbonarCaja(sobrante.ToString("F2").Replace(",", "."));
                        }
                        if (QueryT.Length > 0)
                        {
                            Trans.CreateTransaction(QueryT);
                        }

                        cargarGrid();
                        limpiar();
                    }
                    else
                    {
                        MessageBox.Show("El registro no se pudo actualizar", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    if (Tabla.Insert("egreso", campos, valores) > 0)
                    {
                        MessageBox.Show("El registro se guardó correctamente", "Confirmacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        CLS.Caja objCaja = new CLS.Caja();
                        Trans.CreateTransaction(objCaja.RetiroCaja(_cantidad));
                        cargarGrid();
                        limpiar();
                    }
                    else
                    {
                        MessageBox.Show("El registro no se pudo guardar", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }

                lblEfectivoDisponible.Text = obtenerSaldoCaja().ToString();
            }
        }
Beispiel #11
0
        //*****************************************************************************
        //* MANTENIMIENTO PROVEEDOR INDIVIDUAL(SIN GRIDVIEW)
        //*****************************************************************************

        private void btnProveedorNewSave_Click(object sender, EventArgs e)
        {
            int NewId = 0;

            if (btnProveedorNewSave.Tag.ToString() == "1")
            {
                btnProveedorNewSave.Tag      = "2";
                btnProveedorNewSave.Image    = Resources.save;
                btnProveedorEditCancel.Tag   = "2";
                btnProveedorEditCancel.Image = Properties.Resources.cancel;
                groupBoxProveedor.Controls.OfType <TextBox>().ToList().ForEach(o => o.ReadOnly = false);
                txtidProveedor.ReadOnly = true;
                LimpiarProveedorForm();
            }
            else
            {
                if (txtNombreProv.TextLength > 0 && txtDireccionProv.TextLength > 0)
                {
                    DBM.CLS.CRUD  Tabla  = new DBM.CLS.CRUD();
                    List <string> campos = new List <string>();
                    campos.Add("idProveedor");
                    campos.Add("nombre");
                    campos.Add("direccion");
                    campos.Add("email");
                    campos.Add("telefono");
                    campos.Add("NIT");
                    campos.Add("regContable");
                    campos.Add("contacto");

                    List <string> valores = new List <string>();
                    if (txtidProveedor.TextLength > 0)
                    {
                        valores.Add(txtidProveedor.Text);
                    }
                    else
                    {
                        NewId = (Tabla.GetNewId("proveedor", "idProveedor") > 0) ? Tabla.GetNewId("proveedor", "idProveedor") : (Tabla.GetNewId("proveedor", "idProveedor") + 1);
                        valores.Add(NewId.ToString());
                    }


                    valores.Add(txtNombreProv.Text);
                    valores.Add(txtDireccionProv.Text);
                    valores.Add(txtEmailProv.Text);
                    valores.Add(txtTelefonoProv.Text);
                    valores.Add(txtNITProv.Text);
                    valores.Add(txtNRCProv.Text);
                    valores.Add(txtContactoProv.Text);

                    btnProveedorNewSave.Tag   = "1";
                    btnProveedorNewSave.Image = Properties.Resources.new_;

                    btnProveedorEditCancel.Tag   = "1";
                    btnProveedorEditCancel.Image = Properties.Resources.edit;
                    groupBoxProveedor.Controls.OfType <TextBox>().ToList().ForEach(o => o.ReadOnly = true);

                    bool actualizacion;
                    int  filaActual = 0;
                    if (txtidProveedor.TextLength > 0)
                    {
                        actualizacion = true;
                        filaActual    = dgProveedor.CurrentRow.Index;
                        Tabla.Update("proveedor", campos, valores, "idProveedor", txtidProveedor.Text);
                    }
                    else
                    {
                        actualizacion = false;

                        Tabla.Insert("proveedor", campos, valores);
                    }

                    LlenarGridProveedor();
                    dgProveedor.Refresh();

                    if (actualizacion)
                    {
                        dgProveedor.CurrentCell = dgProveedor.Rows[filaActual].Cells[0];
                    }
                    else
                    {
                        filaActual = dgProveedor.Rows.Count - 1;
                        dgProveedor.CurrentCell = dgProveedor.Rows[dgProveedor.RowCount - 1].Cells[0];
                        //dgProducto.CurrentCell = dgProducto.Rows[filaActual].Cells[0];
                    }
                    LimpiarProveedorForm();
                }
                else
                {
                    //MENSAJE VACIOS
                }
            }
        }
Beispiel #12
0
        //*****************************************************************************
        //* MANTENIMIENTO PRODUCTO INDIVIDUAL(SIN GRIDVIEW)
        //*****************************************************************************


        private void btnProductoNewSave_Click(object sender, EventArgs e)
        {
            int NewId = 0;

            if (btnProductoNewSave.Tag.ToString() == "1")
            {
                btnProductoNewSave.Tag      = "2";
                btnProductoNewSave.Image    = Resources.save;
                btnProductoEditCancel.Tag   = "2";
                btnProductoEditCancel.Image = Properties.Resources.cancel;
                groupBoxProducto.Controls.OfType <TextBox>().ToList().ForEach(o => o.ReadOnly = false);
                LimpiarProductoForm();
            }
            else
            {
                if (txtDescripcion.TextLength > 0 && txtPrecio.TextLength > 0 && txtCosto.TextLength > 0 && txtStock.TextLength > 0 && txtStockMinimo.TextLength > 0)
                {
                    DBM.CLS.CRUD  Tabla  = new DBM.CLS.CRUD();
                    List <string> campos = new List <string>();
                    campos.Add("idProducto");

                    campos.Add("IdFamilia");
                    campos.Add("idUnidad");
                    campos.Add("idTipo");
                    campos.Add("idMarca");

                    campos.Add("descripcion");
                    campos.Add("precio");
                    campos.Add("costo");
                    campos.Add("stock");
                    campos.Add("stockMinimo");
                    campos.Add("inventariable");
                    campos.Add("activo");

                    List <string> valores = new List <string>();
                    if (txtIdProducto.TextLength > 0)
                    {
                        valores.Add(txtIdProducto.Text);
                    }
                    else
                    {
                        NewId = (Tabla.GetNewId("producto", "idProducto") > 0) ? Tabla.GetNewId("producto", "idProducto") : (Tabla.GetNewId("producto", "idProducto") + 1);
                        valores.Add(NewId.ToString());
                    }
                    valores.Add(cboCategoria.SelectedValue.ToString());
                    valores.Add(cboPresentacion.SelectedValue.ToString());
                    valores.Add(cboTipoProducto.SelectedValue.ToString());
                    valores.Add(cboMarca.SelectedValue.ToString());

                    valores.Add(txtDescripcion.Text);
                    valores.Add(txtPrecio.Text);
                    valores.Add(txtCosto.Text);
                    valores.Add(txtStock.Text);
                    valores.Add(txtStockMinimo.Text);
                    valores.Add(chkInventariable.Checked ? "1" : "0");
                    valores.Add(chkMostrar.Checked ? "1" : "0");

                    btnProductoNewSave.Tag   = "1";
                    btnProductoNewSave.Image = Properties.Resources.new_;

                    btnProductoEditCancel.Tag   = "1";
                    btnProductoEditCancel.Image = Properties.Resources.edit;
                    groupBoxProducto.Controls.OfType <TextBox>().ToList().ForEach(o => o.ReadOnly = true);

                    bool actualizacion;
                    int  filaActual = 0;
                    if (txtIdProducto.TextLength > 0)
                    {
                        actualizacion = true;
                        filaActual    = dgProducto.CurrentRow.Index;
                        Tabla.Update("producto", campos, valores, "idProducto", txtIdProducto.Text);
                    }
                    else
                    {
                        actualizacion = false;

                        Tabla.Insert("producto", campos, valores);
                    }

                    LlenarGridProducto();
                    dgProducto.Refresh();

                    if (actualizacion)
                    {
                        dgProducto.CurrentCell = dgProducto.Rows[filaActual].Cells[0];
                    }
                    else
                    {
                        filaActual             = dgProducto.Rows.Count - 1;
                        dgProducto.CurrentCell = dgProducto.Rows[dgProducto.RowCount - 1].Cells[0];
                        //dgProducto.CurrentCell = dgProducto.Rows[filaActual].Cells[0];
                    }
                    LimpiarProductoForm();
                }
                else
                {
                    //MENSAJE VACIOS
                }
            }
        }