コード例 #1
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (this.ValidateForm())
            {
                using (posb.Config con = new posb.Config())
                {
                    var path = Path.GetDirectoryName(this.txtPath.Text);

                    if (Directory.Exists(path))
                    {
                        if (!con.BackUp(this.txtPath.Text))
                        {
                            this.Alert(con.ErrorMessage);
                        }
                        else
                        {
                            if (this.Confirm("El respaldo se creo correctamente, ¿Deseas abrir la carpeta?"))
                            {
                                Process.Start(path);
                            }

                            this.Close();
                        }
                    }
                    else
                    {
                        this.Alert("La carpeta no existe");
                        this.txtPath.Clear();
                        this.txtPath.Focus();
                    }
                }
            }
        }
コード例 #2
0
        private void LoadData(int?Id)
        {
            using (var e = new posb.Expense
            {
                Id = this.Id
            })
            {
                e.Get();

                this.txtName.Text          = e.Name;
                this.txtDescription.Text   = e.Description;
                this.txtAmount.Text        = String.Format("{0:0.00}", e.Amount);
                this.cmbType.SelectedIndex = e.Type.Value + 1;
            }

            using (var e = new posb.Config())
            {
                var picture1 = e.GetImage("InputOutput", this.Id.Value);

                if (picture1 != null)
                {
                    this.pbPhoto.Image = System.Drawing.Image.FromStream(new MemoryStream(picture1));
                    this.pbPhoto.Refresh();
                }
            }
        }
コード例 #3
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (this.ValidateForm())
            {
                if (this.Confirm("¿Realmente deseas restaurar la base de datos SICAP?, Se sugiere realizar un respaldo antes de continuar"))
                {
                    using (posb.Config con = new posb.Config())
                    {
                        var path = Path.GetDirectoryName(this.txtPath.Text);

                        if (Directory.Exists(path))
                        {
                            if (!con.Restore(this.txtPath.Text, true))
                            {
                                this.Alert(con.ErrorMessage);

                                Application.Exit();
                            }
                            else
                            {
                                this.Alert("Se restauro correctamente la base de datos. Debe reiniciar SICAP para aplicar los cambios");
                                Application.Exit();
                            }
                        }
                        else
                        {
                            this.Alert("La carpeta no existe");
                            this.txtPath.Clear();
                            this.txtPath.Focus();
                        }
                    }
                }
            }
        }
コード例 #4
0
 private void SetCostPerMonth()
 {
     using (var e = new posb.Config())
     {
         this.txtAmount.Text = String.Format("{0:0.00}", e.Mensualidad());
     }
 }
コード例 #5
0
        private void Save()
        {
            using (posb.Config con = new posb.Config())
            {
                con.Save(this.txtServer.Text, int.Parse(this.txtPort.Text), this.txtDataBase.Text, this.txtUser.Text, this.txtPassword.Text);
            }

            this.Alert("La configuración se guardo correctamente. SICAP se reiniciara.");

            Application.Restart();
        }
コード例 #6
0
 private void SetCostAlta()
 {
     try
     {
         using (var e = new posb.Config())
         {
             this.txtTotal.Text = String.Format("{0:0.00}", e.AltaH());
         }
     }
     catch (Exception ex)
     {
     }
 }
コード例 #7
0
 private bool TestConnection(out string ErrorMessage, out int ErrorNumber)
 {
     using (var config = new PosBusiness.Config())
     {
         return(config.CheckConnection(out ErrorMessage,
                                       out ErrorNumber,
                                       this.txtServer.Text,
                                       this.txtUser.Text,
                                       this.txtPassword.Text,
                                       int.Parse(this.txtPort.Text),
                                       this.txtDataBase.Text));
     }
 }
コード例 #8
0
        private void Config_Load(object sender, EventArgs e)
        {
            this.ConfigureDialogs();

            using (var c = new posb.Config())
            {
                var picture1 = c.GetImage(this.EntityName, this.Id.Value);

                if (picture1 != null)
                {
                    this.pbPhoto.Image = System.Drawing.Image.FromStream(new MemoryStream(picture1));
                    this.pbPhoto.Refresh();
                }
            }
        }
コード例 #9
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            using (var config = new posb.Config())
            {
                var total = config.WaterIntakeHabitants();

                if (total > this.Total)
                {
                    this.OpenEdit();
                }
                else
                {
                    this.Alert("El numero máximo de tomas de agua por habitante son " + total + ".");
                }
            }
        }
コード例 #10
0
        private void Save()
        {
            if (pbPhoto.Image != null)
            {
                using (posb.Config con = new posb.Config())
                {
                    con.SaveImage(this.EntityName, this.Id.Value, this.ImageToByte(pbPhoto.Image));
                }

                this.Result(true, "", pbPhoto.Image);

                this.Close();
            }
            else
            {
                this.Alert("Seleccione una imagen");
            }
        }
コード例 #11
0
        private void LoadData()
        {
            using (posb.Config con = new posb.Config())
            {
                string Server   = string.Empty;
                int    Port     = 0;
                string DataBase = string.Empty;
                string User     = string.Empty;
                string Password = string.Empty;

                con.GetConnectionParameters(out Server, out Port, out DataBase, out User, out Password);

                this.txtServer.Text   = Server;
                this.txtPort.Text     = Port.ToString();
                this.txtDataBase.Text = DataBase;
                this.txtUser.Text     = User;
                this.txtPassword.Text = Password;
            }
        }
コード例 #12
0
 private void SetCostAlta()
 {
     try
     {
         using (var e = new posb.Config())
         {
             if (this.cmbType.SelectedIndex.Equals(0))
             {
                 this.txtTotal.Text = String.Format("{0:0.00}", e.Alta());
             }
             else
             {
                 this.txtTotal.Text = String.Format("{0:0.00}", e.AltaNegocio());
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
コード例 #13
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();
                }
            }
        }
コード例 #14
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();
            }
        }
コード例 #15
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;
        }