Esempio n. 1
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.txtAP.Text))
            {
                var p = new posb.Payment
                {
                    Id = int.Parse(this.txtAP.Text)
                };

                p.FindByAP();

                if (p.IdWaterIntake.HasValue && p.IdHabitantOrRent.HasValue)
                {
                    this.ChangeHabitant = false;

                    this.idWaterIntake             = p.IdWaterIntake;
                    this.cmbHabitant.SelectedValue = p.IdHabitantOrRent;
                    this.FillWaterIntake(p.IdHabitantOrRent.Value);

                    this.ChangeHabitant = true;
                }
                else
                {
                    this.Alert("No se encontraron datos para el AP: " + this.txtAP.Text);
                }
            }
            else
            {
                this.Alert("Introduzca un AP para realizar la búsqueda");
            }
        }
Esempio n. 2
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (this.ValidateForm())
            {
                if (this.Confirm("¿Realmente desea realizar el cobro por el monto de " + this.txtTotal.Text + " ?"))
                {
                    using (var payment = new posb.Payment
                    {
                        IdHabitantOrRent = this.cmbHabitant.GetVal <int>(),
                        IdWaterIntake = this.cmbWaterIntake.GetVal <int>(),
                        Year = int.Parse(this.cmbYear.Text),
                        Month = this.cmbMonth.SelectedIndex,
                        YearEnd = int.Parse(this.cmbYearEnd.Text),
                        MonthEnd = this.cmbMonthEnd.SelectedIndex,
                        Amount = decimal.Parse(this.txtTotal.Text),
                        Observations = this.txtObservations.Text
                    })
                    {
                        if (!payment.Exist())
                        {
                            payment.Save();

                            if (this.Confirm("¿Deseas imprimir el recibo?"))
                            {
                                this.Print(payment.Id.Value);
                            }

                            this.Result(true, "Success!!");

                            this.Close();
                        }
                        else
                        {
                            this.Alert("Ya se realizo el pago de la toma de agua en el periodo indicado");
                            this.cmbMonth.Focus();
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        protected void PrintWaterIntake(int Id)
        {
            var months = new List <string>
            {
                "ENERO",
                "FEBRERO",
                "MARZO",
                "ABRIL",
                "MAYO",
                "JUNIO",
                "JULIO",
                "AGOSTO",
                "SEPTIEMBRE",
                "OCTUBRE",
                "NOVIEMBRE",
                "DICIEMBRE"
            };

            var p = new PrintDocument();

            p.PrintPage += delegate(object sender1, PrintPageEventArgs e1)
            {
                var line = string.Empty;
                for (int i = 0; i < 81; i++)
                {
                    line += "_";
                }

                var line2 = string.Empty;
                for (int i = 0; i < 125; i++)
                {
                    line2 += " - ";
                }

                var font     = "Times New Roman";
                var brush    = new SolidBrush(Color.Black);
                var brushTwo = new SolidBrush(Color.LightGray);

                var brushRed = new SolidBrush(Color.Red);

                Font titleFont    = new Font(font, 18, FontStyle.Bold),
                     titleSubFont = new Font(font, 16, FontStyle.Bold),
                     f14          = new Font(font, 14, FontStyle.Bold),
                     f11          = new Font(font, 11),
                     f10          = new Font(font, 10),
                     f09          = new Font(font, 09),
                     f08          = new Font(font, 08),
                     f06          = new Font(font, 06);

                var pen = new Pen(Brushes.Black);
                pen.Width = 0.8F;

                var picture1 = new posb.Config().GetImage("Voucher", 1);
                var picture2 = new posb.Config().GetImage("Voucher", 2);
                var picture3 = new posb.Config().GetImage("Voucher", 3);
                var imageCom = new Bitmap(new MemoryStream(picture1));
                var image    = new Bitmap(new MemoryStream(picture2));
                var sicap    = new Bitmap(new MemoryStream(picture3));

                using (posb.Payment payment = new posb.Payment
                {
                    Id = Id
                }
                       .WaterIntakePrint())
                {
                    var total = new Numalet().Convert(String.Format("{0:0.00}", payment.Amount));

                    for (int i = 0; i <= 1; i++)
                    {
                        var copy = i * 530;

                        e1.Graphics.DrawImage(imageCom, 20, 7 + copy, 90, 110);

                        e1.Graphics.DrawString("COMITÉ DE AGUA POTABLE", titleFont, brush, 240, 40 + copy);
                        e1.Graphics.DrawString("SAN DIEGO TLAILOTLACAN", titleFont, brush, 240, 65 + copy);
                        e1.Graphics.DrawImage(image, 760, 37 + copy, 60, 80);

                        e1.Graphics.FillRectangle(brush, new Rectangle(20, 106 + copy, 795, 6));
                        e1.Graphics.DrawRectangle(pen, new Rectangle(20, 112 + copy, 795, 30));
                        e1.Graphics.DrawString("RECIBO OFICIAL DE INGRESOS", titleSubFont, brush, 30, 115 + copy);

                        e1.Graphics.DrawString("FOLIO", titleSubFont, brush, 550, 115 + copy);
                        e1.Graphics.DrawString("N° T-" + payment.Folio.PadLeft(10, '0'), titleSubFont, brushRed, 630, 115 + copy);

                        e1.Graphics.DrawRectangle(pen, new Rectangle(20, 158 + copy, 795, 127));
                        e1.Graphics.DrawRectangle(pen, new Rectangle(20, 158 + copy, 222, 127));

                        e1.Graphics.DrawString("RECIBI DEL(A) SR(A)", f14, brush, 30, 170 + copy);
                        e1.Graphics.DrawString(payment.Propietario, f14, brush, 250, 170 + copy);
                        e1.Graphics.DrawString(line, f14, brush, 17, 170 + copy);

                        e1.Graphics.DrawString("CANTIDAD", f14, brush, 30, 200 + copy);
                        e1.Graphics.DrawString("$" + String.Format("{0:0.00}", payment.Amount) + "   " + total, f14, brush, 250, 200 + copy);
                        e1.Graphics.DrawString(line, f14, brush, 17, 200 + copy);

                        e1.Graphics.DrawString("CONCEPTO", f14, brush, 30, 230 + copy);
                        e1.Graphics.DrawString("Pago por alta de toma de agua", f14, brush, 250, 230 + copy);
                        e1.Graphics.DrawString(line, f14, brush, 17, 230 + copy);

                        e1.Graphics.DrawString("DIRECCIÓN", f14, brush, 30, 260 + copy);
                        e1.Graphics.DrawString(payment.Direccion + "  [" + payment.Type + "]", f14, brush, 250, 260 + copy);

                        e1.Graphics.FillRectangle(brushTwo, new Rectangle(20, 299 + copy, 795, 27));
                        e1.Graphics.DrawRectangle(pen, new Rectangle(20, 299 + copy, 795, 27));

                        e1.Graphics.DrawString("DESCRIPCIÓN DEL PAGO", titleSubFont, brush, 280, 300 + copy);
                        e1.Graphics.DrawString("Pago por alta de toma de agua ubicada en:" + payment.Direccion, f10, brush, 25, 332 + copy);

                        e1.Graphics.DrawRectangle(pen, new Rectangle(20, 326 + copy, 795, 27));

                        e1.Graphics.DrawString("SAN DIEGO TEXCOCO ESTADO DE MEXICO A " + payment.CreationDate.Value.ToString("dd") + " DE " + months[int.Parse(payment.CreationDate.Value.ToString("MM")) - 1] + " DE " + payment.CreationDate.Value.ToString("yyyy"), f10, brush, 340, 360 + copy);

                        using (var addNames = new posb.Config())
                        {
                            var showNames = addNames.AltaAddNames();

                            if (showNames)
                            {
                                e1.Graphics.DrawString("_________________________________", f09, brush, 100, 430 + copy);
                                e1.Graphics.DrawString("TESORERO(A): " + payment.Tesorero, f08, brush, 100, 450 + copy);
                                //e1.Graphics.DrawString("", f08, brush, 163, 470 + copy);

                                e1.Graphics.DrawString("_________________________________", f09, brush, 500, 430 + copy);
                                e1.Graphics.DrawString("PRESIDENTE(A): " + payment.Presidente, f08, brush, 500, 450 + copy);
                                //e1.Graphics.DrawString("VO.BO.  DE COMITE", f08, brush, 520, 470 + copy);
                            }
                            else
                            {
                                e1.Graphics.DrawString("_________________________________", f09, brush, 100, 430 + copy);
                                e1.Graphics.DrawString("TESORERO(A)", f08, brush, 170, 450 + copy);
                                //e1.Graphics.DrawString("", f08, brush, 163, 470 + copy);

                                e1.Graphics.DrawString("_________________________________", f09, brush, 500, 430 + copy);
                                e1.Graphics.DrawString("PRESIDENTE(A)", f08, brush, 565, 450 + copy);
                                //e1.Graphics.DrawString("VO.BO.  DE COMITE", f08, brush, 520, 470 + copy);
                            }
                        }

                        e1.Graphics.DrawImage(sicap, 403, 430 + copy, 40, 50);

                        e1.Graphics.DrawString("SICAP V1.0.0", f06, brush, 397, 480 + copy);

                        e1.Graphics.DrawString("Impresión " + (i + 1) + " - " + DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt"), f08, brush, 610, 495 + copy);

                        if (i.Equals(0))
                        {
                            e1.Graphics.DrawString(line2, f06, brush, 0, 525 + copy);
                        }
                    }
                }

                pen.Dispose();
            };

            try
            {
                using (var printer = new posb.Config())
                {
                    p.PrinterSettings.PrinterName = printer.Printer();
                }

                p.Print();
            }
            catch (Exception ex)
            {
                this.Alert("Ocurrió un error al intentar imprimir el ticket. Descripcion: " + ex.Message, eForm.TypeError.Error);
            }

            return;
        }