コード例 #1
0
        private async Task crearVenta()
        {
            if (dgvbase.Rows.Count < 1)
            {
                MessageBox.Show("No puede realizar la venta con 0 servicios a capturar.", "Datos invalidos", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            var rc = MessageBox.Show($"Desea completar la venta?",
                                     "Confirmar",
                                     MessageBoxButtons.YesNo,
                                     MessageBoxIcon.Question
                                     );

            if (rc == DialogResult.No)
            {
                return;
            }

            List <notaventa_detalle> nvd = new List <notaventa_detalle>();

            nvd = CitaDetalle.Select(citadetalle =>
                                     new notaventa_detalle
            {
                nvd_cantidad = (short)citadetalle.Cantidad,
                nvd_precio   = citadetalle.Precio,
                nvd_servicio = (short)citadetalle.ServicioId,
                nvd_estatus  = 1
            }
                                     ).ToList();

            var venta = await vtCtrl.crearNueva(new notaventa
            {
                nv_cita     = this.Cita.Id,
                nv_cliente  = this.CitaBase.ct_cliente,
                nv_empleado = this.CitaBase.ct_empleado,
                nv_estatus  = 1,
                nv_total    = Convert.ToDecimal(txtimporte.Text)
            },
                                                nvd);

            if (venta != null)
            {
                var r = MessageBox.Show($"La venta se realizo exitosamente, desea imprimir el ticket?",
                                        "Confirmar",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question
                                        );
                if (r == DialogResult.No)
                {
                    reiniciarFormulario();
                    return;
                }
                // TODO: IMPRIMIR TICKET.
                var frmticketVenta = new frmticketcita(this.CitaDetalle, DateTime.Now, Convert.ToInt32(txtfolio.Text));
                frmticketVenta.ShowDialog();
                reiniciarFormulario();
            }
        }
コード例 #2
0
        private async void btnagendar_Click(object sender, EventArgs e)
        {
            if (txthora.Text.Length < 1 || txtminuto.Text.Length < 1)
            {
                MessageBox.Show("La cita debe tener hora y minutos.", "Datos invalidos", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtcantservicios.Value == 0)
            {
                MessageBox.Show("No puede hacer 0 servicios.", "Datos invalidos", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (dgvserv.Rows.Count < 1)
            {
                MessageBox.Show("No puede hacer 0 servicios.", "Datos invalidos", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var r = MessageBox.Show("Agendar cita?", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (r == DialogResult.No)
            {
                return;
            }

            this.Cursor = Cursors.WaitCursor;
            List <cita_detalle> citaDetalles = new List <cita_detalle>();

            foreach (DataGridViewRow row in dgvserv.Rows)
            {
                citaDetalles.Add(new cita_detalle
                {
                    sv_id      = (short)Convert.ToInt32(row.Cells[0].Value.ToString()),
                    sv_cant    = Convert.ToInt32(row.Cells[2].Value.ToString()),
                    sv_precio  = Convert.ToDecimal(row.Cells[3].Value.ToString()),
                    sv_importe = Convert.ToDecimal(row.Cells[4].Value.ToString()),
                });
            }
            var cita = await ctCtrl.crearCita(new citas
            {
                ct_estatus  = 1,
                ct_cliente  = this.Cliente.idcliente,
                ct_empleado = this.Empleado.Id,
                ct_fecha    = this.txtfecha.Value,
                ct_hora     = Convert.ToDateTime($"{txthora.Text}:{txtminuto.Text}:00").TimeOfDay,
            },
                                              citaDetalles);

            this.Cursor = Cursors.Default;
            if (cita != null)
            {
                var msg = MessageBox.Show(
                    $"Se creo una cita con folio {cita.idcita}, para el cliente " +
                    $"{this.Cliente.cl_nombrecompleto} para el dia " +
                    $"{this.txtfecha.Value.Day}/{this.txtfecha.Value.Month}/{this.txtfecha.Value.Year} a " +
                    $"las {this.txthora.Text}:{this.txtminuto.Text}, Imprimir ticket?",
                    "Operacion exitosa, Imprimir ticket?", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (msg == DialogResult.No)
                {
                    reloadForm();
                    return;
                }
                // Abrir el formulario con el ticket.
                var ctd = await ctCtrl.getFullCita(cita.idcita);

                var frmTicketCita = new frmticketcita(ctd.CitaDetalle, ctd.Cita.Fecha, ctd.Cita.Id);
                frmTicketCita.ShowDialog();
                reloadForm();
            }
            else
            {
                MessageBox.Show("Ocurrio un error creando la cita, comuniquese con el administrador del sistema.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }