コード例 #1
0
        private async void loanBtn_Click(object sender, EventArgs e)
        {
            FormPrestamo formPrestamo = new FormPrestamo();

            //DarkForm darkForm = new DarkForm();
            // darkForm.Show();
            if (formPrestamo.ShowDialog() == DialogResult.OK && formPrestamo.loan > 0.0)
            {
                double  loan    = formPrestamo.loan;
                Cliente cliente = new Cliente(this.employee.CustomerID);
                Venta   venta   = new Venta();
                double  Payment = 0.0;
                double  num1    = loan;
                await Task.Run(() => venta.newSale(this.User_employeeID, cliente.ID, loan, Payment, null, num1));

                FormCambio formCambio = new FormCambio(num1);

                openDrawer();
                formCambio.ShowDialog();
                this.debtLbl.Text = "$" + (cliente.Debt + loan).ToString("n2");
            }
            // darkForm.Close();
        }
コード例 #2
0
        private void Paybtn_Click(object sender, EventArgs e)
        {
            FormCambio formCambio = new FormCambio(this.employee.salary);
            //DarkForm darkForm = new DarkForm();
            Form_Login formLogin = new Form_Login(string.Format("Verificación De\nUsuario"));

            //darkForm.Show();
            formLogin.ShowDialog();
            Empleado empleado = new Empleado(formLogin.ID);

            if (formLogin.DialogResult == DialogResult.OK)
            {
                if (empleado.isAdmin)
                {
                    /*try
                     * {
                     *  this.printDocument1.PrinterSettings.PrinterName = this.printDialog1.PrinterSettings.PrinterName;
                     *  this.printDialog1.Document = this.printDocument1;
                     *  this.printDocument1.Print();
                     * }
                     * catch (InvalidPrinterException)
                     * {
                     *  int num2 = (int)MessageBox.Show("Registre una impresora para poder utilizar esta opción", "No se ha registrado impresora");
                     * }*/

                    openDrawer();
                    this.employee.paySalary();
                    formCambio.ShowDialog();
                    // goto label_7;
                }
            }
            if (formLogin.DialogResult == DialogResult.OK && !empleado.isAdmin)
            {
                MessageBox.Show("No dispone de los permisos necesarios para realizar el pago");
            }
        }
コード例 #3
0
        private async void paymentDebtBtn_Click(object sender, EventArgs e)
        {
            paymentDebtBtn.Enabled = false;
            Cliente customer = await Task.Run(() => new Cliente(this.employee.CustomerID));

            if (customer.Debt <= 0.0)
            {
                return;
            }
            FormPagar form = new FormPagar("$" + customer.Debt.ToString("n2"), false, 0.0);

            //DarkForm darkForm = new DarkForm();
            //darkForm.Show();
            if (form.ShowDialog() == DialogResult.OK)
            {
                double customerPayment = Convert.ToDouble(form.Pay);
                double cash            = Convert.ToDouble(form.Cash);
                if (customerPayment > 0.0)
                {
                    DataTable acountsReceivable = customer.GetAcountsReceivable();
                    double    change            = cash <= customerPayment ? 0.0 : cash - customerPayment;
                    for (int index = 0; index < acountsReceivable.Rows.Count; ++index)
                    {
                        DataRow row = acountsReceivable.Rows[index];
                        if (customerPayment > 0.0)
                        {
                            double cash1 = customerPayment - Convert.ToDouble(row["Resto"]) <= 0.0 ? customerPayment : Convert.ToDouble(row["Resto"]);
                            customer.RegisterPayment(Convert.ToInt64(row["id_ventas"]), DateTime.Now, cash1, this.User_employeeID);
                            customer.Pay(cash1, Convert.ToInt64(row["id_ventas"]));
                            customerPayment -= cash1;
                        }
                    }
                    FormCambio formCambio = new FormCambio(change);
                    this.customerPaymentDocument            = new PrintDocument();
                    customerPaymentDocument.PrintController = new StandardPrintController();

                    this.customerPaymentDocument.PrintPage += (PrintPageEventHandler)((ss, ee) =>
                    {
                        Graphics graphics = ee.Graphics;
                        var ticket = new PrinterTicket();
                        this.customerPaymentDocument.PrinterSettings.PrinterName = ticket.printerName;
                        this.customerPaymentDocument.DefaultPageSettings.PaperSize = new PaperSize("Custom", 200, 200);
                        int width = (int)this.printDialog1.PrinterSettings.DefaultPageSettings.PrintableArea.Width;

                        int y1 = 0;
                        Size stringSize = ticket.printLogo(graphics, y1);
                        y1 = stringSize.Height == 0 ? y1 : y1 + stringSize.Height + 10;

                        stringSize = ticket.printHeader(graphics, y1);
                        y1 = stringSize.Height == 0 ? y1 : y1 + stringSize.Height + 10;

                        stringSize = ticket.printAddress(graphics, y1);
                        y1 = stringSize.Height == 0 ? y1 : y1 + stringSize.Height + 10;

                        stringSize = ticket.printPhone(graphics, y1);
                        y1 = stringSize.Height == 0 ? y1 : y1 + stringSize.Height + 10;

                        y1 += printingClass.drawLine(10, width - 10, graphics, y1) + 5;

                        string str = "Pago de Cliente";
                        Font font = new Font("times new roman", 17f, FontStyle.Bold);//this.getFont(str1, width, FontStyle.Regular);
                        y1 += printingClass.printLine(str, font, width, StringAlignment.Center, ee.Graphics, y1) + 1;

                        font = width > 200 ? new Font("Times new Roman", 9.9f) : new Font("Times new Roman", 7f);

                        if (customer.ID != 0)
                        {
                            str = "Cliente: " + customer.Name;
                            y1 += printingClass.printLine(str, font, width, StringAlignment.Near, ee.Graphics, y1) + 1;
                        }

                        str = string.Format("Fecha: {0} {1}", DateTime.Now.Date.ToShortDateString(), DateTime.Now.ToShortTimeString());
                        y1 += printingClass.printLine(str, font, width, StringAlignment.Near, graphics, y1);


                        y1 += printingClass.drawLine(10, width - 10, graphics, y1) + 3;

                        customerPayment = Convert.ToDouble(form.Pay);
                        str = string.Format("Adeudo Previo: ${0}", (customer.Debt + customerPayment).ToString("n2"));
                        y1 += printingClass.printLine(str, font, width, StringAlignment.Near, graphics, y1) + 1;

                        str = string.Format("Monto a pagar: ${0}", customerPayment.ToString("n2"));
                        y1 += printingClass.printLine(str, font, width, StringAlignment.Near, graphics, y1) + 1;

                        str = string.Format("Adeudo Actualizado: ${0}", customer.Debt.ToString("n2"));
                        y1 += printingClass.printLine(str, new Font("times new roman", 10f, FontStyle.Bold), width, StringAlignment.Near, graphics, y1);

                        y1 += printingClass.drawLine(10, width - 10, graphics, y1) + 3;

                        str = string.Format("Efectivo: ${0}", cash.ToString("n2"));
                        y1 += printingClass.printLine(str, font, width, StringAlignment.Far, graphics, y1) + 1;

                        str = string.Format("Cambio: ${0}", change.ToString("n2"));
                        y1 += printingClass.printLine(str, font, width, StringAlignment.Far, graphics, y1) + 1;

                        if (ticket.footerDisplay)
                        {
                            printingClass.printLine(ticket.footer, ticket.footerFont, width, StringAlignment.Center, graphics, y1);
                        }
                    });
                    try
                    {
                        this.customerPaymentDocument.PrinterSettings.PrinterName = this.printDialog1.PrinterSettings.PrinterName;
                        this.printDialog1.Document = this.customerPaymentDocument;
                        this.customerPaymentDocument.Print();
                    }
                    catch (InvalidPrinterException ex)
                    {
                        int num = (int)MessageBox.Show("Registre una impresora para poder utilizar esta opción", "No se ha registrado impresora");
                    }
                    int num10 = (int)formCambio.ShowDialog();
                    customer.RefreshInfo();
                    this.debtLbl.Text = "$" + customer.Debt.ToString("n2");
                }
                else
                {
                    int num11 = (int)MessageBox.Show("El Cliente no genera ningun adeudo");
                }
            }
            paymentDebtBtn.Enabled = true;
            //darkForm.Close();
        }