Exemplo n.º 1
0
        private void ControlStockVendedores_Load(object sender, EventArgs e)
        {
            Conexion.abrir();
            DataTable arts = Conexion.Consultar("idarticulo,codigoart as [Codigo],descripcion as [Nombre],marca as [Marca],proveedor as [Proveedor],stockactual as [Stock]", "Articulos", "WHERE eliminado != 'Eliminado' and tipo LIKE 'Producto%'", "order by proveedor", new SqlCeCommand());

            Conexion.cerrar();
            BindingSource SBind = new BindingSource();

            SBind.DataSource = arts;
            dataGridView1.AutoGenerateColumns = true;
            dataGridView1.DataSource          = arts;
            dataGridView1.Columns[0].Visible  = false;
            dataGridView1.DataSource          = SBind;
            dataGridView1.Refresh();
            dataGridView1.Columns.Add("stockreal", "[F2] StockReal");
            foreach (DataGridViewColumn dc in dataGridView1.Columns)
            {
                if (dc.Index.Equals(6))
                {
                    dc.ReadOnly = false;
                }
                else
                {
                    dc.ReadOnly = true;
                }
            }
            if (arts.Rows.Count < 1)
            {
                button2.Enabled = false;
            }
        }
Exemplo n.º 2
0
        void getprovs()
        {
            Conexion.abrir();
            DataTable showprovs = Conexion.Consultar("idproveedor,nombre as [Nombre del Proveedor],atencion as [Atencion],telefono as Telefono,mail as [Correo Electrónico],direccion as [Direccion],localidad as Localidad,cp as CP", "Proveedores", "where Eliminado != 'Eliminado'", "", new SqlCeCommand());

            Conexion.cerrar();
            BindingSource SBind = new BindingSource();

            SBind.DataSource = showprovs;
            dataGridView1.AutoGenerateColumns = true;
            dataGridView1.DataSource          = showprovs;
            dataGridView1.Columns[0].Visible  = false;
            dataGridView1.DataSource          = SBind;
            dataGridView1.Refresh();

            if (showprovs.Rows.Count > 0)
            {
                dataGridView1.DataSource = showprovs; //mostramos lo que hay
                button2.Enabled          = true;
                button9.Enabled          = true;
            }
            else
            {
                button2.Enabled = false;
                button9.Enabled = false;
            }
        }
Exemplo n.º 3
0
        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            SqlCeCommand dates = new SqlCeCommand();

            dates.Parameters.AddWithValue("d2", Convert.ToDateTime(maskedTextBox1).Month);
            dates.Parameters.AddWithValue("d3", Convert.ToDateTime(maskedTextBox1).Year);
            Conexion.abrir();
            DataTable showdebe = Conexion.Consultar("area as [Area], descripcion as Motivo, importe as Total", "Gastos", "WHERE DATEPART(month,fecha) = @d2 AND DATEPART(year,fecha) = @d3;", "", dates);

            Conexion.cerrar();
            if (showdebe.Rows.Count > 0)
            {
                float toto = 0;
                for (int i = 0; i < showdebe.Rows.Count; i++)
                {
                    toto += float.Parse(showdebe.Rows[i][2].ToString());
                }
                textBox3.Text = toto.ToString("$0.00");
            }
            else
            {
                float tot = 0;
                textBox3.Text = tot.ToString("$0.00");
            }
        }
Exemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count > 0)
            {
                int    rowIndex = dataGridView1.CurrentCell.RowIndex;
                var    row      = this.dataGridView1.Rows[rowIndex];
                string name     = row.Cells[2].Value.ToString();
                string id       = row.Cells[0].Value.ToString();

                DialogResult borrar = MessageBox.Show("Está seguro de borrar este artículo?\n" + name, "Borrar?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (borrar == DialogResult.Yes)
                {
                    Conexion.abrir();
                    SqlCeCommand del = new SqlCeCommand();
                    del.Parameters.AddWithValue("@id", id);
                    del.Parameters.AddWithValue("@el", "Eliminado");
                    Conexion.Actualizar("Articulos", "eliminado = @el", "WHERE idarticulo = @id", "", del);
                    Conexion.cerrar();
                }
                getarts();
            }
            else
            {
                MessageBox.Show("No hay articulo seleccionado para borrar");
            }
        }
Exemplo n.º 5
0
        private void closeturno(string id, string nombre)
        {
            SqlCeCommand cierro = new SqlCeCommand();

            cierro.Parameters.AddWithValue("id", id);
            cierro.Parameters.AddWithValue("ff", app.hoy + " " + DateTime.Now.ToShortTimeString());
            string total = "";

            Conexion.abrir();
            SqlCeCommand paraeltotal = new SqlCeCommand();

            paraeltotal.Parameters.Add("ven", nombre);
            paraeltotal.Parameters.Add("fecA", app.hoy + " 00:00:00");
            paraeltotal.Parameters.Add("fecB", app.hoy + " " + DateTime.Now.ToShortTimeString());

            DataTable totalvendido = Conexion.Consultar("SUM(total)", "Ventas", "Where vendedor = @ven and estadoventa = 'Finalizado' and fechaventa between @fecA and @fecB", "", paraeltotal);

            if (totalvendido.Rows.Count > 0)
            {
                try
                {
                    total = float.Parse(totalvendido.Rows[0][0].ToString()).ToString();
                }
                catch (Exception)
                {
                    total = "0";
                }


                cierro.Parameters.AddWithValue("tot", float.Parse(total));
                Conexion.Actualizar("Turnos", "FechaFin = @ff, TotalVendido = @tot", "WHERE idturno = @id", "", cierro);
                Conexion.Actualizar("Ventas", "estadoventa='Cerrado' ", "WHERE vendedor = @ven and fechaventa between @fecA and @fecB and estadoventa = 'Finalizado' ", "", paraeltotal);
                Conexion.cerrar();
            }
        }
Exemplo n.º 6
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex >= 0 && textBox1.Text.Length > 0 && textBox2.Text.Length > 0)
     {
         string       fechaingresada = maskedTextBox1.Text;
         SqlCeCommand gasto          = new SqlCeCommand();
         gasto.Parameters.AddWithValue("fe", Convert.ToDateTime(fechaingresada + " 00:00:00"));
         gasto.Parameters.AddWithValue("ti", comboBox1.SelectedItem.ToString());
         gasto.Parameters.AddWithValue("mo", textBox1.Text);
         gasto.Parameters.AddWithValue("im", textBox2.Text.Replace("$", ""));
         Conexion.abrir();
         Conexion.Insertar("Gastos", "fecha,area,descripcion,importe", "@fe,@ti,@mo,@im", gasto);
         Conexion.cerrar();
         if (Application.OpenForms.OfType <Gastos>().Count() == 1)
         {
             Application.OpenForms.OfType <Gastos>().First().Close();
         }
         Gastos frm = new Gastos();
         frm.Show();
     }
     else
     {
         MessageBox.Show("Debe completar todos los datos para poder agregar el gasto");
     }
 }
Exemplo n.º 7
0
        private void NuevoCliente_Load(object sender, EventArgs e)
        {
            if (createorupdate.status == "update")
            {
                SqlCeCommand idprod = new SqlCeCommand();
                idprod.Parameters.AddWithValue("id", createorupdate.itemid);
                Conexion.abrir();
                DataTable datosprod = Conexion.Consultar("*", "Clientes", "WHERE idcliente = @id", "", idprod);

                Conexion.cerrar();

                button1.Text = "Guardar cambios";
                if (datosprod.Rows.Count > 0)
                {
                    textBox2.Text          = datosprod.Rows[0][1].ToString();
                    textBox3.Text          = datosprod.Rows[0][2].ToString();
                    textBox4.Text          = datosprod.Rows[0][3].ToString();
                    textBox5.Text          = datosprod.Rows[0][4].ToString();
                    textBox6.Text          = datosprod.Rows[0][5].ToString();
                    textBox7.Text          = datosprod.Rows[0][6].ToString();
                    textBox8.Text          = datosprod.Rows[0][7].ToString();
                    textBox9.Text          = datosprod.Rows[0][8].ToString();
                    textBox1.Text          = datosprod.Rows[0][9].ToString();
                    comboBox2.SelectedItem = datosprod.Rows[0][10].ToString();
                }
            }
        }
Exemplo n.º 8
0
        private void button3_Click(object sender, EventArgs e)
        {
            bool encontrecambios = false;

            Conexion.abrir();
            DataTable refresh = Conexion.Consultar("idarticulo,stockactual", "Articulos", "where eliminado != 'Eliminado'", "", new SqlCeCommand());

            Conexion.cerrar();
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                string id = dataGridView1.Rows[i].Cells[0].Value.ToString();
                for (int j = 0; j < refresh.Rows.Count; j++)
                {
                    if (id == refresh.Rows[j][0].ToString())
                    {
                        //MessageBox.Show("encontre el id ahora me fijo si el stock cambió o no");
                        string stock        = dataGridView1.Rows[i].Cells[5].Value.ToString();
                        int    stockactual  = int.Parse(stock);
                        int    stockrefresh = int.Parse(refresh.Rows[j][1].ToString());
                        if (stockactual != stockrefresh)
                        {
                            dataGridView1.Rows[i].Cells[5].Value             = stockrefresh.ToString();
                            dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Yellow;
                            encontrecambios = true;
                        }
                    }
                }
            }
            if (encontrecambios == true)
            {
                MessageBox.Show("Se encontraron cambios en el stock actual de productos, por favor revise las lineas de color amarillo y controle el stock nuevamente acorde al nuevo stock", "Se encontraron cambios", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 9
0
        void getarts()
        {
            Conexion.abrir();
            DataTable showarts = Conexion.Consultar("idarticulo,codigoart as [Codigo de Articulo],descripcion as [Descripcion del Articulo],proveedor as Proveedor,precio as Precio,costo as Costo,stockactual as Stock,stockminimo as [Stock Minimo],iva as IVA", "Articulos", "WHERE eliminado != 'Eliminado' and tipo NOT LIKE 'Servicio%'", "", new SqlCeCommand());

            Conexion.cerrar();
            BindingSource SBind = new BindingSource();

            SBind.DataSource = showarts;
            dataGridView1.AutoGenerateColumns = true;
            dataGridView1.DataSource          = showarts;
            dataGridView1.Columns[0].Visible  = false;
            dataGridView1.Columns[4].DefaultCellStyle.Format = "c";
            dataGridView1.Columns[5].DefaultCellStyle.Format = "c";
            dataGridView1.DataSource = SBind;
            dataGridView1.Refresh();
            if (showarts.Rows.Count > 0)
            {
                label2.Visible           = false;    //sacamos label
                dataGridView1.DataSource = showarts; //mostramos lo que hay
            }
            else
            {
                label2.Visible         = true; //mostramos que no hay registros
                button1.Enabled        = false;
                comboBox1.Enabled      = false;
                comboBox2.Enabled      = false;
                numericUpDown2.Enabled = false;
            }
        }
Exemplo n.º 10
0
        private void impnofiscal_Load(object sender, EventArgs e)
        {
            comboBox1.Items.Clear();
            foreach (string printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
            {
                comboBox1.Items.Add(printer);
            }
            //SqlCeCommand saconombre = new SqlCeCommand();
            Conexion.abrir();
            DataTable myimpresora = Conexion.Consultar("nombreimpnofiscal", "Configuracion", "", "", new SqlCeCommand());

            Conexion.cerrar();
            if (myimpresora.Rows.Count > 0)
            {
                ImpresionNOFISCAL.NONFISCALPRINTERNAME = myimpresora.Rows[0][0].ToString();
                //Messa
                //MessageBox.Show(ImpresionNOFISCAL.NONFISCALPRINTERNAME);
                try
                {
                    comboBox1.SelectedItem = ImpresionNOFISCAL.NONFISCALPRINTERNAME;
                }
                catch (Exception) { }
            }
            comboBox1.DroppedDown = true;
            comboBox1.Select();
        }
Exemplo n.º 11
0
        private void Ventas_Load(object sender, EventArgs e)
        {
            totalventa.compraoventa = "NC";
            if (dataGridView1.Rows.Count == 0)
            {
                float cero = 0;
                textBox5.Text = cero.ToString("$0.00");
            }
            textBox3.Text = app.hoy;
            Conexion.abrir();
            DataTable nextid = new DataTable();

            nextid = Conexion.Consultar("AUTOINC_NEXT", "INFORMATION_SCHEMA.COLUMNS", " WHERE (TABLE_NAME = 'NotaCreds') AND (COLUMN_NAME = 'idventa')", "", new SqlCeCommand());
            Conexion.cerrar();
            textBox1.Text         = nextid.Rows[0][0].ToString();
            totalventa.idnotacred = Convert.ToInt32(nextid.Rows[0][0].ToString());
            if (Demo.EsDemo == true)
            {
                textBox2.Text = Demo.demouser;
            }
            else
            {
                textBox2.Text = registereduser.reguser;
            }
            float idv = float.Parse(textBox1.Text);

            if (idv >= 100 && Demo.EsDemo == true)
            {
                this.Close();
                MessageBox.Show("Lo sentimos pero esta es la versión demo del producto y solo se permiten ingresar hasta 100 registros de venta. Si quiere habilitar esta opcion debe comprar la licencia.");
            }
        }
Exemplo n.º 12
0
        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult seguro = MessageBox.Show("Está seguro de poner faltantes y sobrantes en cero?", "Seguro?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (seguro == DialogResult.Yes)
            {
                if (dataGridView1.Rows.Count > 0 && comboBox1.SelectedIndex >= 0)
                {
                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {
                        SqlCeCommand id = new SqlCeCommand();
                        id.Parameters.AddWithValue("id", dataGridView1.Rows[i].Cells[0].Value.ToString());
                        Conexion.abrir();
                        Conexion.Actualizar("Articulos", "faltante = '0', sobrante = '0'", "where idarticulo = @id", "", id);
                        Conexion.cerrar();
                    }
                    if (Application.OpenForms.OfType <DiferenciaStock>().Count() == 1)
                    {
                        Application.OpenForms.OfType <DiferenciaStock>().First().Close();
                    }
                    DiferenciaStock frm = new DiferenciaStock();
                    frm.Show();
                    frm.BringToFront();
                }
                else
                {
                    MessageBox.Show("Debe elegir un provedor y asegurarse de que posea articulos");
                }
            }
        }
Exemplo n.º 13
0
        private void Clientes_Load(object sender, EventArgs e)
        {
            this.Focus();

            Conexion.abrir();
            DataTable showacls = Conexion.Consultar("idcliente,nombre as [Nombre del cliente],atencion as [Atencion],direccion as Domicilio,telefono as Telefono,mail as Email, cuit as CUIT", "Clientes", "where eliminado != 'Eliminado'", "", new SqlCeCommand());

            Conexion.cerrar();
            BindingSource SBind = new BindingSource();

            SBind.DataSource = showacls;
            dataGridView1.AutoGenerateColumns = true;
            dataGridView1.DataSource          = showacls;
            dataGridView1.Columns[0].Visible  = false;
            dataGridView1.DataSource          = SBind;
            dataGridView1.Refresh();
            if (showacls.Rows.Count > 0)
            {
                button2.Enabled = true;
                button9.Enabled = true;
            }
            else
            {
                button2.Enabled = false;
                button9.Enabled = false;
            }
        }
Exemplo n.º 14
0
        public static string getRegLicense()
        {
            Conexion.abrir();
            DataTable license= Conexion.Consultar("NombreEmpresa","Configuracion","","",new SqlCeCommand());
            Conexion.cerrar();
            string reglicense = license.Rows[0][0].ToString();
            return reglicense;

        }
Exemplo n.º 15
0
        void getarts()
        {
            SqlCeCommand elim = new SqlCeCommand();

            elim.Parameters.AddWithValue("el", "Eliminado");
            Conexion.abrir();
            DataTable showarts = Conexion.Consultar("idarticulo,codigoart as [Codigo prod.],descripcion as [Descripcion del Articulo],proveedor as Proveedor,precio as [Pr Venta],costo as [Pr Compra],stockactual as Stock,stockminimo as [Stock Minimo],iva as IVA", "Articulos", "WHERE eliminado != @el", "", elim);

            Conexion.cerrar();
            BindingSource SBind = new BindingSource();

            SBind.DataSource = showarts;
            dataGridView1.AutoGenerateColumns = true;
            dataGridView1.DataSource          = showarts;
            dataGridView1.Columns[0].Visible  = false;
            dataGridView1.Columns[4].DefaultCellStyle.Format = "c";
            dataGridView1.Columns[5].DefaultCellStyle.Format = "c";
            dataGridView1.DataSource = SBind;
            dataGridView1.Refresh();

            if (showarts.Rows.Count > 0)
            {
                label2.Visible           = false;    //sacamos label
                dataGridView1.DataSource = showarts; //mostramos lo que hay
                button2.Enabled          = true;

                button5.Enabled = true;
                //button6.Enabled = true;


                button9.Enabled = true;
                Conexion.abrir();
                DataTable valorizacion = Conexion.Consultar("precio,costo,stockactual", "Articulos", "WHERE eliminado != 'Eliminado'", "", new SqlCeCommand());
                Conexion.cerrar();
                float precio = 0;
                float costo  = 0;
                for (int i = 0; i < valorizacion.Rows.Count; i++)
                {
                    precio += float.Parse(valorizacion.Rows[i][0].ToString()) * float.Parse(valorizacion.Rows[i][2].ToString());
                    costo  += float.Parse(valorizacion.Rows[i][1].ToString()) * float.Parse(valorizacion.Rows[i][2].ToString());
                }
                textBox3.Text = precio.ToString("$0.00");
                textBox2.Text = costo.ToString("$0.00");
            }
            else
            {
                textBox2.Text   = "$0.00";
                textBox3.Text   = "$0.00";
                label2.Visible  = true; //mostramos que no hay registros
                button2.Enabled = false;
                button9.Enabled = false;

                button5.Enabled = false;
                //button6.Enabled = false;
            }
        }
Exemplo n.º 16
0
        private void DiferenciaStock_Load(object sender, EventArgs e)
        {
            Conexion.abrir();
            DataTable proveedores = Conexion.Consultar("nombre", "Proveedores", "WHERE Eliminado != 'Eliminado'", "", new SqlCeCommand());

            Conexion.cerrar();
            for (int i = 0; i < proveedores.Rows.Count; i++)
            {
                comboBox1.Items.Add(proveedores.Rows[i][0].ToString());
            }
        }
Exemplo n.º 17
0
        private void comboBox1_DropDown(object sender, EventArgs e)
        {
            comboBox1.Items.Clear();
            Conexion.abrir();
            DataTable rubros = Conexion.Consultar("nombrerubro", "Rubros", "where eliminado = 'Activo'", "", new SqlCeCommand());

            Conexion.cerrar();
            for (int i = 0; i < rubros.Rows.Count; i++)
            {
                comboBox1.Items.Add(rubros.Rows[i][0].ToString());
            }
        }
Exemplo n.º 18
0
        private void addturno(string user)
        {
            SqlCeCommand usr = new SqlCeCommand();

            usr.Parameters.AddWithValue("u", user);
            usr.Parameters.AddWithValue("fi", DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
            usr.Parameters.AddWithValue("tot", "0");

            Conexion.abrir();
            Conexion.Insertar("Turnos", "Usuario,FechaInicio,TotalVendido", "@u,@fi,@tot", usr);
            Conexion.cerrar();
        }
Exemplo n.º 19
0
        private void Consultas_Load(object sender, EventArgs e)
        {
            if (ConfigFiscal.usaImpFiscal == "no" || Demo.EsDemo == true)
            {
                this.Focus();
                label1.Text = "Listado de Ventas de hoy";
                Conexion.abrir();
                SqlCeCommand fechahoy = new SqlCeCommand();
                fechahoy.Parameters.AddWithValue("hoy", app.hoy);
                if (Demo.EsDemo == true)
                {
                    fechahoy.Parameters.AddWithValue("ven", Demo.demouser);
                }
                else
                {
                    fechahoy.Parameters.AddWithValue("ven", registereduser.reguser);
                }
                fechahoy.Parameters.AddWithValue("anulada", "Anulada");
                DataTable showv = new DataTable();
                if (Demo.EsDemo == true || registereduser.level == "Admin" || registereduser.level == "Supervisor")
                {
                    showv = Conexion.Consultar("nfactura as [N° Fact.], vendedor as Usuario, fechaventa as Fecha, total as Importe, estadoventa as Estado, tipoFactura as Factura", "Ventas", "WHERE datediff(day,fechaventa,@hoy) =  0 AND estadoventa = 'Finalizado' ", " order by nfactura desc", fechahoy);
                }
                else
                {
                    showv = Conexion.Consultar("nfactura as [N° Fact.], vendedor as Usuario, fechaventa as Fecha, total as Importe, estadoventa as Estado, tipoFactura as Factura", "Ventas", "WHERE datediff(day,fechaventa,@hoy) =  0 AND estadoventa = 'Finalizado' and vendedor =@ven ", " order by nfactura desc", fechahoy);
                }

                Conexion.cerrar();
                BindingSource SBind = new BindingSource();
                SBind.DataSource = showv;
                dataGridView1.AutoGenerateColumns = true;
                dataGridView1.DataSource          = showv;
                dataGridView1.DataSource          = SBind;
                dataGridView1.Columns[4].DefaultCellStyle.Format = "c";
                dataGridView1.Refresh();
                if (showv.Rows.Count > 0)
                {
                    dataGridView1.DataSource = showv; //mostramos lo que hay
                }
                textBox1.Focus();
                if (dataGridView1.Rows.Count < 1)
                {
                    button2.Enabled = false;
                }
            }
            else
            {
                MessageBox.Show("Solo se pueden anular ventas cuando el sistema no hace uso de la facturación fiscal");
                this.Close();
            }
        }
Exemplo n.º 20
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex >= 0)
     {
         SqlCeCommand saconombre = new SqlCeCommand();
         saconombre.Parameters.AddWithValue("pr", comboBox1.SelectedItem.ToString());
         Conexion.abrir();
         Conexion.Actualizar("Configuracion", "nombreimpnofiscal = @pr", "", "", saconombre);
         Conexion.cerrar();
         ImpresionNOFISCAL.NONFISCALPRINTERNAME = comboBox1.SelectedItem.ToString();
         MessageBox.Show("Impresora seleccionada:\n" + comboBox1.SelectedItem.ToString());
         this.Close();
     }
 }
Exemplo n.º 21
0
        void vender()
        {
            //guardo en base de datos
            SqlCeCommand item = new SqlCeCommand();

            Conexion.abrir();
            for (int i = 0; i < totalventa.detalle.Rows.Count; i++)
            {
                item.Parameters.Clear();
                item.Parameters.AddWithValue("nf", totalventa.idventa);
                item.Parameters.AddWithValue("idprod", totalventa.detalle.Rows[i][0].ToString());
                item.Parameters.AddWithValue("cp", totalventa.detalle.Rows[i][2].ToString());
                item.Parameters.AddWithValue("dp", totalventa.detalle.Rows[i][3].ToString());
                item.Parameters.AddWithValue("mc", totalventa.detalle.Rows[i][4].ToString());
                item.Parameters.AddWithValue("ca", totalventa.detalle.Rows[i][1].ToString());
                item.Parameters.AddWithValue("pp", totalventa.detalle.Rows[i][5].ToString().Replace("$", ""));
                item.Parameters.AddWithValue("to", totalventa.detalle.Rows[i][6].ToString().Replace("$", ""));
                item.Parameters.AddWithValue("ti", totalventa.detalle.Rows[i][7].ToString().Replace("$", ""));
                string prodser = totalventa.detalle.Rows[i][7].ToString();
                Conexion.Insertar("DetalleVentas", "nfactura,idproducto, codigoproducto , descripproducto, marcaproducto, cantidproducto, precioproducto, totalproducto,tipo", "@nf,@idprod,@cp,@dp,@mc,@ca,@pp,@to,@ti", item);
                if (prodser.Contains("Producto"))
                {
                    Conexion.Actualizar("Articulos", "stockactual = stockactual - @ca", "WHERE idarticulo = @idprod", "", item);
                }
            }
            if (Demo.EsDemo == true)
            {
                item.Parameters.AddWithValue("ve", Demo.demouser);
            }
            else
            {
                item.Parameters.AddWithValue("ve", registereduser.reguser);
            }
            if (Demo.EsDemo == true)
            {
                item.Parameters.AddWithValue("fv", DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
            }
            else
            {
                item.Parameters.AddWithValue("fv", app.hoy + " " + DateTime.Now.ToShortTimeString());
            }

            item.Parameters.AddWithValue("tt", totalventa.totventa.Replace("$", ""));
            item.Parameters.AddWithValue("ev", "Finalizado");
            item.Parameters.AddWithValue("tf", "FC");
            Conexion.Insertar("Ventas", "nfactura, vendedor, fechaventa, total , estadoventa  , tipoFactura ", "@nf,@ve,@fv,@tt,@ev,@tf", item);
            Conexion.cerrar();
            this.Close();
        }
Exemplo n.º 22
0
 private void cargadata()
 {
     if (Demo.EsDemo == false)
     {
         Conexion.abrir();
         DataTable datos = Conexion.Consultar("*", "Configuracion", "", "", new SqlCeCommand());
         Conexion.cerrar();
         if (datos.Rows.Count > 0)
         {
             textBox1.Text        = datos.Rows[0][2].ToString();
             textBox2.Text        = datos.Rows[0][3].ToString();
             textBox3.Text        = datos.Rows[0][4].ToString();
             textBox4.Text        = datos.Rows[0][5].ToString();
             textBox5.Text        = datos.Rows[0][6].ToString();
             textBox6.Text        = datos.Rows[0][8].ToString();
             textBox7.Text        = float.Parse(datos.Rows[0][0].ToString()).ToString("$0.00");
             textBox14.Text       = datos.Rows[0][17].ToString();
             textBox13.Text       = datos.Rows[0][18].ToString();
             textBox12.Text       = datos.Rows[0][19].ToString();
             textBox11.Text       = datos.Rows[0][20].ToString();
             textBox10.Text       = datos.Rows[0][21].ToString();
             textBox9.Text        = datos.Rows[0][22].ToString();
             textBox8.Text        = datos.Rows[0][23].ToString();
             textBox16.Text       = datos.Rows[0][24].ToString();
             numericUpDown1.Value = decimal.Parse(datos.Rows[0][27].ToString());
             if (datos.Rows[0][28].ToString() == "si")
             {
                 checkBox1.Checked = true;
             }
             if (datos.Rows[0][29].ToString() == "si")
             {
                 checkBox2.Checked = true;
             }
             if (datos.Rows[0][30].ToString() == "si")
             {
                 checkBox3.Checked = true;
             }
             if (datos.Rows[0][31].ToString() == "si")
             {
                 checkBox4.Checked = true;
             }
         }
     }
     else
     {
         MessageBox.Show("Esta opcion es para usuarios de licencia solamente");
         this.Close();
     }
 }
Exemplo n.º 23
0
        private void IngreseFecha_Load(object sender, EventArgs e)
        {
            Conexion.abrir();
            DataTable fechasdb = Conexion.Consultar("ultimafechatrabajo", "Configuracion", "", "", new SqlCeCommand());

            Conexion.cerrar();
            ulfecha = fechasdb.Rows[0][0].ToString();

            if (ulfecha.Length < 1)
            {
                ulfecha = DateTime.Now.ToShortDateString();
            }
            label3.Text         = "Ultima fecha de trabajo: " + Convert.ToDateTime(ulfecha).ToShortDateString();
            maskedTextBox1.Text = Convert.ToDateTime(ulfecha).ToShortDateString();
        }
Exemplo n.º 24
0
        void getarts(string prov)
        {
            float faltante, sobrante, diferencia;

            Conexion.abrir();
            SqlCeCommand proveedor = new SqlCeCommand();

            proveedor.Parameters.AddWithValue("pr", prov);
            DataTable showarts = Conexion.Consultar("idarticulo,descripcion as [Descripcion del Articulo],proveedor as Proveedor,precio as Precio,costo as Costo,stockactual as Stock,faltante as [Faltante],sobrante as Sobrante", "Articulos", " WHERE proveedor = @pr and eliminado != 'Eliminado' and tipo LIKE 'Producto%'", "", proveedor);

            Conexion.cerrar();
            BindingSource SBind = new BindingSource();

            SBind.DataSource = showarts;
            dataGridView1.AutoGenerateColumns = true;
            dataGridView1.DataSource          = showarts;
            dataGridView1.Columns[0].Visible  = false;
            dataGridView1.Columns[3].DefaultCellStyle.Format = "c";
            dataGridView1.Columns[4].DefaultCellStyle.Format = "c";
            dataGridView1.DataSource = SBind;
            dataGridView1.Refresh();
            if (showarts.Rows.Count > 0)
            {
                button2.Enabled = true; //mostramos que no hay registros
                button1.Enabled = true;
                float tsob, tfal;
                sobrante = 0;
                faltante = 0;
                tsob     = 0;
                tfal     = 0;
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    tfal += float.Parse(dataGridView1.Rows[i].Cells[3].Value.ToString().Replace("$", "")) * int.Parse(dataGridView1.Rows[i].Cells[6].Value.ToString());
                    tsob += float.Parse(dataGridView1.Rows[i].Cells[3].Value.ToString().Replace("$", "")) * int.Parse(dataGridView1.Rows[i].Cells[7].Value.ToString());
                }
                textBox1.Text = tfal.ToString("$0.00");
                textBox2.Text = tsob.ToString("$0.00");
                textBox3.Text = (tsob - tfal).ToString("$0.00");
            }
            else
            {
                button2.Enabled = false; //mostramos que no hay registros
                button1.Enabled = false;
                faltante        = 0;
                sobrante        = 0;
                diferencia      = faltante - sobrante;
            }
        }
Exemplo n.º 25
0
        void getdebehaber()
        {
            SqlCeCommand dates = new SqlCeCommand();

            dates.Parameters.Clear();
            dates.Parameters.AddWithValue("d1", Convert.ToDateTime(maskedTextBox1.Text + " 00:00:00"));
            dates.Parameters.AddWithValue("d2", Convert.ToDateTime(maskedTextBox2.Text + " 23:59:59"));
            dates.Parameters.AddWithValue("an", "Anulada");
            Conexion.abrir();
            DataTable showdebe    = Conexion.Consultar("area as [Tipo], descripcion as Motivo, importe as Total", "Gastos", "WHERE fecha BETWEEN @d1 AND @d2;", "", dates);
            DataTable showhaber   = Conexion.Consultar("tipoFactura as [Tipo], nfactura as [N°] ,total as [Importe]", "Ventas", " WHERE estadoventa != @an AND fechaventa BETWEEN @d1 AND @d2 ;", "", dates);
            DataTable addIngresos = Conexion.Consultar("tipo,motivo,total", "EntradaCaja", "WHERE fecha BETWEEN @d1 AND @d2;", "", dates);
            DataTable addSalidas  = Conexion.Consultar("tipo,motivo,total", "SalidaCaja", " WHERE fecha BETWEEN @d1 AND @d2;", "", dates);

            Conexion.cerrar();
            for (int i = 0; i < addIngresos.Rows.Count; i++)
            {
                string tipo    = addIngresos.Rows[i][0].ToString();
                string motivo  = addIngresos.Rows[i][1].ToString();
                string importe = addIngresos.Rows[i][2].ToString();
                showhaber.Rows.Add(tipo + "(" + motivo + ")", 0, importe);
            }

            BindingSource SBind = new BindingSource();

            SBind.DataSource = showhaber;
            dataGridView2.AutoGenerateColumns = true;
            dataGridView2.DataSource          = showhaber;
            dataGridView2.Columns[2].DefaultCellStyle.Format = "c";
            dataGridView2.DataSource = SBind;
            dataGridView2.Refresh();

            for (int i = 0; i < addSalidas.Rows.Count; i++)
            {
                string tipo    = addSalidas.Rows[i][0].ToString();
                string motivo  = addSalidas.Rows[i][1].ToString();
                float  importe = float.Parse(addSalidas.Rows[i][2].ToString());
                showdebe.Rows.Add(tipo, motivo, importe.ToString("0.00"));
            }
            BindingSource SBind2 = new BindingSource();

            SBind2.DataSource = showdebe;
            dataGridView1.AutoGenerateColumns = true;
            dataGridView1.DataSource          = showdebe;
            dataGridView1.Columns[2].DefaultCellStyle.Format = "c";
            dataGridView1.DataSource = SBind2;
            dataGridView1.Refresh();
        }
Exemplo n.º 26
0
        private void Clientes_Load(object sender, EventArgs e)
        {
            this.Focus();
            Conexion.abrir();
            DataTable showacls = Conexion.Consultar("idab,fecha as Fecha,codigo as Codigo,descripcion as Descripcion,altas as Altas,bajas as Bajas,motivo as Motivo,vendedor as Vendedor", "Altasbajas", "", "", new SqlCeCommand());

            Conexion.cerrar();
            BindingSource SBind = new BindingSource();

            SBind.DataSource = showacls;
            dataGridView1.AutoGenerateColumns = true;
            dataGridView1.DataSource          = showacls;
            dataGridView1.Columns[0].Visible  = false;
            dataGridView1.DataSource          = SBind;
            dataGridView1.Refresh();
        }
Exemplo n.º 27
0
 private void textBox1_Leave(object sender, EventArgs e)
 {
     if (textBox1.Text.Length > 0)
     {
         SqlCeCommand checkexistance = new SqlCeCommand();
         checkexistance.Parameters.AddWithValue("code", textBox1.Text);
         Conexion.abrir();
         DataTable existira = Conexion.Consultar("login", "Usuarios", "where login = @code and eliminado != 'Eliminado'", "", checkexistance);
         Conexion.cerrar();
         if (existira.Rows.Count > 0 && createorupdate.status == "create")
         {
             MessageBox.Show("Ese usuario ya existe, use otro nombre de usuario por favor");
             textBox1.Text = "";
         }
     }
 }
Exemplo n.º 28
0
 private void textBox1_Leave(object sender, EventArgs e)
 {
     if (textBox1.Text.Length > 0 && createorupdate.status == "create")
     {
         SqlCeCommand existe = new SqlCeCommand();
         existe.Parameters.AddWithValue("cuitx", textBox1.Text);
         Conexion.abrir();
         DataTable existira = Conexion.Consultar("numcuit", "Proveedores", "Where numcuit = @cuitx", "", existe);
         Conexion.cerrar();
         if (existira.Rows.Count > 0)
         {
             MessageBox.Show("Ese CUIT de proveedor ya existe, no se admiten clientes duplicados en el sistema.");
             textBox1.Text = "";
             textBox1.Focus();
         }
     }
 }
Exemplo n.º 29
0
 private void textBox2_Leave(object sender, EventArgs e)
 {
     if (textBox2.Text.Length > 0 && createorupdate.status == "create")
     {
         SqlCeCommand existe = new SqlCeCommand();
         existe.Parameters.AddWithValue("nombrex", textBox2.Text);
         Conexion.abrir();
         DataTable existira = Conexion.Consultar("nombre", "Proveedores", "Where nombre = @nombrex and Eliminado != 'Eliminado'", "", existe);
         Conexion.cerrar();
         if (existira.Rows.Count > 0)
         {
             MessageBox.Show("Ese nombre de proveedor ya existe, intente con otro nombre");
             textBox2.Text = "";
             textBox2.Focus();
         }
     }
 }
Exemplo n.º 30
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count > 0)
            {
                int    rowIndex = dataGridView1.CurrentCell.RowIndex;
                var    row      = this.dataGridView1.Rows[rowIndex];
                string name     = row.Cells["Nombre del cliente"].Value.ToString();
                string id       = row.Cells["idcliente"].Value.ToString();

                DialogResult borrar = MessageBox.Show("Está seguro de borrar este Cliente?\n" + name, "Borrar?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (borrar == DialogResult.Yes)
                {
                    Conexion.abrir();
                    SqlCeCommand del = new SqlCeCommand();
                    del.Parameters.AddWithValue("@id", id);
                    del.Parameters.AddWithValue("@el", "Eliminado");
                    //Conexion.Eliminar("Clientes", "idcliente = @id", del);
                    Conexion.Actualizar("Clientes", "eliminado = @el", "where idcliente = @id", "", del);
                    Conexion.abrir();
                    DataTable showacls = Conexion.Consultar("idcliente,nombre as [Nombre del cliente],atencion as [Atencion],direccion as Domicilio,telefono as Telefono,mail as Email, cuit as CUIT", "Clientes", "where eliminado != 'Eliminado'", "", new SqlCeCommand());
                    Conexion.cerrar();
                    BindingSource SBind = new BindingSource();
                    SBind.DataSource = showacls;
                    dataGridView1.AutoGenerateColumns = true;
                    dataGridView1.DataSource          = showacls;
                    dataGridView1.Columns[0].Visible  = false;
                    dataGridView1.DataSource          = SBind;
                    dataGridView1.Refresh();
                    if (showacls.Rows.Count > 0)
                    {
                        button2.Enabled = true;
                        button9.Enabled = true;
                    }
                    else
                    {
                        button2.Enabled = false;
                        button9.Enabled = false;
                    }
                }
            }
            else
            {
                MessageBox.Show("No hay ningun cliente seleccionado para borrar");
            }
        }