Ejemplo n.º 1
0
        private Int32 DetalleVenta(string NoVenta)
        {
            Decimal TotalIVA = 0.0m;
            string  str      = "";
            int     cont     = 0;

            for (int i = 0; i < grvVenta.Rows.Count; i++)
            {
                decimal IVA;
                if (Convert.ToBoolean(grvVenta.Rows[i].Cells["IVA"].Value))
                {
                    IVA = Convert.ToDecimal(grvVenta.Rows[i].Cells["IVA"].Value);
                }
                else
                {
                    IVA = 0.0m;
                }
                TotalIVA += IVA;
                string cod = ConexionSQL.ConsultaUnica(string.Format("Select isnull(max(Cod),0)+1 from DetalleVenta where Venta={0}", NoVenta));
                str = string.Format(@"Insert into DetalleVenta(Cod,Venta,Producto,Descripcion,Cantidad,Precio,IVA,Descuento,Fecha,Estado) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',default,1)", cod, NoVenta, grvVenta.Rows[i].Cells["NoSeq"].Value, grvVenta.Rows[i].Cells["Descripcion"].Value, grvVenta.Rows[i].Cells["Cantidad"].Value, grvVenta.Rows[i].Cells["Precio"].Value, grvVenta.Rows[i].Cells["IVA"].Value, grvVenta.Rows[i].Cells["Descuento"].Value);
                try
                {
                    if (ConexionSQL.DML(str) > 0)
                    {
                        cont++;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            return(cont);
        }
Ejemplo n.º 2
0
 private void CargarMarcas()
 {
     comboBox1.DataSource    = ConexionSQL.consultaDataTable("Select * from Marca where Estado=1", "Marca");
     comboBox1.DisplayMember = "Descripcion";
     comboBox1.ValueMember   = "Cod";
     comboBox1.Show();
 }
Ejemplo n.º 3
0
        protected void Prueba(String Cod)
        {
            string  NoSeq     = ConexionSQL.ConsultaUnica(string.Format("Select NoSeq from (Select Cod,ROW_NUMBER() over(partition by convert(varchar,Fecha,103)order by Cod asc)NoSeq  from Venta)a where Cod='{0}'", Cod));
            decimal Descuento = Convert.ToDecimal(dtVenta.Compute("SUM(Descuento)", string.Empty));
            decimal IV        = Convert.ToDecimal(dtVenta.Compute("SUM(IVA)", string.Empty));
            decimal total     = Convert.ToDecimal(dtVenta.Compute("SUM(Total)", string.Empty));
            decimal SubTotal  = total - IV + Descuento;
            Tiquete tkt       = new Tiquete();

            tkt.TicketNo   = int.Parse(NoSeq);
            tkt.Discount   = float.Parse(Descuento.ToString());
            tkt.Iva        = float.Parse(IV.ToString());
            tkt.Total      = float.Parse(total.ToString());
            tkt.ticketDate = DateTime.Now;
            tkt.Cancela    = txtCancela.Text;
            tkt.Vuelto     = txtVuelto.Text;
            tkt.Voucher    = textBox2.Text;
            if (radioButton1.Checked)
            {
                tkt.TipoPago = radioButton1.Text;
            }
            else
            {
                tkt.TipoPago = radioButton2.Text;
            }
            tkt.Productos = dtVenta;
            tkt.amount    = float.Parse(SubTotal.ToString());
            tkt.Cliente1  = txtCliente.Text;
            tkt.print();
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        private void btnLastProv_Click(object sender, EventArgs e)
        {
            int total = Convert.ToInt32(ConexionSQL.ConsultaUnica("Select Count(*) from Proveedor"));

            txtCodigoPro.Text = string.Format("{0}", total);
            Proveedor();
        }
Ejemplo n.º 6
0
 private void CargarCategoria()
 {
     comboBox2.DataSource    = ConexionSQL.consultaDataTable("Select * from Categoria where Estado=1", "Categoria");
     comboBox2.DisplayMember = "Descripcion";
     comboBox2.ValueMember   = "Cod";
     comboBox2.Show();
 }
Ejemplo n.º 7
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();
        }
Ejemplo n.º 8
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         string NoSeq    = ConexionSQL.ConsultaUnica("Select isnull(max(Cod),0)+1 from Compra");
         string osql     = string.Format("set dateformat dmy;insert into Compra values ({0},'{1}','{2}','{3}','{4}','{5}','{6}',{7});", NoSeq, dtpFecha.Value.ToString("dd/MM/yyyy"), dtpVencimiento.Value.ToString("dd/MM/yyyy"), txtNumFact.Text, txtSubTotal.Text, txtDesc.Text, txtIVA.Text, cboProveedor.SelectedValue);
         int    i        = ConexionSQL.DML(osql);
         int    qty      = dataGridView1.Rows.Count;
         int    contador = 0;
         if (i > 0)
         {
             foreach (DataGridViewRow dr in dataGridView1.Rows)
             {
                 string j = ConexionSQL.ConsultaUnica(string.Format("Select isnull(max(NoSeq),0)+1 from DetalleCompra where Compra={0}", NoSeq));
                 osql = string.Format("insert into DetalleCompra values ({0},{1},{2},{3},{4});", j, NoSeq, dr.Cells["NoSeq"].Value, dr.Cells["Cantidad"].Value, dr.Cells["Precio"].Value);
                 i    = ConexionSQL.DML(osql);
                 if (i > 0)
                 {
                     contador++;
                 }
             }
             if (contador == qty)
             {
                 MessageBox.Show("Compra procesada satisfactoriamente", "Registro de Compra", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 9
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);
     }
 }
Ejemplo n.º 10
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);
            }
        }
Ejemplo n.º 11
0
 private void btnVenta_Click(object sender, EventArgs e)
 {
     try
     {
         if (grvVenta.Rows.Count > 0 && txtCancela.Text.Length > 0 && (txtCancela.Text.Length) > 0)
         {
             string  osql      = "";
             decimal Descuento = Convert.ToDecimal(dtVenta.Compute("SUM(Descuento)", string.Empty));
             decimal IV        = Convert.ToDecimal(dtVenta.Compute("SUM(IVA)", string.Empty));
             decimal total     = Convert.ToDecimal(dtVenta.Compute("SUM(Total)", string.Empty));
             decimal SubTotal  = total - IV + Descuento;
             string  cod       = ConexionSQL.ConsultaUnica("Select isnull(max(Cod),0)+1 from Venta");
             bool    flag      = false;
             if (radioButton2.Checked && !string.IsNullOrEmpty(textBox2.Text) && !string.IsNullOrEmpty(txtCliente.Text))
             {
                 osql = string.Format("insert into Venta(Cod, Cliente, SubTotal,Descuento,IVA,TipoPago, Referencia) values({0}, '{1}', '{2}','{3}','{4}', '{5}', '{6}')", cod, txtCliente.Text, SubTotal, Descuento, IV, radioButton2.Text, textBox2.Text);
                 flag = true;
             }
             if (radioButton1.Checked && !string.IsNullOrEmpty(txtCliente.Text))
             {
                 osql = string.Format("insert into Venta(Cod,Cliente,SubTotal,Descuento,IVA,TipoPago) values ({0}, '{1}', '{2}','{3}','{4}', '{5}')", cod, txtCliente.Text, SubTotal, Descuento, IV, radioButton1.Text);
                 flag = true;
             }
             if (flag)
             {
                 int i = ConexionSQL.DML(osql);
                 if (i > 0)
                 {
                     if (DetalleVenta(cod) == grvVenta.Rows.Count)
                     {
                         MessageBox.Show("Venta realizada con exito", "Venta Exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         // PrintTicket(cod,false);
                         // PrintTicket(cod,true);
                         Prueba(cod);
                         Limpiar();
                     }
                 }
                 else
                 {
                     MessageBox.Show("Ha ocurrido un error", "Venta Fallida", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             else
             {
                 MessageBox.Show("Por favor valide todos los campos", "Información de Venta Incompleta", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("No puede realizar una venta sin productos que facturar", "Venta Fallida", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Venta Fallida", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 12
0
        private void button1_Click(object sender, EventArgs e)
        {
            string NoSeq = ConexionSQL.ConsultaUnica("Select isnull(max(Cod),0)+1 from Gasto");

            if (ConexionSQL.DML(String.Format("insert into Gasto values ({0},default,'{1}','{2}','{3}','{4}',1,default)", NoSeq, textBox4.Text, textBox1.Text, textBox2.Text, textBox5.Text)) > 0)
            {
                CargarGastos();
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            //this.Size = Screen.PrimaryScreen.WorkingArea.Size;
            ConexionSQL conexion = new ConexionSQL();

            LlenarItems(comboBox1);
            obj.Cerrar();
            //   conexion.abrir();
        }
Ejemplo n.º 14
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         int i = ConexionSQL.DML(textBox1.Text);
         textBox1.Text += string.Format(" Registros afectados ({0})", i);
     }
     catch (Exception ex) {
         textBox1.Text = string.Format("{0}", ex.Message);
     }
 }
Ejemplo n.º 15
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);
     }
 }
Ejemplo n.º 16
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            int NoVenta = Convert.ToInt32(txtNumero.Text);
            int max     = Convert.ToInt32(ConexionSQL.ConsultaUnica("Select isnull(max(Cod),0) from Venta"));

            if (NoVenta < max)
            {
                NoVenta++;
                txtNumero.Text = NoVenta.ToString();
                CargarVenta(txtNumero.Text);
            }
        }
Ejemplo n.º 17
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()));
        }
Ejemplo n.º 18
0
 private void Limpiar()
 {
     txtNoSeq.Text = ConexionSQL.ConsultaUnica("Select isnull(max(NoSeq),0)+1 from Producto");
     txtBarCode.Focus();
     txtCode.Text             = "";
     txtCosto.Text            = "";
     txtDescripcion.Text      = "";
     txtPrecio.Text           = "";
     rdbConIVA.Checked        = false;
     rdbSinIVA.Checked        = false;
     rdbHabilitado.Checked    = false;
     rdbDeshabilitado.Checked = false;
     txtBarCode.Text          = "";
 }
Ejemplo n.º 19
0
        private void btnCancelar_Click(object sender, EventArgs e)
        {
            /*  try
             * {
             *    if (txtApertura.Text.Length > 0)
             * {
             *    decimal Apertura = decimal.Parse(txtApertura.Text,
             * NumberStyles.AllowCurrencySymbol |
             * NumberStyles.AllowThousands |
             * NumberStyles.AllowDecimalPoint);
             *    decimal Cierre = decimal.Parse(txtCierre.Text,
             * NumberStyles.AllowCurrencySymbol |
             * NumberStyles.AllowThousands |
             * NumberStyles.AllowDecimalPoint);
             *    decimal Saldo = Cierre - Apertura;
             *    if (Saldo > 0)
             *    {
             *        MessageBox.Show(string.Format("{0:c}", Saldo), "Saldo positivo al cierre", MessageBoxButtons.OK, MessageBoxIcon.Information);
             *    }
             *    if (Saldo == 0)
             *    {
             *        MessageBox.Show(string.Format("{0:c}", Saldo), "Saldo neutro al cierre", MessageBoxButtons.OK, MessageBoxIcon.Stop);
             *    }
             *    if (Saldo < 0)
             *    {
             *        MessageBox.Show(string.Format("{0:c}", Saldo), "Saldo negativo al cierre", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             *    }
             *    int i = ConexionSQL.DML(String.Format("Update Caja  set FechaCierre=default, MontoCierre='{1}',Estado=1 where Convert(varchar,Fecha,103)='{0}' and NoSeq in (Select max(NoSeq) from Caja where Convert(varchar,Fecha,103)='{0}') and Estado=0", DateTime.Now.ToShortDateString(),txtCierre.Text));
             *    if (i > 0)
             *    {
             *        MessageBox.Show("Cierre efectuado con éxito", "Cierre de Caja", MessageBoxButtons.OK, MessageBoxIcon.Information);
             *            ImprimirCierre("1");
             *    }
             * }
             * }
             * catch (Exception ex)
             * {
             *    MessageBox.Show(ex.Message, "Error de Apertura", MessageBoxButtons.OK, MessageBoxIcon.Error);
             * }*/
            int i = ConexionSQL.DML(String.Format("Update caja set MontoCierre='{0}',FechaCierre=default,Estado=1 where NoSeq='{1}'", Cierre(), txtApertura.Tag));

            if (i > 0)
            {
                int j = ConexionSQL.DML("Update Venta set Estado=1 where Fecha<=getdate()");
                int k = ConexionSQL.DML("Update Gasto set Flag=1 where Fecha<=getdate()");
                MessageBox.Show("Cierre de Caja efectuado correctamente", "Cierre de caja", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ImprimirCierre(txtApertura.Tag.ToString());
            }
        }
Ejemplo n.º 20
0
 private void Compra_Load(object sender, EventArgs e)
 {
     dtpFecha.Value       = DateTime.Now;
     dtpVencimiento.Value = DateTime.Now;
     dtVenta = new DataTable();
     dtVenta.Columns.Add("NoSeq", typeof(int));
     dtVenta.Columns.Add("Descripcion", typeof(String));
     dtVenta.Columns.Add("Cantidad", typeof(decimal));
     dtVenta.Columns.Add("Precio", typeof(decimal));
     dtVenta.Columns.Add("Total", typeof(decimal));
     tabControl1.SelectedIndex = 1;
     lblTotalProv.Text         = string.Format("Total de Registros: {0}", ConexionSQL.ConsultaUnica("Select count(*) from Proveedor"));
     txtCodigoPro.Text         = "1";
     Proveedor();
 }
        private void Form1_Load(object sender, EventArgs e)
        {
            /*** Se coloca la fecha en el evento Load para que la variable F1 obtenga el valor de la fecha inicial ***/
            DateTime Fecha1 = dateTimePicker1.Value;

            F1 = Fecha1.ToString("yyyy-MM-dd");
            /*** Fin Comentario ***/

            //this.Size = Screen.PrimaryScreen.WorkingArea.Size;
            ConexionSQL conexion = new ConexionSQL();

            LlenarItems(comboBox1);
            obj.Cerrar();
            //   conexion.abrir();
        }
Ejemplo n.º 22
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);
            }
        }
Ejemplo n.º 23
0
        private void detalleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string numero = ConexionSQL.ConsultaUnica("Select isnull(min(Cod),0) from Venta");

            if (numero.Equals("0"))
            {
                MessageBox.Show("No se ha realizado ninguna venta", "Sin registro de ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                VentaDetalle vd = new VentaDetalle();
                vd.MdiParent = this;
                vd.Show();
            }
        }
Ejemplo n.º 24
0
 private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 4)
     {
         Boolean flag = Convert.ToBoolean(dataGridView1.Rows[e.RowIndex].Cells[4].Value);
         if (flag)
         {
             ConexionSQL.DML(string.Format("Update Gasto set Estado=0 where Cod='{0}'", dataGridView1.Rows[e.RowIndex].Cells[0].Value));
         }
         else
         {
             ConexionSQL.DML(string.Format("Update Gasto set Estado=1 where Cod='{0}'", dataGridView1.Rows[e.RowIndex].Cells[0].Value));
         }
         CargarGastos();
     }
 }
Ejemplo n.º 25
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     try
     {
         int flag       = Convert.ToInt32(ConexionSQL.ConsultaUnica(string.Format("Select Count(*) from Producto where NoSeq='{0}'", txtNoSeq.Text)));
         int IVA        = 0;
         int habilitado = 0;
         if (rdbConIVA.Checked)
         {
             IVA = 1;
         }
         if (rdbHabilitado.Checked)
         {
             habilitado = 1;
         }
         if (flag > 0)
         {
             int u = ConexionSQL.DML(string.Format("Update Producto set BarCode='{0}',Code='{1}',Descripcion='{2}',Categoria='{3}',Marca='{4}',IVA='{5}',Costo='{6}',PrecioVenta='{7}',Estado={9} where NoSeq='{8}'", txtBarCode.Text, txtCode.Text, txtDescripcion.Text, comboBox2.SelectedValue, comboBox1.SelectedValue, IVA, txtCosto.Text, txtPrecio.Text, txtNoSeq.Text, habilitado));
             if (u > 0)
             {
                 MessageBox.Show("Actualización efectuada correctamente", "Actualización", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 Limpiar();
             }
         }
         else
         {
             if (ConexionSQL.ConsultaUnica(String.Format("Select count(*) from Producto where BarCode='{0}'", txtBarCode.Text)).Equals("0"))
             {
                 int i = ConexionSQL.DML(string.Format("insert into Producto values ({0},'{1}','{2}','{3}',{4},{5},{6},'{7}','{8}',1)", txtNoSeq.Text, txtBarCode.Text, txtCode.Text, txtDescripcion.Text, comboBox1.SelectedValue, comboBox2.SelectedValue, IVA, txtCosto.Text, txtPrecio.Text));
                 if (i > 0)
                 {
                     MessageBox.Show("Registro efectuado correctamente", "Actualización", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     Limpiar();
                 }
             }
             else
             {
                 MessageBox.Show("El Codigo de Barras ya existe", "Codigo de barras duplicado", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtBarCode.Focus();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 26
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         int i = ConexionSQL.DML(string.Format("Update Marca set Estado=0 where Cod='{0}'", comboBox1.SelectedValue));
         if (i > 0)
         {
             CargarMarcas();
             textBox1.Text = "";
             textBox1.Focus();
             comboBox1.Text = "";
         }
         else
         {
             textBox1.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 27
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         int flag = Convert.ToInt32(ConexionSQL.ConsultaUnica(string.Format("Select Count(*) from Marca where Descripcion='{0}'", textBox1.Text)));
         if (flag == 1)
         {
             int i = ConexionSQL.DML(string.Format("Update Marca set Estado=1 where Descripcion='{0}'", textBox1.Text));
             if (i > 0)
             {
                 CargarMarcas();
                 textBox1.Text = "";
                 textBox1.Focus();
             }
             else
             {
                 textBox1.Focus();
             }
         }
         else if (flag == 0)
         {
             int i = ConexionSQL.DML(string.Format("Insert into Marca values ('{0}',1)", textBox1.Text));
             if (i > 0)
             {
                 CargarMarcas();
                 textBox1.Text = "";
                 textBox1.Focus();
             }
             else
             {
                 textBox1.Focus();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 28
0
        private void txtBarCode_TextChanged(object sender, EventArgs e)
        {
            try
            {
                string BarCode = txtBarCode.Text;
                string flag    = ConexionSQL.ConsultaUnica(string.Format("Select count(*) from Producto where BarCode='{0}'", BarCode));
                if (flag.Equals("1"))
                {
                    //Buscar Producto
                    Producto producto = new Producto();
                    Producto p1       = producto.GetList().Find(x => x.BarCode1 == BarCode);

                    // Get all DataRows where the name is the name you want.
                    IEnumerable <DataRow> rows = dtVenta.Rows.Cast <DataRow>().Where(r => r["Descripcion"].ToString() == p1.Descripcion1);
                    // Loop through the rows and change the name.
                    if (rows.Count() == 0)
                    {
                        dtVenta.Rows.Add(p1.NoSeq1, p1.Descripcion1, "0.0", "0.0", "0.0");
                    }
                    dataGridView1.DataSource = dtVenta;
                    dataGridView1.Show();
                    int n = Convert.ToInt32(dataGridView1.Rows.Count.ToString());
                    for (int i = 0; i < n; i++)
                    {
                        dataGridView1.Rows[i].Cells[0].ReadOnly = true;
                        dataGridView1.Rows[i].Cells[1].ReadOnly = true;
                        dataGridView1.Rows[i].Cells[4].ReadOnly = true;
                    }
                    txtBarCode.Text = "";
                    txtBarCode.Focus();
                    txtSubTotal.Text = String.Format(CultureInfo.CreateSpecificCulture("es-CR"), "{0}", Convert.ToDecimal(dtVenta.Compute("SUM(Total)", string.Empty)));
                    txtTotal.Text    = string.Format("{0:c}", Convert.ToDecimal(txtSubTotal.Text) - Convert.ToDecimal(txtDesc.Text) + Convert.ToDecimal(txtIVA.Text));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Escaneo Fallido", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 29
0
        private void btnGuardarProv_Click(object sender, EventArgs e)
        {
            int    flag = Convert.ToInt32(ConexionSQL.ConsultaUnica(string.Format("Select count(*) from Proveedor where Cod='{0}'", txtCodigoPro.Text)));
            string osql = "";
            string mensaje = "", Titulo = "";

            if (flag == 0)
            {
                osql    = string.Format("insert into Proveedor values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}',1)", txtNombreProv.Text, txtContactoProv.Text, txtTelefonoProv.Text, txtCelProv.Text, txtDireccionProv.Text, txtEmailProv.Text, txtComentarioProv.Text);
                mensaje = "Registro insertado correctamente";
                Titulo  = "Inserción";
                tabControl1.SelectedIndex = 1;
                lblTotalProv.Text         = string.Format("Total de Registros: {0}", ConexionSQL.ConsultaUnica("Select count(*) from Proveedor"));
                txtCodigoPro.Text         = "1";
                Proveedor();
            }
            else
            {
                int est = 0;
                if (rdbHabPro.Checked)
                {
                    est = 1;
                }
                osql    = string.Format("Update Proveedor set Nombre='{0}',Contacto='{1}',Telefono='{2}',Celular='{3}',Direccion='{4}',Correo='{5}',Comentarios='{6}',Estado='{8}' where Cod={7}", txtNombreProv.Text, txtContactoProv.Text, txtTelefonoProv.Text, txtCelProv.Text, txtDireccionProv.Text, txtEmailProv.Text, txtComentarioProv.Text, txtCodigoPro.Tag, est);
                mensaje = "Registro actualizado correctamente";
                Titulo  = "Actualización";
            }
            int i = ConexionSQL.DML(osql);

            if (i > 0)
            {
                tabControl1.SelectedIndex = 1;
            }
            MessageBox.Show(mensaje, Titulo, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            lblTotalProv.Text = string.Format("Total de Registros: {0}", ConexionSQL.ConsultaUnica("Select count(*) from Proveedor"));
            txtCodigoPro.Text = "1";
            Proveedor();
        }
Ejemplo n.º 30
0
 private void btnApertura_Click(object sender, EventArgs e)
 {
     try
     {
         string NoCa = ConexionSQL.ConsultaUnica("Select isnull(max(NoSeq),0)+1 NoSeq from Caja");
         int    i    = ConexionSQL.DML(string.Format("insert into Caja values({1},default,default,default,'{0}',default,0)", txtApertura.Text, NoCa));
         if (i > 0)
         {
             MessageBox.Show("Apertura realizada con éxito", "Apertura de Caja", MessageBoxButtons.OK, MessageBoxIcon.Information);
             decimal Apertura = decimal.Parse(txtApertura.Text,
                                              NumberStyles.AllowCurrencySymbol |
                                              NumberStyles.AllowThousands |
                                              NumberStyles.AllowDecimalPoint);
             txtApertura.Text    = String.Format("{0:c}", Apertura);
             txtApertura.Enabled = false;
             btnApertura.Visible = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error de Apertura", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }