private void btnGrabar_Click(object sender, EventArgs e)
        {
            if (GrillaPresupuesto.Rows.Count < 1)
            {
                Mensaje("Debe ingresar registros para continuar");
                return;
            }

            int          b              = 0;
            cPresupuesto prep           = new cPresupuesto();
            Int32        CodPresupuesto = 0;

            if (txtCodPresupuesto.Text != "")
            {
                CodPresupuesto = Convert.ToInt32(txtCodPresupuesto.Text);
                DataTable trdo = prep.GetPresupuestoxCodigo(CodPresupuesto);
                if (trdo.Rows.Count > 0)
                {
                    if (trdo.Rows[0]["Procesado"].ToString() != "1")
                    {
                        b = 1;
                    }
                }
            }
            if (b == 0)
            {
                Mensaje("Ya se proceso el presupuesto");
                return;
            }
            GrabarVenta();
        }
Beispiel #2
0
        private void Buscar()
        {
            cPresupuesto prep       = new cPresupuesto();
            DateTime     FechaDesde = Convert.ToDateTime(txtFechaDesde.Text);
            DateTime     FechaHasta = Convert.ToDateTime(txtFechaHasta.Text);
            DataTable    trdo       = prep.GetPresupuesto(FechaDesde, FechaHasta);

            trdo = fun.TablaaMiles(trdo, "Total");
            Grilla.DataSource = trdo;
            fun.AnchoColumnas(Grilla, "0;15;35;35;15");
        }
Beispiel #3
0
        private void BuscarPresupuesto(Int32 CodPresupuesto)
        {   //string Col = "CodArticulo;Nombre;Precio;Cantidad;Subtotal";
            cPresupuesto prep        = new cPresupuesto();
            DataTable    trdo        = prep.GetPresupuestoxCod(CodPresupuesto);
            string       CodArticulo = "";
            string       Nombre      = "";
            string       Precio      = "";
            string       Cantidad    = "";
            string       Subtotal    = "";
            string       Val         = "";

            if (trdo.Rows.Count > 0)
            {/*
              * if (trdo.Rows[0]["CodTarjeta"].ToString() != "")
              * {
              *     CmbTarjeta.SelectedValue = trdo.Rows[0]["CodTarjeta"].ToString();
              *     txtCupon.Text = trdo.Rows[0]["Cupon"].ToString();
              *     CmbTarjeta.Visible = true;
              *     txtCupon.Visible = true;
              * }
              */
                if (trdo.Rows[0]["CodCliente"].ToString() != "")
                {
                    Int32 CodCli = Convert.ToInt32(trdo.Rows[0]["CodCliente"].ToString());
                    BuscarCliente(CodCli);
                }
                for (int i = 0; i < trdo.Rows.Count; i++)
                {
                    CodArticulo = trdo.Rows[i]["CodArticulo"].ToString();
                    Nombre      = trdo.Rows[i]["Nombre"].ToString();
                    Precio      = trdo.Rows[i]["Precio"].ToString();
                    Cantidad    = trdo.Rows[i]["Cantidad"].ToString();
                    Subtotal    = trdo.Rows[i]["Subtotal"].ToString();
                    Val         = CodArticulo + ";" + Nombre;
                    Val         = Val + ";" + Precio + ";" + Cantidad;
                    Val         = Val + ";" + Subtotal;
                    tbVenta     = fun.AgregarFilas(tbVenta, Val);
                }
                Grilla.DataSource         = tbVenta;
                Grilla.Columns[0].Visible = false;
                Grilla.Columns[5].Visible = false;
                Grilla.Columns[1].Width   = 370;
                Double Total = fun.TotalizarColumna(tbVenta, "Subtotal");
                txtTotal.Text       = Total.ToString();
                txtTotal.Text       = fun.FormatoEnteroMiles(txtTotal.Text);
                btnGrabar.Enabled   = false;
                btnCancelar.Enabled = false;
            }
        }
        private void GrabarVenta()
        {
            DateTime     Fecha              = Convert.ToDateTime(txtFecha.Text);
            Int32?       CodVendedor        = null;
            Int32        CodVenta           = 0;
            cVentaJoya   venta              = new cVentaJoya();
            cPresupuesto prep               = new cPresupuesto();
            cJoya        joya               = new cJoya();
            int          Cantidad           = 0;
            Int32        CodJoya            = 0;
            Double       Precio             = 0;
            Double       Comision           = 0;
            Int32        CodRegistro        = 0;
            Int32        CodPresupuesto     = 0;
            Double       Total              = 0;
            Double       TotalComision      = 0;
            Double       TotalVentaComision = 0;

            if (txtCodVendedor.Text != "")
            {
                CodVendedor = Convert.ToInt32(txtCodVendedor.Text);
            }
            if (txtCodPresupuesto.Text != "")
            {
                CodPresupuesto = Convert.ToInt32(txtCodPresupuesto.Text);
            }
            if (txtTotal.Text != "")
            {
                Total = fun.ToDouble(txtTotal.Text);
            }

            if (txtTotalComision.Text != "")
            {
                TotalComision = fun.ToDouble(txtTotalComision.Text);
            }

            if (txtTotalConComision.Text != "")
            {
                TotalVentaComision = fun.ToDouble(txtTotalConComision.Text);
            }

            SqlTransaction Transaccion;
            SqlConnection  con = new SqlConnection(cConexion.GetConexion());

            con.Open();
            Transaccion = con.BeginTransaction();

            try
            {
                CodVenta = venta.InsertarVenta(con, Transaccion, CodVendedor, Fecha, CodPresupuesto, Total, TotalComision, TotalVentaComision);
                prep.ActualizarProcesado(con, Transaccion, CodPresupuesto);
                for (int i = 0; i < tbVenta.Rows.Count; i++)
                {
                    CodRegistro = Convert.ToInt32(tbVenta.Rows[i]["CodRegistro"]);
                    CodJoya     = Convert.ToInt32(tbVenta.Rows[i]["CodJoya"]);
                    Cantidad    = Convert.ToInt32(tbVenta.Rows[i]["Cantidad"]);
                    Precio      = fun.ToDouble(tbVenta.Rows[i]["Precio"].ToString());
                    Comision    = fun.ToDouble(tbVenta.Rows[i]["Comision"].ToString());
                    venta.InsertarDetalleVenta(con, Transaccion, CodVenta, CodJoya, Cantidad, Precio, CodRegistro, Comision);
                    joya.ActualizarStock(con, Transaccion, CodJoya, Cantidad);
                }
                Transaccion.Commit();
                con.Close();
                Mensaje("Datos grabados correctamente");
                Limpiar();
            }
            catch (Exception exa)
            {
                MessageBox.Show(exa.Message.ToString());
                Transaccion.Rollback();
                con.Close();
                Mensaje("Hubo un error en el proceso de grabacion");
                Mensaje(exa.Message);
            }
        }
Beispiel #5
0
        private void GrabarPresupuesto()
        {
            SqlTransaction Transaccion;
            SqlConnection  con = new SqlConnection(cConexion.GetConexion());

            con.Open();
            Transaccion = con.BeginTransaction();
            DateTime Fecha      = Convert.ToDateTime(txtFechaAltaOrden.Text);
            Int32?   CodCliente = null;

            cCliente cli            = new cCliente();
            Int32    CodPresupuesto = 0;
            Int32    CodArticulo    = 0;
            Double   Precio         = 0;
            Int32    Cantidad       = 0;
            Double   Subtotal       = 0;
            Double   Total          = 0;

            if (txtTotal.Text != "")
            {
                Total = Convert.ToDouble(txtTotal.Text);
            }
            cArticulo objArt            = new Clases.cArticulo();
            string    Cupon             = txtCupon.Text;
            Double    Descuento         = 0;
            Double    PorDescuento      = 0;
            Double    TotalConDescuento = 0;
            string    FormaPago         = "";

            if (txtPordescuento.Text != "")
            {
                PorDescuento = Convert.ToDouble(txtPordescuento.Text);
            }

            if (txtTotalDescuento.Text != "")
            {
                Descuento = Convert.ToDouble(txtTotalDescuento.Text);
            }

            if (txtTotalConDescuento.Text != "")
            {
                TotalConDescuento = Convert.ToDouble(txtTotalConDescuento.Text);
            }

            // string Col = "CodArticulo;Nombre;Precio;Cantidad;Subtotal";
            cPresupuesto pre = new cPresupuesto();

            try
            {
                if (txtNombre.Text != "")
                {
                    if (txtCodCliente.Text == "")
                    {
                        CodCliente = GrabarCliente(con, Transaccion);
                    }
                    else
                    {
                        ModificarCliente(con, Transaccion);
                        CodCliente = Convert.ToInt32(txtCodCliente.Text);
                    }
                }

                FormaPago      = GetFormaPago();
                CodPresupuesto = pre.InsertarPresupuesto(con, Transaccion, Total,
                                                         Fecha
                                                         , CodCliente, Descuento, PorDescuento, TotalConDescuento, FormaPago);
                Principal.CodigoSenia = CodPresupuesto.ToString();
                string NroPresupuesto = "0001-" + GetNroPresupueto(CodPresupuesto.ToString());
                pre.ActualizarNroPresupuesto(con, Transaccion, CodPresupuesto, NroPresupuesto);
                for (int i = 0; i < tbVenta.Rows.Count; i++)
                {
                    CodArticulo = Convert.ToInt32(tbVenta.Rows[i]["CodArticulo"].ToString());
                    Precio      = Convert.ToDouble(tbVenta.Rows[i]["Precio"].ToString());
                    Cantidad    = Convert.ToInt32(tbVenta.Rows[i]["Cantidad"].ToString());
                    Subtotal    = Convert.ToDouble(tbVenta.Rows[i]["Subtotal"].ToString());
                    pre.InsertarDetalle(con, Transaccion, CodPresupuesto, Cantidad, Precio, CodArticulo, Subtotal);
                }
                Transaccion.Commit();
                con.Close();
                Mensaje("Datos grabados correctamente");
                Limpiar();
                FrmReporte frm = new SistemaFact.FrmReporte();
                frm.Show();
                // this.GetJugadorxCodigoTableAdapter.Fill(this.DataSet1.GetJugadorxCodigo, Codigo);
            }
            catch (Exception exa)
            {
                Transaccion.Rollback();
                con.Close();
                Mensaje("Hubo un error en el proceso de grabacion");
                Mensaje(exa.Message);
            }
        }
        private void GrabarPresupuesto()
        {
            SqlTransaction Transaccion;
            SqlConnection  con = new SqlConnection(cConexion.GetConexion());

            con.Open();
            Transaccion = con.BeginTransaction();
            DateTime  Fecha = Convert.ToDateTime(txtFecha.Text);
            Int32?    CodVendedor = null;
            string    Nombre = "", Apellido = "";
            string    NroDocumento = "", Telefono = "";
            string    Direccion = "";
            Int32?    CodCiudad = null;
            cVendedor vendedor  = new cVendedor();

            Nombre       = txtNombre.Text;
            Apellido     = txtApellido.Text;
            Telefono     = txtTelefono.Text;
            NroDocumento = txtNroDocumento.Text;
            Direccion    = txtDireccion.Text;
            string Ciudad = "", Provincia = "";
            string DomicilioCompleto = "";

            if (cmbCiudad.SelectedIndex > 0)
            {
                CodCiudad = Convert.ToInt32(cmbCiudad.SelectedValue);
                Ciudad    = cmbCiudad.Text;
            }
            if (cmbProvincia.SelectedIndex > 0)
            {
                Provincia = cmbProvincia.Text;
            }

            if (Direccion != "")
            {
                DomicilioCompleto = Direccion;
            }
            if (Ciudad != "")
            {
                DomicilioCompleto = DomicilioCompleto + " " + Ciudad;
            }
            if (Provincia != "")
            {
                DomicilioCompleto = DomicilioCompleto + " " + Provincia;
            }

            Int32    CodPresupuesto = 0;
            Int32    CodJoya        = 0;
            Double   Precio         = 0;
            Int32    Cantidad       = 0;
            DateTime?FechaRendicion = null;
            Double   SubTotal       = 0;
            Double   Total          = 0;

            if (txtTotal.Text != "")
            {
                Total = Convert.ToDouble(txtTotal.Text);
            }
            if (txtFechaRendicion.Text != "  /  /")
            {
                FechaRendicion = Convert.ToDateTime(txtFechaRendicion.Text);
            }
            // string Col = "CodArticulo;Nombre;Precio;Cantidad;Subtotal";
            int          Orden = 1;
            cPresupuesto pre   = new cPresupuesto();

            try
            {
                if (txtCodVendedor.Text == "")
                {
                    CodVendedor = (Int32)vendedor.InsertarVendedorTran(con, Transaccion, Apellido, Nombre, Telefono, NroDocumento, Direccion, CodCiudad, DomicilioCompleto);
                }
                else
                {
                    CodVendedor = Convert.ToInt32(txtCodVendedor.Text);
                    vendedor.ActualizarVendedor(con, Transaccion, Convert.ToInt32(CodVendedor), Apellido, Nombre, Telefono, NroDocumento, Direccion, CodCiudad, DomicilioCompleto);
                }


                CodPresupuesto = pre.InsertarPresupuesto(con, Transaccion, Total,
                                                         Fecha
                                                         , CodVendedor, FechaRendicion);

                Principal.CodigoSenia = CodPresupuesto.ToString();
                string NroPresupuesto = GetNroPresupueto(CodPresupuesto.ToString());
                pre.ActualizarNroPresupuesto(con, Transaccion, CodPresupuesto, NroPresupuesto);
                for (int i = 0; i < tbDetalle.Rows.Count; i++)
                {
                    CodJoya  = Convert.ToInt32(tbDetalle.Rows[i]["CodJoya"].ToString());
                    Precio   = Convert.ToDouble(tbDetalle.Rows[i]["Precio"].ToString());
                    Cantidad = Convert.ToInt32(tbDetalle.Rows[i]["Cantidad"].ToString());
                    SubTotal = Convert.ToDouble(tbDetalle.Rows[i]["SubTotal"].ToString());
                    pre.InsertarDetalle(con, Transaccion, CodPresupuesto, Cantidad, Precio, CodJoya, SubTotal, Orden);
                    Orden++;
                }
                Transaccion.Commit();
                con.Close();
                Mensaje("Datos grabados correctamente");
                Principal.CodigoPrincipalAbm = CodPresupuesto.ToString();
                FrmVerReportePresupuesto frm = new FrmVerReportePresupuesto();
                frm.Show();
                Limpiar();
                // FrmReporte frm = new SistemaFact.FrmReporte();
                // frm.Show();
                // this.GetJugadorxCodigoTableAdapter.Fill(this.DataSet1.GetJugadorxCodigo, Codigo);
            }
            catch (Exception exa)
            {
                MessageBox.Show(exa.Message.ToString());
                Transaccion.Rollback();
                con.Close();
                Mensaje("Hubo un error en el proceso de grabacion");
                Mensaje(exa.Message);
            }
        }