Esempio n. 1
0
        private void txt_Codigo_TextChanged(object sender, EventArgs e)
        {
            string Codigo = txt_Codigo.Text;
            cJoya  joya   = new cJoya();

            if (Codigo.Length > 2)
            {
                DataTable trdo = joya.GetJoyaxCodigo(Codigo);
                if (trdo.Rows.Count > 0)
                {
                    txt_Codigo.Text      = trdo.Rows[0]["Codigo"].ToString();
                    txtCodigo.Text       = trdo.Rows[0]["CodJoya"].ToString();
                    txt_Nombre.Text      = trdo.Rows[0]["Nombre"].ToString();
                    txt_Stock.Text       = trdo.Rows[0]["Stock"].ToString();
                    txt_PrecioVenta.Text = trdo.Rows[0]["PrecioVenta"].ToString();
                    if (trdo.Rows[0]["CodTipo"].ToString() != "")
                    {
                        {
                            cmb_CodTipo.SelectedValue = trdo.Rows[0]["CodTipo"].ToString();
                        }

                        if (txt_PrecioVenta.Text != "")
                        {
                            cFunciones fun         = new cFunciones();
                            Double     PrecioVenta = Convert.ToDouble(txt_PrecioVenta.Text.Replace(".", ","));
                            txt_PrecioVenta.Text = Math.Round(PrecioVenta, 0).ToString();
                            txt_PrecioVenta.Text = fun.SepararDecimales(txt_PrecioVenta.Text);
                            txt_PrecioVenta.Text = fun.FormatoEnteroMiles(txt_PrecioVenta.Text);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void CargarGrilla(string Nombre, string Codigo)
        {
            cFunciones fun  = new cFunciones();
            cJoya      joya = new cJoya();
            DataTable  trdo = joya.GetJoyas();

            // trdo = fun.TablaaMiles(trdo, "PrecioEfectivo");

            Grilla.DataSource = trdo;
            //Grilla.Columns[0].Visible = false;
            fun.AnchoColumnas(Grilla, "0;10;35;35;10;10");
            DataGridViewCellStyle style = new DataGridViewCellStyle();

            style.Font = new Font(Grilla.Font, FontStyle.Bold);
            //    Grilla.Columns[8].DefaultCellStyle = style;
            //Grilla.Rows[8].DefaultCellStyle = style;
        }
        private void txtCodigoBarra_TextChanged(object sender, EventArgs e)
        {
            string Codigo = txtCodigoBarra.Text;
            int    b      = 0;

            if (Codigo.Length > 8)
            {
                cJoya     joya = new cJoya();
                DataTable trdo = joya.GetJoyaxCodigoBarra(Codigo);
                if (trdo.Rows.Count > 0)
                {
                    if (trdo.Rows[0]["CodJoya"].ToString() != "")
                    {
                        b = 1;
                        txtCodJoya.Text    = trdo.Rows[0]["CodJoya"].ToString();
                        txtNombreJoya.Text = trdo.Rows[0]["Nombre"].ToString();
                        txtStock.Text      = trdo.Rows[0]["Stock"].ToString();
                        txtPrecio.Text     = trdo.Rows[0]["PrecioVenta"].ToString();
                        if (trdo.Rows[0]["CodTipo"].ToString() != "")
                        {
                            cmbTipo.SelectedValue = trdo.Rows[0]["CodTipo"].ToString();
                        }
                        if (txtPrecio.Text != "")
                        {
                            txtPrecio.Text = fun.SepararDecimales(txtPrecio.Text);
                            txtPrecio.Text = fun.FormatoEnteroMiles(txtPrecio.Text);
                        }
                        AgregaCodigoBarra = true;
                    }
                }
            }
            if (b == 0)
            {
                txtCodJoya.Text    = "";
                txtNombreJoya.Text = "";
                txtStock.Text      = "";
                if (cmbTipo.Items.Count > 0)
                {
                    cmbTipo.SelectedIndex = 0;
                }
            }
        }
        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);
            }
        }
        private void form_FormClosing(object sender, FormClosingEventArgs e)
        {
            cVendedor ven   = new cVendedor();
            string    Tabla = Principal.TablaPrincipal;

            if (Principal.CodigoPrincipalAbm != null)
            {
                switch (Tabla)
                {
                case "Vendedor":
                    Int32     CodVendedor = Convert.ToInt32(Principal.CodigoPrincipalAbm);
                    DataTable trdo        = ven.GetVendedorxCodVendedor(CodVendedor);
                    if (trdo.Rows.Count > 0)
                    {
                        if (trdo.Rows.Count > 0)
                        {
                            if (trdo.Rows[0]["CodVendedor"].ToString() != "")
                            {
                                txtNroDocumento.Text = trdo.Rows[0]["NroDocumento"].ToString();
                                txtCodVendedor.Text  = trdo.Rows[0]["CodVendedor"].ToString();
                                txtNombre.Text       = trdo.Rows[0]["Nombre"].ToString();
                                txtApellido.Text     = trdo.Rows[0]["Apellido"].ToString();
                                txtDireccion.Text    = trdo.Rows[0]["Direccion"].ToString();
                                txtTelefono.Text     = trdo.Rows[0]["Telefono"].ToString();

                                if (trdo.Rows[0]["CodProvincia"].ToString() != "")
                                {
                                    Int32 CodProv = Convert.ToInt32(trdo.Rows[0]["CodProvincia"].ToString());
                                    CargarCiudadxProv(CodProv);
                                    cmbProvincia.SelectedValue = CodProv.ToString();
                                }

                                if (trdo.Rows[0]["CodCiudad"].ToString() != "")
                                {
                                    Int32 CodCiudad = Convert.ToInt32(trdo.Rows[0]["CodCiudad"].ToString());
                                    cmbCiudad.SelectedValue = CodCiudad.ToString();
                                }
                            }
                        }
                    }
                    break;

                case "Joya":
                    cJoya     joya    = new cJoya();
                    Int32     CodJoya = Convert.ToInt32(Principal.CodigoPrincipalAbm);
                    DataTable trJoya  = joya.GetJoyaxCodJoya(CodJoya);
                    if (trJoya.Rows.Count > 0)
                    {
                        if (trJoya.Rows[0]["CodJoya"].ToString() != "")
                        {
                            txtCodigo.Text     = trJoya.Rows[0]["Codigo"].ToString();
                            txtCodJoya.Text    = trJoya.Rows[0]["CodJoya"].ToString();
                            txtNombreJoya.Text = trJoya.Rows[0]["Nombre"].ToString();
                            txtStock.Text      = trJoya.Rows[0]["Stock"].ToString();
                            txtPrecio.Text     = trJoya.Rows[0]["PrecioVenta"].ToString();
                            if (trJoya.Rows[0]["CodTipo"].ToString() != "")
                            {
                                cmbTipo.SelectedValue = trJoya.Rows[0]["CodTipo"].ToString();
                            }
                            if (txtPrecio.Text != "")
                            {
                                txtPrecio.Text = fun.SepararDecimales(txtPrecio.Text);
                                txtPrecio.Text = fun.FormatoEnteroMiles(txtPrecio.Text);
                            }
                            txtCodigo.Focus();
                        }
                    }
                    break;
                }
            }
        }