Esempio n. 1
0
        private void LoadData()
        {
            this.cmbPrinter.Items.Add("Seleccione...");

            foreach (var printer in PrinterSettings.InstalledPrinters)
            {
                this.cmbPrinter.Items.Add(printer);
            }

            this.cmbPrinter.SelectedIndex = 0;

            using (var e = new posb.Config())
            {
                this.txtAlta.Text               = String.Format("{0:0.00}", e.Alta());
                this.txtAltaNegocio.Text        = String.Format("{0:0.00}", e.AltaNegocio());
                this.txtMensualidad.Text        = String.Format("{0:0.00}", e.Mensualidad());
                this.txtMensualidadNegocio.Text = String.Format("{0:0.00}", e.MensualidadNegocio());
                this.cmbPrinter.Text            = e.Printer();
                this.txtPresidente.Text         = e.Presidente();
                this.txtTesorero.Text           = e.Tesorero();
                this.txtAltaH.Text              = String.Format("{0:0.00}", e.AltaH());
                this.cbAddNames.Checked         = e.AltaAddNames();
                this.nudTomas.Value             = e.WaterIntakeHabitants();

                var picture1 = e.GetImage("Voucher", 1);

                if (picture1 != null)
                {
                    this.pbPhoto.Image = System.Drawing.Image.FromStream(new MemoryStream(picture1));
                    this.pbPhoto.Refresh();
                }

                var picture2 = e.GetImage("Voucher", 2);

                if (picture1 != null)
                {
                    this.pbPhoto2.Image = System.Drawing.Image.FromStream(new MemoryStream(picture2));
                    this.pbPhoto2.Refresh();
                }
            }
        }
Esempio n. 2
0
        private void Save()
        {
            if (this.ValidateForm())
            {
                using (var e = new posb.Config())
                {
                    e.Alta(this.txtAlta.Text);
                    e.AltaNegocio(this.txtAltaNegocio.Text);
                    e.Mensualidad(this.txtMensualidad.Text);
                    e.MensualidadNegocio(this.txtMensualidadNegocio.Text);
                    e.Printer(this.cmbPrinter.Text);
                    e.Presidente(this.txtPresidente.Text);
                    e.Tesorero(this.txtTesorero.Text);
                    e.AltaH(this.txtAltaH.Text);
                    e.AltaAddNames(this.cbAddNames.Checked);
                    e.WaterIntakeHabitants(this.nudTomas.Value.ToString());
                }

                this.Close();
            }
        }
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;
        }