示例#1
0
 private void Caja_Load(object sender, EventArgs e)
 {
     try
     {
         txtCierre.Text = String.Format("{0:c}", 0.0m);
         Decimal apertura = 0.0m;
         txtFecha.Text = DateTime.Now.ToString("dd/MM/yyyy");
         DataTable dt = ConexionSQL.consultaDataTable(String.Format("Select isnull(MontoApertura,0)[MontoApertura],NoSeq from Caja where Convert(varchar,FechaApertura,103)='{0}' and FechaApertura=FechaCierre and Estado=0", DateTime.Now.ToString("dd/MM/yyyy")), "Caja");
         if (dt.Rows.Count > 0)
         {
             apertura             = Convert.ToDecimal(dt.Rows[0][0].ToString());
             this.Text            = "Caja N° " + dt.Rows[0][1].ToString();
             this.txtApertura.Tag = dt.Rows[0][1].ToString();
         }
         txtApertura.Text = String.Format("{0:c}", apertura);
         if (apertura > 0)
         {
             txt50000.Focus();
             txtApertura.Enabled = false;
             btnApertura.Visible = false;
         }
         else
         {
             txtApertura.Focus();
         }
         CargarMontos();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error al cargar", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#2
0
        private void CargarMontos()
        {
            StringBuilder str = new StringBuilder();

            str.Append("Select *,[Venta]-[Gasto] [Total] from (");
            str.Append(" Select sum(Gasto)[Gasto],sum(Venta)[Venta] from (");
            str.Append(string.Format(" Select isnull(sum(Total),0)[Venta],0[Gasto] from Venta where convert(varchar,Fecha,103)='{0}' and Estado=0", txtFecha.Text));
            str.Append(" union all");
            str.Append(string.Format(" Select 0,isnull(sum(Total),0)[Gasto] from Gasto where convert(varchar,Fecha,103)='{0}' and Estado=1 and Flag=0", txtFecha.Text));
            str.Append(" )a");
            str.Append(" )b");
            DataTable dt = ConexionSQL.consultaDataTable(str.ToString(), "DetalleCaja");

            if (dt.Rows.Count > 0)
            {
                txtGastos.Text   = String.Format("{0:c}", Convert.ToDecimal(dt.Rows[0][0].ToString()));
                txtVentas.Text   = String.Format("{0:c}", Convert.ToDecimal(dt.Rows[0][1].ToString()));
                txtTotal.Text    = String.Format("{0:c}", Convert.ToDecimal(dt.Rows[0][2].ToString()));
                dt               = ConexionSQL.consultaDataTable(string.Format("Select isnull(sum(Total),0)[Venta] from Venta where convert(varchar,Fecha,103)='{0}' and Estado=0 and TipoPago='Efectivo'", txtFecha.Text), "Efectivo");
                txtEfectivo.Text = String.Format("{0:c}", Convert.ToDecimal(dt.Rows[0][0].ToString()));
                dt               = ConexionSQL.consultaDataTable(string.Format("Select isnull(sum(Total),0)[Venta] from Venta where convert(varchar,Fecha,103)='{0}' and Estado=0 and TipoPago='Tarjeta'", txtFecha.Text), "Tarjeta");
                txtTarjeta.Text  = String.Format("{0:c}", Convert.ToDecimal(dt.Rows[0][0].ToString()));
            }
            else
            {
                txtGastos.Text   = String.Format("{0:c}", 0.0m);
                txtVentas.Text   = String.Format("{0:c}", 0.0m);
                txtTotal.Text    = String.Format("{0:c}", 0.0m);
                txtTarjeta.Text  = String.Format("{0:c}", 0.0m);
                txtEfectivo.Text = String.Format("{0:c}", 0.0m);
            }
        }
示例#3
0
 private void CargarCategoria()
 {
     comboBox2.DataSource    = ConexionSQL.consultaDataTable("Select * from Categoria where Estado=1", "Categoria");
     comboBox2.DisplayMember = "Descripcion";
     comboBox2.ValueMember   = "Cod";
     comboBox2.Show();
 }
示例#4
0
文件: Gasto.cs 项目: luismbm89/SOZ-v3
        protected void CargarGastos()
        {
            dataGridView1.Columns.Clear();
            dataGridView1.Columns.Add(new DataGridViewTextBoxColumn {
                Name = "Cod", DataPropertyName = "Cod"
            });
            dataGridView1.Columns.Add(new DataGridViewTextBoxColumn {
                Name = "Hora", DataPropertyName = "Hora"
            });
            dataGridView1.Columns.Add(new DataGridViewTextBoxColumn {
                Name = "Total", DataPropertyName = "Total"
            });
            dataGridView1.Columns.Add(new DataGridViewTextBoxColumn {
                Name = "Descripcion", DataPropertyName = "Descripcion"
            });
            dataGridView1.Columns.Add(new DataGridViewCheckBoxColumn {
                Name = "Estado", DataPropertyName = "Estado"
            });
            dataGridView1.DataSource = ConexionSQL.consultaDataTable(string.Format("Select Cod,Convert(varchar(5),Fecha,108)[Hora],Total,Descripcion,Estado from Gasto where Convert(varchar,Fecha,103)='{0}'", dateTimePicker1.Value.ToString("dd/MM/yyyy")), "Gasto");
            var provider = new System.Globalization.CultureInfo("es-CR");

            dataGridView1.Columns["Total"].DefaultCellStyle.FormatProvider = provider;
            dataGridView1.Columns["Total"].DefaultCellStyle.Format         = "C2";
            dataGridView1.Columns["Total"].DefaultCellStyle.Alignment      = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Show();
            textBox3.Text = string.Format("{0:c}", ConexionSQL.ConsultaUnica(string.Format("Select isnull(sum(Total),0)[Total] from Gasto where Convert(varchar,Fecha,103)='{0}' and Estado=1", dateTimePicker1.Value.ToString("dd/MM/yyyy"))));

            decimal paga       = Convert.ToDecimal(textBox3.Text);
            string  formateado = string.Format("{0:C}", paga);

            textBox3.Text = formateado;
        }
示例#5
0
 private void CargarMarcas()
 {
     comboBox1.DataSource    = ConexionSQL.consultaDataTable("Select * from Marca where Estado=1", "Marca");
     comboBox1.DisplayMember = "Descripcion";
     comboBox1.ValueMember   = "Cod";
     comboBox1.Show();
 }
示例#6
0
        private void Proveedor()
        {
            DataTable proveedor = ConexionSQL.consultaDataTable("Select Cod,Nombre,Contacto,Telefono,Celular,Direccion,Correo,Comentarios,Estado,ROW_NUMBER()over(order by Nombre)NoSeq from Proveedor", "Proveedor");

            DataRow[] dr = proveedor.Select(string.Format("NoSeq = '{0}'", txtCodigoPro.Text));
            txtCodigoPro.Text      = dr[0]["NoSeq"].ToString();
            txtCodigoPro.Tag       = dr[0]["Cod"].ToString();
            txtComentarioProv.Text = dr[0]["Comentarios"].ToString();
            txtContactoProv.Text   = dr[0]["Contacto"].ToString();
            txtDireccionProv.Text  = dr[0]["Direccion"].ToString();
            txtEmailProv.Text      = dr[0]["Correo"].ToString();
            txtNombreProv.Text     = dr[0]["Nombre"].ToString();
            txtTelefonoProv.Text   = dr[0]["Telefono"].ToString();
            txtCelProv.Text        = dr[0]["Celular"].ToString();
            if (Convert.ToBoolean(dr[0]["Estado"].ToString()))
            {
                rdbHabPro.Checked = true;
            }
            else
            {
                rdbDeshProv.Checked = true;
            }
            cboProveedor.DataSource    = ConexionSQL.consultaDataTable("Select Cod,Nombre from Proveedor where Estado=1", "Proveedor");
            cboProveedor.DisplayMember = "Nombre";
            cboProveedor.ValueMember   = "Cod";
            cboProveedor.Show();
        }
示例#7
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         dataGridView1.DataSource = ConexionSQL.consultaDataTable(textBox1.Text, "Consulta");
         dataGridView1.Show();
     }
     catch (Exception ex) {
         textBox1.Text = string.Format("{0}", ex.Message);
     }
 }
示例#8
0
        private void CargarVenta(string noVenta)
        {
            dataGridView1.DataSource = ConexionSQL.consultaDataTable(string.Format("Select NoSeq,Code,Descripcion,Cantidad,Precio,SubTotal,IVA,Descuento,Total from VwDetalle where Venta={0}", noVenta), "VwDetalle");
            dataGridView1.Show();
            DataTable dt = ConexionSQL.consultaDataTable(string.Format("Select Fecha,Cliente,SubTotal,Descuento,IVA,Total,TipoPago,Referencia from Venta where Cod='{0}'", noVenta), "Venta");

            txtCliente.Text     = dt.Rows[0]["Cliente"].ToString();
            txtDescuento.Text   = string.Format("{0:c}", Convert.ToDecimal(dt.Rows[0]["Descuento"].ToString()));
            txtFormadePago.Text = dt.Rows[0]["TipoPago"].ToString();
            txtIV.Text          = string.Format("{0:c}", Convert.ToDecimal(dt.Rows[0]["IVA"].ToString()));
            txtTotal.Text       = string.Format("{0:c}", Convert.ToDecimal(dt.Rows[0]["Total"].ToString()));
            txtSubTotal.Text    = string.Format("{0:c}", Convert.ToDecimal(dt.Rows[0]["SubTotal"].ToString()));
        }
示例#9
0
        private void nuevaVentaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataTable dt = ConexionSQL.consultaDataTable(String.Format("Select isnull(MontoApertura,0)[MontoApertura],NoSeq from Caja where Convert(varchar,FechaApertura,103)='{0}' and FechaApertura=FechaCierre and Estado=0", DateTime.Now.ToString("dd/MM/yyyy")), "Caja");

            if (dt.Rows.Count > 0)
            {
                Venta venta = new Venta();
                venta.MdiParent = this;
                venta.Show();
            }
            else
            {
                MessageBox.Show("Debe realizar la apertura de caja", "Apertura de caja", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
示例#10
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            DataTable dt = ConexionSQL.consultaDataTable(string.Format("Select * from Producto where BarCode='{0}'", toolStripTextBox1.Text), "Producto");

            if (dt.Rows.Count > 1)
            {
                MessageBox.Show("Existen muchos artículos para el código digitado", "Artículos con mismo código", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            if (dt.Rows.Count == 1)
            {
                txtBarCode.Text     = dt.Rows[0]["BarCode"].ToString();
                txtCode.Text        = dt.Rows[0]["Code"].ToString();
                txtCosto.Text       = dt.Rows[0]["Costo"].ToString();
                txtDescripcion.Text = dt.Rows[0]["Descripcion"].ToString();
                txtNoSeq.Text       = dt.Rows[0]["NoSeq"].ToString();
                txtPrecio.Text      = dt.Rows[0]["PrecioVenta"].ToString();
                if (Convert.ToBoolean(dt.Rows[0]["IVA"].ToString()))
                {
                    rdbConIVA.Checked = true;
                }
                else
                {
                    rdbSinIVA.Checked = true;
                }
                if (Convert.ToBoolean(dt.Rows[0]["Estado"].ToString()))
                {
                    rdbHabilitado.Checked = true;
                }
                else
                {
                    rdbDeshabilitado.Checked = true;
                }
                comboBox1.SelectedValue = dt.Rows[0]["Marca"].ToString();
                comboBox2.SelectedValue = dt.Rows[0]["Categoria"].ToString();
                CargarInventario(Convert.ToInt32(txtNoSeq.Text));
            }
        }
示例#11
0
 protected void ImprimirCierre(string Cierre)
 {
     try
     {
         StringBuilder str = new StringBuilder();
         str.Append("Select *,[Venta]-[Gasto] [Total] from (");
         str.Append(" Select sum(Gasto)[Gasto],sum(Venta)[Venta] from (");
         str.Append(string.Format(" Select isnull(sum(Total),0)[Venta],0[Gasto] from Venta where convert(varchar,Fecha,103)='{0}' and Estado=0", txtFecha.Text));
         str.Append(" union all");
         str.Append(string.Format(" Select 0,isnull(sum(Total),0)[Gasto] from Gasto where convert(varchar,Fecha,103)='{0}' and Estado=1 and flag=0", txtFecha.Text));
         str.Append(" )a");
         str.Append(" )b");
         DataTable dt     = ConexionSQL.consultaDataTable(str.ToString(), "DetalleCaja");
         decimal   venta  = Convert.ToDecimal(dt.Rows[0][1].ToString());
         decimal   gasto  = Convert.ToDecimal(dt.Rows[0][0].ToString());
         Ticket    ticket = new Ticket();
         ticket.HeaderImage = Properties.Resources.logo;
         ticket.AddHeaderLine(Properties.Settings.Default.Encabezado1);
         ticket.AddHeaderLine(Properties.Settings.Default.Encabezado2);
         ticket.AddHeaderLine(Properties.Settings.Default.Encabezado3);
         ticket.AddHeaderLine(Properties.Settings.Default.Encabezado4);
         ticket.AddHeaderLine(Properties.Settings.Default.Encabezado5);
         ticket.AddSubHeaderLine(String.Format("Cierre # {0}", Cierre));
         ticket.AddTotal("Apertura de Caja", string.Empty);
         ticket.AddTotal(string.Empty, txtApertura.Text);
         ticket.AddTotal(string.Empty, string.Empty);
         ticket.AddTotal("Total Ventas", txtVentas.Text);
         ticket.AddTotal("Total Gastos", txtGastos.Text);
         ticket.AddTotal(string.Empty, string.Empty);
         ticket.AddTotal("Venta Neta", Convert.ToString(string.Format("{0:c}", venta - gasto)));
         ticket.AddTotal(string.Empty, string.Empty);
         ticket.AddItem("Desglose de Caja", string.Empty, string.Empty);
         ticket.AddItem(string.Empty, string.Empty, string.Empty);
         ticket.AddTotal("Efectivo", string.Empty);
         dt = ConexionSQL.consultaDataTable("Select isnull(sum(Total),0)[Total] from Venta where TipoPago='Tarjeta' and Fecha <=getdate()", "Tarjeta");
         decimal Tarjeta = Convert.ToDecimal(dt.Rows[0][0].ToString());
         ticket.AddTotal(string.Empty, txtCierre.Text);
         ticket.AddTotal("Tarjeta", string.Empty);
         ticket.AddTotal(string.Empty, string.Format("{0:c}", Tarjeta));
         ticket.AddTotal("", "");
         ticket.AddItem("Billetes", string.Empty, string.Empty);
         ticket.AddItem(txt50000.Text, label1.Text, string.Format("{0:c}", Convert.ToInt32(txt50000.Text) * 50000));
         ticket.AddItem(txt20000.Text, label2.Text, string.Format("{0:c}", Convert.ToInt32(txt20000.Text) * 20000));
         ticket.AddItem(txt10000.Text, label3.Text, string.Format("{0:c}", Convert.ToInt32(txt10000.Text) * 10000));
         ticket.AddItem(txt5000.Text, label4.Text, string.Format("{0:c}", Convert.ToInt32(txt5000.Text) * 5000));
         ticket.AddItem(txt2000.Text, label5.Text, string.Format("{0:c}", Convert.ToInt32(txt2000.Text) * 2000));
         ticket.AddItem(txt1000.Text, label6.Text, string.Format("{0:c}", Convert.ToInt32(txt1000.Text) * 1000));
         ticket.AddItem(string.Empty, string.Empty, string.Empty);
         ticket.AddItem("Monedas", string.Empty, string.Empty);
         ticket.AddItem(txt500.Text, label12.Text, string.Format("{0:c}", Convert.ToInt32(txt500.Text) * 500));
         ticket.AddItem(txt100.Text, label11.Text, string.Format("{0:c}", Convert.ToInt32(txt100.Text) * 100));
         ticket.AddItem(txt50.Text, label10.Text, string.Format("{0:c}", Convert.ToInt32(txt50.Text) * 50));
         ticket.AddItem(txt25.Text, label9.Text, string.Format("{0:c}", Convert.ToInt32(txt25.Text) * 25));
         ticket.AddItem(txt10.Text, label8.Text, string.Format("{0:c}", Convert.ToInt32(txt10.Text) * 10));
         ticket.AddItem(txt5.Text, label7.Text, string.Format("{0:c}", Convert.ToInt32(txt5.Text) * 5));
         ticket.AddTotal("", "");
         ticket.PrintTicket(Properties.Settings.Default.Impresora); //Nombre de la impresora de tickets
     }
     catch (Exception ex) {
         //
     }
 }