public static List<ventasfact> consultaventasnot()
        {

            List<ventasfact> _lista = new List<ventasfact>();



            MySqlCommand _comando = new MySqlCommand(String.Format(

           "SELECT * FROM factura where tipo_compra='nota'"), BdComun.ObtenerConexion());

            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {

                ventasfact pCliente = new ventasfact();

                 pCliente.id = _reader.GetInt32(0);
                pCliente.tipo_compra = _reader.GetString(1);
                pCliente.fechaventa = _reader.GetString(2);
                pCliente.Total = _reader.GetString(3);

                _lista.Add(pCliente);

            }



            return _lista;


        }
        public static int Agregar(ventasfact ventas)
        {

            int retorno = 0;

            MySqlCommand comando = new MySqlCommand(string.Format("Insert into factura (tipo_compra,fecha_venta, Total) values ('{0}','{1}','{2}')",
            ventas.tipo_compra, ventas.fechaventa, ventas.Total), BdComun.ObtenerConexion());
           retorno = comando.ExecuteNonQuery();
            return retorno;
        }
        public static int Agregar(ventasfact ventas)
        {

            int retorno = 0;

            MySqlCommand comando = new MySqlCommand(string.Format("Insert into Insumos (vendedor,producto,tipo_compra,color,unidades,cantidad,fecha_venta,total) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')",
            ventas.tipo_compra,ventas.fechaventa,ventas.Total), BdComun.ObtenerConexion());
            retorno = comando.ExecuteNonQuery();
            return retorno;

            
        }
Ejemplo n.º 4
0
        private void toolStripButton2_Click(object sender, EventArgs e)
        {

            DateTime dd = DateTime.Now;
            /*/this.vendedor = ven;
            this.producto = product;
            this.tipo_compra = tipo_com;
            this.color = colo;
            this.unidades = unidad;
            this.cantidad = cant;
            this.fechaventa = fecha;
            this.Total = tot;/*/

            if (vent == Convert.ToUInt32(txtventas.Text))
            {
                button4.Enabled = true;
                txtventas.Enabled = true;


                if (precioc != 0 && preciog != 0 && preciolip != 0)
                {
                    if (rdbCaja.Checked)
                    {
                        if (cmbcolorcaja.Text != "" && cmbcajaunidades.Text != "" && cmbdiamcaja.Text != "")
                        {
                            ventasfact pCliente = new ventasfact();

                            if (rdfactura.Checked)
                            {
                                pCliente.tipo_compra = "factura";
                            }
                            else
                            {
                                pCliente.tipo_compra = "nota";
                            }

                            pCliente.fechaventa = dd.ToString("yyyy/MM/dd");
                            label29.Text = total.sumasubtotal().ToString();
                            pCliente.Total = label29.Text;


                            int resultado = ventafactdal.Agregar(pCliente);
                            if (resultado > 0)
                            {
                                MessageBox.Show("Compra realizada Con Exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                MessageBox.Show("No se pudo guardar el cliente", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Faltan campos por llenar", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }


                    else
                        if (rdbUnidad.Checked)
                        {
                            if (cmbcolorunidad.Text != "" && cmbdiamunidad.Text != "")
                            {
                                //factura//
                                objeto = new Totales(Convert.ToInt32(nucantunidad.Value), Convert.ToInt32(cmbdiamunidad.Text), Convert.ToInt32(0), precioc, preciog, preciolip);
                                label29.Text = total.sumasubtotal().ToString();
                                ventasfact pCliente = new ventasfact();
                                if (rdfactura.Checked)
                                {
                                    pCliente.tipo_compra = "factura";
                                }
                                else
                                {
                                    pCliente.tipo_compra = "nota";
                                }
                                pCliente.fechaventa = dd.ToString("yyyy/MM/dd");
                                pCliente.Total = label29.Text;
                                int resultado = ventafactdal.Agregar(pCliente);
                                if (resultado > 0)
                                {
                                    MessageBox.Show("Compra realizada Con Exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                                else
                                {
                                    MessageBox.Show("No se pudo guardar el cliente", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Faltan campos por llenar", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                }
                else
                {
                    MessageBox.Show("Para realizar compras debe insertar los precios de los insumos", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    tabControl1.SelectTab(1);
                }
            }
            else
            {
                MessageBox.Show("falta realizar compras");
            }



        }