コード例 #1
0
 private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
 {
     c = new Consultas();
     try
     {
         if (e.KeyChar == (char)Keys.Return)
         {
             em = c.ConsutarFactura(int.Parse(txtSucursal.Text), int.Parse(txtCaja.Text), int.Parse(txtNumFact.Text), 2);
             if (em != null)
             {
                 product = c.detalleFact;
                 if (product.Count > 0)
                 {
                     limpiarDGV();
                     llenarDgV();
                     lblUsuario.Text            = "Usuario: " + em.NombreUsuario;
                     txtCliente.Text            = em.NombresCliente;
                     DgvDetalleFact.CurrentCell = DgvDetalleFact.Rows[0].Cells[0];
                     DgvDetalleFact.BeginEdit(true);
                 }
                 else
                 {
                     MessageBox.Show("Todos los Items de esta factura ya Fueron dados de baja.");
                     LimpiarTodo();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("" + ex.Message);
     }
 }
コード例 #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     c = new Consultas();
     try
     {
         ObtenerPedidos();
         if (indezp.Count > 0)
         {
             if (!verificarNull())
             {
                 if (!verificarLimites())
                 {
                     if (MessageBox.Show("¿Estas seguro de darle de baja a estos Items?", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                     {
                         bool b = c.DevolucionVenta(pedidos, Convert.ToInt32(txtNumFact.Text));
                         if (b)
                         {
                             MessageBox.Show("Cambios realizados con exito.");
                             LimpiarTodo();
                         }
                         else
                         {
                             MessageBox.Show("Error al realizar devolucion.");
                         }
                     }
                 }
                 else
                 {
                     MessageBox.Show("Hay una cantidad que sobrepasa a la cantidad vendida.\nFila: " + posicion + 1);
                     DgvDetalleFact.CurrentCell = DgvDetalleFact.Rows[posicion].Cells[6];
                     DgvDetalleFact.BeginEdit(true);
                 }
             }
             else
             {
                 MessageBox.Show("Hay un producto seleccionado sin cantidad.\nPor favor ingresa la cantidad. Fila: " + posicion + 1);
                 DgvDetalleFact.CurrentCell = DgvDetalleFact.Rows[posicion].Cells[6];
                 DgvDetalleFact.BeginEdit(true);
             }
         }
         else
         {
             MessageBox.Show("Selecciona al menos un Item.");
         }
     }
     catch (Exception)
     {
         //throw;
     }
 }
コード例 #3
0
        private void txtModificarVer_Click(object sender, EventArgs e)
        {
            if (dgvDatosProducto.RowCount > 0 && dgvDatosProducto.CurrentRow.Cells[1].Value != null)
            {
                modificar                  = true;
                BtnGuardar.Text            = "Modificar";
                encabezadoNotaCreditoVenta = Convert.ToInt32(dgvDatosProducto.CurrentRow.Cells[6].Value);
                tabControl1.SelectedIndex  = 0;
                DataTable encabezadoPie = c.BoolDataTable("select * from TbEncabezadoNotaDebito where IDENCABEZADONOTADEBITO = " + encabezadoNotaCreditoVenta);
                if (encabezadoPie.Rows.Count > 0)
                {
                    DataRow rowEncabezado = encabezadoPie.Rows[0];
                    txtSerie1ND.Text = rowEncabezado["SERIE1"].ToString();
                    txtSerie2ND.Text = rowEncabezado["SERIE2"].ToString();
                    txtNumeroND.Text = rowEncabezado["NUMERO"].ToString();

                    string seriefactura = dgvDatosProducto.CurrentRow.Cells[2].Value.ToString();
                    txtSucursal.Text = seriefactura.Substring(0, 3);
                    txtCaja.Text     = seriefactura.Substring(3, 3);
                    txtNumFact.Text  = seriefactura.Substring(6, 9);

                    txtCliente.Text         = dgvDatosProducto.CurrentRow.Cells[3].Value.ToString();
                    txtTotalDevolucion.Text = dgvDatosProducto.CurrentRow.Cells[4].Value.ToString();
                    txtTotalFactura.Text    = dgvDatosProducto.CurrentRow.Cells[5].Value.ToString();
                    DataTable detalleNotaCreditoVentas = c.BoolDataTable("select * from TbDetalleNotaDebito where IDENCABEZADONOTADEBITO = " + dgvDatosProducto.CurrentRow.Cells[6].Value);
                    if (detalleNotaCreditoVentas.Rows.Count > 0)
                    {
                        em = c.ConsutarFactura(int.Parse(txtSucursal.Text), int.Parse(txtCaja.Text), int.Parse(txtNumFact.Text), 2);
                        if (em != null)
                        {
                            product = c.detalleFact;
                            if (product.Count > 0)
                            {
                                limpiarDGV();
                                llenarDgV();
                                lblUsuario.Text            = "Usuario: " + em.NombreUsuario;
                                txtCliente.Text            = em.NombresCliente;
                                DgvDetalleFact.CurrentCell = DgvDetalleFact.Rows[0].Cells[0];
                                DgvDetalleFact.BeginEdit(true);
                            }
                            else
                            {
                                MessageBox.Show("Todos los Items de esta factura ya Fueron dados de baja.");
                                LimpiarTodo();
                            }
                        }

                        for (int i = 0; i < detalleNotaCreditoVentas.Rows.Count; i++)
                        {
                            DataRow rowDetalleCredito = detalleNotaCreditoVentas.Rows[i];
                            if (DgvDetalleFact.Rows[i].Cells[0].Value != null)
                            {
                                if (DgvDetalleFact.Rows[i].Cells[0].Value.ToString() == rowDetalleCredito["CODIGOBARRA"].ToString())
                                {
                                    DgvDetalleFact.Rows[i].Cells[6].Value = rowDetalleCredito["CANTIDAD"].ToString();
                                }
                                if (DgvDetalleFact.Rows[i].Cells[6].Value.ToString() != "0")
                                {
                                    DgvDetalleFact.Rows[i].Cells[7].Value = true;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                pedidos.Clear();
                ObtenerPedidos();

                if (indezp.Count > 0)
                {
                    //if (!verificarNull())
                    //{
                    if (!verificarLimites())
                    {
                        if (!modificar)
                        {
                            if (MessageBox.Show("¿Estas seguro de darle de baja a estos Items?", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                bool b = c.DevolucionVenta(pedidos, Convert.ToInt32(txtNumFact.Text));
                                if (b)
                                {
                                    string idEncabezado = c.ObtenerValorCampo("IDFACTURA", "TbEncabezadoFactura", "where SUCURSAL = " + Convert.ToInt32(txtSucursal.Text) + " AND CAJA = " + Convert.ToInt32(txtCaja.Text) + " and NFACTURA =" + Convert.ToInt32(txtNumFact.Text) + "");
                                    objEND = new EncabezadoNotaDebito(txtSerie1ND.Text, txtSerie2ND.Text, txtNumeroND.Text, Convert.ToInt32(idEncabezado), Convert.ToSingle(txtTotalDevolucion.Text));
                                    string resultado = objEND.InsertarEncabezadoND(objEND);
                                    if (resultado == "Datos Guardados")
                                    {
                                        string encabezadoND    = c.ObtenerValorCampo("IDENCABEZADONOTADEBITO", "TbEncabezadoNotaDebito", "WHERE IDENCABEZADOVENTA =" + idEncabezado);
                                        bool   banderaCorrecto = false;
                                        for (int i = 0; i < DgvDetalleFact.RowCount - 1; i++)
                                        {
                                            if (Convert.ToString(DgvDetalleFact.Rows[i].Cells[6].Value) != "")
                                            {
                                                objDND = new DetalleNotaDebito(Convert.ToInt32(encabezadoND), Convert.ToInt32(DgvDetalleFact.Rows[i].Cells[6].Value), Convert.ToString(DgvDetalleFact.Rows[i].Cells[0].Value));
                                                string resultado2 = objDND.InsertarDetalleND(objDND);
                                                if (resultado == "Datos Guardados")
                                                {
                                                    banderaCorrecto = true;
                                                }
                                                else
                                                {
                                                    banderaCorrecto = false;
                                                }
                                            }
                                            if (Convert.ToString(DgvDetalleFact.Rows[i + 1].Cells[0].Value) == "")
                                            {
                                                break;
                                            }
                                        }
                                        if (banderaCorrecto)
                                        {
                                            MessageBox.Show("Cambios realizados con exito.");
                                            string numeroND = (Convert.ToInt32(txtNumeroND.Text) + 1).ToString("D9");
                                            c.EjecutarSQL("UPDATE [dbo].[TbCajasTalonario] SET [DOCUMENTOACTUAL] = '" + numeroND + "' WHERE SERIE1 = '" + txtSerie1ND.Text + "' and SERIE2 = '" + txtSerie2ND.Text + "' and IPESTACION = '" + bitacora.LocalIPAddress() + "' and TIPODOCUMENTO = 'NDEB'");
                                            c.seriesDocumentoRetencion(txtNumeroND, txtSerie1ND, txtSerie2ND, txtAutorizacionND, "NDEB", bitacora.LocalIPAddress());
                                        }
                                        else
                                        {
                                            MessageBox.Show("Error al guardar la Nota de Crédito", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                            c.EjecutarSQL("DELETE FROM [dbo].[TbDetalleNotaDebito] WHERE IDENCABEZADONOTADEBITO = " + encabezadoND + "");
                                            c.EjecutarSQL("DELETE FROM [dbo].[TbEncabezadoNotaDebito] WHERE IDENCABEZADOVENTA = " + idEncabezado + "");
                                        }
                                    }
                                    else if (resultado == "Error al Registrar")
                                    {
                                        MessageBox.Show("Error al guardar la Nota de Crédito", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        c.EjecutarSQL("DELETE FROM [dbo].[TbEncabezadoNotaDebito] WHERE IDENCABEZADOVENTA = " + idEncabezado + "");
                                    }
                                    else if (resultado == "Existe")
                                    {
                                        MessageBox.Show("Ya existe la Nota de Crédito", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                    LimpiarTodo();
                                }
                                else
                                {
                                    MessageBox.Show("Error al realizar devolucion.");
                                }
                            }
                        }
                        else
                        {
                            if (MessageBox.Show("¿Estas seguro de modificar?", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                bool resultado = c.modificarNotadeDebito(DgvDetalleFact, encabezadoNotaCreditoVenta);
                                if (resultado)
                                {
                                    MessageBox.Show("Cambios realizados con exito.");
                                }
                                else
                                {
                                    MessageBox.Show("Error al realizar el cambio.");
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Hay una cantidad que sobrepasa a la cantidad vendida.\nFila: " + posicion + 1);
                        DgvDetalleFact.CurrentCell = DgvDetalleFact.Rows[posicion].Cells[6];
                        //DgvDetalleFact.BeginEdit(true);
                    }
                }
                else
                {
                    MessageBox.Show("Hay un producto seleccionado sin cantidad.\nPor favor ingresa la cantidad. Fila: " + posicion + 1);
                    DgvDetalleFact.CurrentCell = DgvDetalleFact.Rows[posicion].Cells[6];
                    DgvDetalleFact.BeginEdit(true);
                }
                //}
                //else
                //{
                //    MessageBox.Show("Selecciona al menos un Item.");
                //}
            }
            catch (Exception)
            {
                //throw;
            }
        }