示例#1
0
        private void Facturas_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F4)
            {
                if (cont_fila > 0)
                {
                    totalidad = totalidad - (Convert.ToDecimal(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[4].Value));


                    resultadotxt.Text = "$" + totalidad.ToString("N2");


                    dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);

                    cont_fila--;
                }
            }
            if (e.KeyCode == Keys.End)
            {
                completar();
                venta.Agregarventa(vendedor, codigocliente, fechatxt.Text);
                DataTable ds;
                ds    = venta.ventamax();
                factu = ds.Rows[0][0].ToString();
                foreach (DataGridViewRow fila in dataGridView1.Rows)
                {
                    venta.ventapro(factu, Convert.ToString(fila.Cells[0].Value), Convert.ToString(fila.Cells[2].Value));
                }
                reporte_factura fer = new reporte_factura();


                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    reportfactu c = new reportfactu();
                    c.nombre   = (string)this.dataGridView1.Rows[i].Cells[1].Value;
                    c.cantidad = (string)this.dataGridView1.Rows[i].Cells[2].Value;
                    c.precio   = (string)this.dataGridView1.Rows[i].Cells[3].Value;
                    c.importe  = (decimal)this.dataGridView1.Rows[i].Cells[4].Value;
                    c.fecha    = fechatxt.Text;
                    c.total    = resultadotxt.Text;
                    fer.datos.Add(c);
                }
                fer.ShowDialog();
                dataGridView1.Rows.Clear();
                resultadotxt.Text = "";
                cont_fila         = 0;
                totalidad         = 0;
                productotxt.Focus();
            }
        }
示例#2
0
        private void btn_vender_Click(object sender, EventArgs e)
        {
            completar();
            if (string.IsNullOrEmpty(codigocliente) || codigocliente == "0")
            {
                codigocliente = "1";
            }
            venta.Agregarventa(vendedor, codigocliente, fechatxt.Text);
            DataTable ds;

            ds    = venta.ventamax();
            factu = ds.Rows[0][0].ToString();
            foreach (DataGridViewRow fila in dataGridView1.Rows)
            {
                venta.ventapro(factu, Convert.ToString(fila.Cells[0].Value), Convert.ToString(fila.Cells[2].Value));
            }
            reporte_factura fer = new reporte_factura();


            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                reportfactu c = new reportfactu();
                c.nombre   = (string)this.dataGridView1.Rows[i].Cells[1].Value;
                c.cantidad = (string)this.dataGridView1.Rows[i].Cells[2].Value;
                c.precio   = (string)this.dataGridView1.Rows[i].Cells[3].Value;
                c.importe  = (decimal)this.dataGridView1.Rows[i].Cells[4].Value;
                c.fecha    = fechatxt.Text;
                c.total    = resultadotxt.Text;
                fer.datos.Add(c);
            }
            fer.ShowDialog();
            dataGridView1.Rows.Clear();
            resultadotxt.Text = "";
            ivatex.Text       = "";
            cont_fila         = 0;
            totalidad         = 0;
            productotxt.Focus();

            button1.Enabled    = false;
            btn_vender.Enabled = false;
            eliminar.Enabled   = false;
        }