private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox5.Text != "")
                {
                    using (GestorVenta venta = new GestorVenta())
                    {
                        venta.InsertarNewVenta(id_cliente, id_usuario, DateTime.Parse("2018-02-01").ToString(), textBox5.Text);
                        CargarUltimoIdBill();
                    }

                    FrmVentasNuevas FrmVentasNuevas = new FrmVentasNuevas(id_usuario, id_cliente, id_lastbill, usuario, cargo, id_cliente);
                    FrmVentasNuevas.Show();
                    this.SetVisibleCore(false);
                }
                else
                {
                    MessageBox.Show("No ha llenado el campo de detalle", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception o) {
                Console.Write(o);
            }
        }
Example #2
0
        /// <summary>
        /// Guardamos la venta en la base de datos
        /// </summary>
        private void GuardarVenta()
        {
            int id_pago = 0;    //variable que almacena la forma de pago 1 = efectivo, 2 = tarjeta y 3 = ambos

            if (efectivo > 0)
            {
                id_pago = 1;
            }
            else if (tarjeta > 0)
            {
                id_pago = 2;
            }
            else if (tarjeta > 0 && efectivo > 0)
            {
                id_pago = 3;
            }
            try
            {
                using (GestorVenta venta = new GestorVenta())
                {
                    venta.InsertarVenta(id_cliente, id_usuario, fecha, id_pago, saldo, "A");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error " + e);
            }
        }
Example #3
0
 private void btnExpediente_Click(object sender, EventArgs e)
 {
     if (txtDetails.Text != "" && txtPrice.Text != "")
     {
         f1 = Date.Value.ToString("MM-dd-yyyy");
         using (GestorVenta laVenta = new GestorVenta())
         {
             if (txtGuys.Text != "0" && txtHours.Text != "0")
             {
                 laVenta.ModifyBill(int.Parse(label1.Text), int.Parse(label27.Text), f1, txtDetails.Text + " Guys: " + txtGuys.Text + " Hours: " + txtHours.Text, double.Parse(txtPrice.Text), amount());
                 MessageBox.Show("Modify successful", caption: "Alerta", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Information);
             }
             else if (txtGuys.Text == "0" && txtHours.Text == "0" && textUnitPrice.Text != "0" && textUnits.Text != "0")
             {
                 laVenta.ModifyBill(int.Parse(label1.Text), int.Parse(label27.Text), f1, txtDetails.Text + " Units: " + textUnits.Text, double.Parse(txtPrice.Text), amount());
                 MessageBox.Show("Modify successful", caption: "Alerta", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Information);
             }
             else
             {
                 laVenta.ModifyBill(int.Parse(label1.Text), int.Parse(label27.Text), f1, txtDetails.Text, double.Parse(txtPrice.Text), amount());
                 MessageBox.Show("Modify successful", caption: "Alerta", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Information);
             }
             CargarFactura();
             LimpiarCampos();
             btnExpediente.Visible = false;
             label26.Visible       = false;
         }
     }
     else
     {
         MessageBox.Show("ยก Debe rellenar todos los espacios ! ", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     CalcularTotales();
     LimpiarCampos();
 }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        private void CargarNumFactura()
        {
            using (GestorVenta recibo = new GestorVenta())
            {
                dsVentas = recibo.ConsultarUltimoVenta();
                dtVentas = this.dsVentas.Tables[0];

                numRecibo = int.Parse(this.dtVentas.Rows[0]["siguiente"].ToString());
            }
        }
Example #5
0
        private void CargarFactura()
        {
            using (GestorVenta bills = new GestorVenta())
            {
                dgv_ventas.DataSource = bills.ConsultarVentaE(id_lastbill);

                dgv_ventas.Columns["id_bill"].Visible         = false;
                dgv_ventas.Columns["fecha"].HeaderText        = "fecha";
                dgv_ventas.Columns["details"].HeaderText      = "details";
                dgv_ventas.Columns["servicePrice"].HeaderText = "servicePrice";
                dgv_ventas.Columns["amount"].HeaderText       = "amount";
            }
        }
Example #6
0
        private void Guardar()
        {
            using (GestorVenta insertnewsavebills = new GestorVenta())
            {
                f1 = fecha.ToString("MM/dd/yyyy");


                insertnewsavebills.InsertNewSaveBills(id_customer, f1, id_lastbill);
                MessageBox.Show("Saved successfully", caption: "Alerta", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Information);
                frmBill volver = new frmBill(id_usuario, usuario, cargo, id_customer);
                volver.Show();
                this.SetVisibleCore(false);
            }
        }
        private void btn_Agregar_Click(object sender, EventArgs e)
        {
            f1 = Date.Value.ToString("MM-dd-yyyy");



            if (txtPrice.Text != "" || txtDetails.Text != "")
            {
                if (radioButton1.Checked)
                {
                    precio = double.Parse(txtPrice.Text);
                }
                else
                {
                    precio = double.Parse(txtPrice.Text);
                }
                using (GestorVenta insertbills = new GestorVenta())
                {
                    double amount = precio;

                    if (txtGuys.Text != "0" && txtHours.Text != "0")
                    {
                        insertbills.InsertarVenta(id_lastbill, f1, txtDetails.Text + " Guys: " + txtGuys.Text + " Hours: " + txtHours.Text, Double.Parse(textUnitPrice.Text), amount);
                    }
                    else if (txtGuys.Text == "0" && txtHours.Text == "0" && textUnitPrice.Text != "0" && textUnits.Text != "0")
                    {
                        insertbills.InsertarVenta(id_lastbill, f1, txtDetails.Text + " Units: " + textUnits.Text, Double.Parse(textUnitPrice.Text), amount);
                    }
                    else
                    {
                        insertbills.InsertarVenta(id_lastbill, f1, txtDetails.Text, precio, amount);
                    }

                    MessageBox.Show("Sirve", caption: "Alerta", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Information);
                    CargarFactura();
                    CalcularTotales();
                    LimpiarCampos();
                }
            }
            else
            {
                MessageBox.Show("LLenar todos los campos");
            }
        }
Example #8
0
        private void GuardarDetalleVenta()
        {
            string fecha = DateTime.Now.ToShortDateString();

            try
            {
                using (GestorVenta venta = new GestorVenta())
                {
                    dsVentas = venta.ConsultarUltimoVenta();
                    dtVentas = this.dsVentas.Tables[0];

                    foreach (DataGridViewRow fila in dgv_ventas.Rows)
                    {
                        //agregamos la cantidad, el precio y subtotal
                        string codProd = Convert.ToString(fila.Cells[0].Value);
                        int    canti   = Convert.ToInt32(fila.Cells[2].Value);
                        string tipo    = Convert.ToString(fila.Cells[3].Value);
                        int    prec    = Convert.ToInt16(fila.Cells[4].Value);
                        int    subt    = Convert.ToInt16(fila.Cells[5].Value);
                        if (tipo.Equals("GRAVADO"))
                        {
                            double aux = subt * 0.13 + subt;
                            subtotal = int.Parse(aux.ToString());
                        }
                        else
                        {
                            subtotal = subt;
                        }
                        venta.InsertarDetalleVenta(numRecibo, codProd, canti, prec, subtotal, "A");
                        subtotal = 0;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error " + e);
            }
        }