Exemplo n.º 1
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                List <Form> OpenForms = new List <Form>();

                ventas       ventas = new ventas();
                Cotizaciones cot    = new Cotizaciones();
                foreach (Form frm in Application.OpenForms)
                {
                    if (frm.Name == "ventas")
                    {
                        ventas = (ventas)frm;

                        ventas.txtProducto.Text    = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                        ventas.txtDescripcion.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString();
                        // ventas.txtPallet.Text = dataGridView1.CurrentRow.Cells[7].Value.ToString();
                        ventas.textBox5.Text        = dataGridView1.CurrentRow.Cells[1].Value.ToString();
                        ventas.textBox4.Text        = dataGridView1.CurrentRow.Cells[2].Value.ToString();
                        ventas.txtPrecio.Text       = dataGridView1.CurrentRow.Cells[4].Value.ToString();
                        ventas.cantidad.Text        = dataGridView1.CurrentRow.Cells[5].Value.ToString();
                        ventas.txtUniMedAduana.Text = dataGridView1.CurrentRow.Cells[6].Value.ToString();
                        ventas.txtSAT.Text          = dataGridView1.CurrentRow.Cells[7].Value.ToString();
                        ventas.txtAduana.Text       = dataGridView1.CurrentRow.Cells[8].Value.ToString();
                        ventas.txtFraccion.Text     = dataGridView1.CurrentRow.Cells[10].Value.ToString();
                        ventas.txtMedida.Text       = dataGridView1.CurrentRow.Cells[9].Value.ToString();


                        this.Close();

                        break;
                    }

                    else if (frm.Name == "Cotizaciones")
                    {
                        cot = (Cotizaciones)frm;

                        cot.txtProducto.Text    = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                        cot.txtDescripcion.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString();
                        cot.txtMedida.Text      = dataGridView1.CurrentRow.Cells[2].Value.ToString();
                        //cot.txtPallet.Text = dataGridView1.CurrentRow.Cells[7].Value.ToString();
                        cot.txtTam.Text    = dataGridView1.CurrentRow.Cells[1].Value.ToString();
                        cot.txtPrecio.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString();
                        cot.txtCan.Text    = dataGridView1.CurrentRow.Cells[5].Value.ToString();


                        this.Close();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
 private void btnVentas_Click(object sender, EventArgs e)
 {
     if (ventas == null)
     {
         ventas                       = new ventas();
         ventas.Owner                 = this;
         ventas.FormClosed           += ventas_FormClosed;
         ventas.dateTimePicker1.Value = DateTime.Today;
         ventas.Show();
     }
     else
     {
         ventas.Activate();
     }
 }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            ventas       inf  = new ventas();
            compras      com  = new compras();
            Cotizaciones coti = new Cotizaciones();

            if (dataGridView1.SelectedRows.Count > 0)
            {
                if (cmdReporte.Text.Equals("Ventas"))
                {
                    inf.txtFolio.Text        = dataGridView1.CurrentRow.Cells["Id"].Value.ToString();
                    inf.dateTimePicker1.Text = dataGridView1.CurrentRow.Cells["date"].Value.ToString();
                    inf.txtIva.Text          = dataGridView1.CurrentRow.Cells["iva"].Value.ToString();
                    inf.txtNumCliente.Text   = dataGridView1.CurrentRow.Cells["num"].Value.ToString();
                    //inf.txtCajasContenido.Text = dataGridView1.CurrentRow.Cells["cajas"].Value.ToString();
                    inf.comboBox3.Text      = dataGridView1.CurrentRow.Cells["nombreP"].Value.ToString();
                    inf.comboMoneda.Text    = dataGridView1.CurrentRow.Cells["currency"].Value.ToString();
                    inf.txtCondiciones.Text = dataGridView1.CurrentRow.Cells["cond"].Value.ToString();
                    inf.txtLugarExpe.Text   = dataGridView1.CurrentRow.Cells["lugar"].Value.ToString();
                    inf.txtSubtotal.Text    = dataGridView1.CurrentRow.Cells["subtotal"].Value.ToString();
                    inf.txtTotal.Text       = dataGridView1.CurrentRow.Cells["total"].Value.ToString();
                    //inf.txtCajasContenido.Text = dataGridView1.CurrentRow.Cells[""].Value.ToString();

                    inf.dateTimePicker1.Enabled = false;
                    inf.txtIva.Enabled          = false;
                    //inf.txtCajasContenido.Enabled = false;
                    inf.comboBox3.Enabled      = false;
                    inf.txtLugarExpe.Enabled   = false;
                    inf.txtCondiciones.Enabled = false;
                    inf.comboMoneda.Enabled    = false;
                    inf.txtPallet.Enabled      = false;
                    inf.txtCantidad.Enabled    = false;
                    inf.cantidad.Text          = "0";

                    inf.button2.Visible        = false;
                    inf.btnArticulo.Visible    = false;
                    inf.btnMostrar.Visible     = true;
                    inf.button4.Visible        = false;
                    inf.btnAgregarProd.Visible = false;
                    inf.btnEliminar.Visible    = false;
                    inf.btnMostrar.Visible     = false;
                    //inf.txtFolio.Visible = false;
                    inf.dataGridView1.Visible = false;
                    inf.dataGridView2.Visible = true;
                    inf.textBox3.Enabled      = false;



                    inf.ShowDialog();
                }
                else if (cmdReporte.Text.Equals("Compras"))
                {
                    com.txtFolioCompra.Text  = dataGridView1.CurrentRow.Cells["Id"].Value.ToString();
                    com.dateTimePicker1.Text = dataGridView1.CurrentRow.Cells["fecha"].Value.ToString();
                    //com.txtTipo.Text = dataGridView1.CurrentRow.Cells["tipo"].Value.ToString();
                    //com.txtName.Text = dataGridView1.CurrentRow.Cells["product"].Value.ToString();
                    //com.txtPrecioUnitario.Text = dataGridView1.CurrentRow.Cells["price"].Value.ToString();
                    com.prov.Text     = dataGridView1.CurrentRow.Cells["provider"].Value.ToString();
                    com.txtNoPro.Text = dataGridView1.CurrentRow.Cells["numberP"].Value.ToString();
                    com.txtTot.Text   = dataGridView1.CurrentRow.Cells["total"].Value.ToString();
                    //com.txtCantidad.Text = dataGridView1.CurrentRow.Cells["amountPurchased"].Value.ToString();
                    //com.txtTotalCompra.Text = dataGridView1.CurrentRow.Cells["total"].Value.ToString();
                    //com.txtDescripcion.Text = dataGridView1.CurrentRow.Cells["description"].Value.ToString();

                    com.dateTimePicker1.Enabled   = false;
                    com.txtTipo.Enabled           = false;
                    com.dataGridView1.Visible     = false;
                    com.dataGridView2.Visible     = true;
                    com.button2.Visible           = false;
                    com.prov.Enabled              = false;
                    com.txtTot.Enabled            = false;
                    com.txtPrecioUnitario.Enabled = false;
                    com.txtName.Enabled           = false;
                    com.txtDescripcion.Enabled    = false;
                    com.btnGuardar.Visible        = false;
                    com.btrRegreso.Visible        = false;
                    com.button1.Visible           = false;
                    com.button3.Visible           = false;



                    com.ShowDialog();
                }
                else if (cmdReporte.Text.Equals("Cotizaciones"))
                {
                    coti.txtFolio.Text    = dataGridView1.CurrentRow.Cells["Id"].Value.ToString();
                    coti.Date.Text        = dataGridView1.CurrentRow.Cells["date"].Value.ToString();
                    coti.pallet.Text      = dataGridView1.CurrentRow.Cells["pallet"].Value.ToString();
                    coti.Expiration.Text  = dataGridView1.CurrentRow.Cells["expiration"].Value.ToString();
                    coti.IdClient.Text    = dataGridView1.CurrentRow.Cells["idCliente"].Value.ToString();
                    coti.ico.Text         = dataGridView1.CurrentRow.Cells["icoterm"].Value.ToString();
                    coti.Customer.Text    = dataGridView1.CurrentRow.Cells["customerName"].Value.ToString();
                    coti.txtTotal.Text    = dataGridView1.CurrentRow.Cells["total"].Value.ToString();
                    coti.txtSubtotal.Text = dataGridView1.CurrentRow.Cells["subtotal"].Value.ToString();
                    coti.divisa.Text      = dataGridView1.CurrentRow.Cells["currency"].Value.ToString();
                    coti.txtIva.Text      = dataGridView1.CurrentRow.Cells["IVA"].Value.ToString();
                    coti.place.Text       = dataGridView1.CurrentRow.Cells["place"].Value.ToString();
                    coti.Condicion.Text   = dataGridView1.CurrentRow.Cells["cond"].Value.ToString();
                    coti.textBox1.Text    = dataGridView1.CurrentRow.Cells["producto"].Value.ToString();
                    coti.flete.Text       = dataGridView1.CurrentRow.Cells["flete"].Value.ToString();

                    coti.txtCan.Text        = "0";
                    coti.Date.Enabled       = false;
                    coti.pallet.Enabled     = false;
                    coti.place.Enabled      = false;
                    coti.textBox1.Enabled   = false;
                    coti.Expiration.Enabled = false;
                    coti.ico.Enabled        = false;
                    coti.divisa.Enabled     = false;
                    coti.txtIva.Enabled     = false;
                    coti.Customer.Enabled   = false;
                    coti.Condicion.Enabled  = false;
                    coti.flete.Enabled      = false;
                    coti.txtPallet.Enabled  = false;
                    coti.txtMedida.Enabled  = false;


                    coti.btnArticulo.Visible    = false;
                    coti.btnAgregarProd.Visible = false;
                    coti.btnEliminar.Visible    = false;
                    coti.button2.Visible        = false;
                    coti.button3.Visible        = false;
                    coti.button1.Visible        = false;
                    coti.button5.Visible        = false;
                    coti.TablaDeVenta.Visible   = false;
                    coti.dataGridView1.Visible  = true;

                    coti.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("Seleccione una fila por favor");
            }
        }
Exemplo n.º 4
0
        private void ventas_Load(object sender, EventArgs e)
        {
            //dateTimePicker1.Value = DateTime.Today;
            txtCantidad.Enabled = false;

            SqlCommand cm = new SqlCommand("select name from FinishedProducts", connection);

            connection.Open();
            SqlDataReader registro = cm.ExecuteReader();

            while (registro.Read())
            {
                comboBox1.Items.Add(registro["name"].ToString());
            }
            connection.Close();
            SqlCommand d = new SqlCommand("select name from clientes", connection);

            connection.Open();
            SqlDataReader r = d.ExecuteReader();

            while (r.Read())
            {
                comboBox3.Items.Add(r["name"].ToString());
            }
            connection.Close();
            SqlCommand cm2 = new SqlCommand("select nombres + '-' + primerApellido +'-' + segundoApellido as name from clientesFisicos", connection);

            connection.Open();
            SqlDataReader r2 = cm2.ExecuteReader();

            while (r2.Read())
            {
                comboBox3.Items.Add(r2["name"].ToString());
            }
            connection.Close();


            ventas ven   = new ventas();
            string query = "select max(Id) from ventas";
            // jess
            SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\William carmona\Documents\Desarrollo\Cagada Adrian\WaareDev\BD\fruteria.mdf;Integrated Security=True");
            // karina
            //SqlConnection con = new SqlConnection(@"Server=tcp:OMEN-LAPTOP18\SQLEXPRESS02,49172;DataBase= fruteria; User Id=Cliente ; Password=cliente1234");
            SqlCommand cmd = new SqlCommand(query, con);

            try
            {
                con.Open();
                string pcount = Convert.ToString(cmd.ExecuteScalar());
                if (this.txtFolio.Text.Equals(""))
                {
                    //string pcount = Convert.ToString(cmd.ExecuteScalar());
                    if (pcount.Length == 0)
                    {
                        txtFolio.Text = "1";
                    }
                    else
                    {
                        int pcount1   = Convert.ToInt32(pcount);
                        int pcountAdd = pcount1 + 1;
                        txtFolio.Text = pcountAdd.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                con.Close();
            }

            SqlCommand     com  = new SqlCommand("select * from detalleVenta where folio='" + txtFolio.Text + "'", connection);
            SqlDataAdapter adap = new SqlDataAdapter();

            adap.SelectCommand = com;
            DataTable tabla = new DataTable();

            adap.Fill(tabla);
            dataGridView2.DataSource = tabla;

            this.dataGridView2.Columns[0].HeaderText = "Folio";
            this.dataGridView2.Columns[1].HeaderText = "Pallet x contenido";
            this.dataGridView2.Columns[2].HeaderText = "Tamaño";
            this.dataGridView2.Columns[3].HeaderText = "Medida";
            this.dataGridView2.Columns[4].HeaderText = "Producto";
            this.dataGridView2.Columns[5].HeaderText = "Descripción";
            this.dataGridView2.Columns[6].HeaderText = "Precio";
            this.dataGridView2.Columns[7].HeaderText = "Cajas";
            this.dataGridView2.Columns[8].HeaderText = "Total";


            //SqlCommand c = new SqlCommand("select * from FinishedProducts where name='"+txtProducto.Text+"'",connection);
            //SqlDataAdapter ad = new SqlDataAdapter();
            //ad.SelectCommand = c;
            //DataTable tab = new DataTable();
            //ad.Fill(tab);
            //dataGridView3.DataSource = tab;



            //try
            //{
            //    List<Form> OpenForms = new List<Form>();

            //}
        }
Exemplo n.º 5
0
 private void ventas_FormClosed(object sender, FormClosedEventArgs e)
 {
     ventas       = null;
     cotizaciones = null;
 }