Пример #1
0
 private void CargarTabla()
 {
     using (var context = new PARKING_DBEntities(CadenaConexion))
     {
         var listabusqueda = (from pc in context.proveedorescorreo
                              select new Modelos.ModeloServidoresSMTP
         {
             ID = pc.ID_ProveedoresCorreo,
             Dominio = pc.Dominio,
             Puerto = pc.Puerto,
             ServidorSMTP = pc.Servidor_SMTP,
         }).AsQueryable();
         dtServidores.DataSource = listabusqueda.ToList();
         if (dtServidores.Rows.Count > 0)
         {
             dtServidores.Rows[0].Selected = true;
         }
         int?id = GetID();
         if (id != null)
         {
             var datos = context.proveedorescorreo.Where(n => n.ID_ProveedoresCorreo == id).FirstOrDefault();
             lblID.Text           = datos.ID_ProveedoresCorreo.ToString();
             txtServidorSMTP.Text = datos.Servidor_SMTP;
             txtPuerto.Text       = datos.Puerto.ToString();
         }
     }
 }
Пример #2
0
        private void CargarHistorialCortes()
        {
            using (var context = new PARKING_DBEntities(CadenaConexion))
            {
                CantidadCortes = (from cs in context.cortes select cs.Id_Corte).Count();
                var listabusqueda = (from bp in context.cortes
                                     select new Modelos.ModeloCorteHistorial
                {
                    ID = bp.Id_Corte,
                    CorteNormal = bp.CorteNormal.ToString(),
                    CortePension = bp.CortePension.ToString(),
                    CorteTarifa2 = bp.CorteTarifa2.ToString(),
                    FechaCorte = bp.FechaCorte.ToString(),
                    ImporteCortes = bp.Importe_Cortes.ToString(),
                    ImporteParqueo = bp.Importe_Parqueo.ToString(),
                    ImporteReportado = bp.Importe_Reportado.ToString(),
                    Usuario = bp.Usuario
                }).ToList();
                dtHistorialCorte.DataSource = listabusqueda;
                DataGridViewCheckBoxColumn btnCheck = new DataGridViewCheckBoxColumn();
                btnCheck.HeaderText = "";
                btnCheck.Name       = "Reporte";
                btnCheck.FalseValue = false;
                btnCheck.TrueValue  = true;

                if (dtHistorialCorte.Columns["Reporte"] == null)
                {
                    dtHistorialCorte.Columns.Insert(0, btnCheck);
                }

                dmCorteResumido.Maximum = context.cortes.Max(x => x.Id_Corte);
            }
            dmCortes.Maximum = CantidadCortes;
            dmCortes.Value   = CantidadCortes;
        }
Пример #3
0
 private bool ValidarCampos()
 {
     if (string.IsNullOrEmpty(txtUsuario.Text) || string.IsNullOrEmpty(txtContra1.Text) || string.IsNullOrEmpty(txtContra2.Text) || string.IsNullOrEmpty(txtNombre.Text) || string.IsNullOrEmpty(txtTelefono.Text) || string.IsNullOrEmpty(txtPuesto.Text) || string.IsNullOrEmpty(txtCorreo.Text))
     {
         MessageBox.Show("Faltan campos por llenar"); return(false);
     }
     else
     {
         if (txtContra1.Text != txtContra2.Text)
         {
             MessageBox.Show("Las contraseñas no coinciden"); return(false);
         }
         else
         {
             using (var context = new PARKING_DBEntities(CadenaConexion))
             {
                 var us = txtUsuario.Text.Trim();
                 var a  = context.usuario.Where(n => n.Usuario1 == us).Count();
                 if (a > 0)
                 {
                     MessageBox.Show("El usuario ya existe seleccione otro nombre"); return(false);
                 }
                 else
                 {
                     return(true);
                 }
             }
         }
     }
 }
Пример #4
0
        private int InsertarCliente(int idVehiculo)
        {
            int IDCliente = 0;

            using (var context = new PARKING_DBEntities(CadenaConexion))
            {
                var a = new cliente()
                {
                    Nombre           = txtNombre.Text.Trim(),
                    Apellido_paterno = txtApellidoP.Text.Trim(),
                    Apellido_materno = txtApellidoM.Text.Trim(),
                    Tel1             = txtTel1.Text.Trim(),
                    Tel2             = txtTel2.Text.Trim(),
                    Direccion        = txtDireccion.Text.Trim(),
                    Correo           = txtCorreo.Text.Trim(),
                    Razon_Social     = txtRazonSocial.Text.Trim(),
                    RFC         = txtRFC.Text.Trim(),
                    Id_Vehiculo = idVehiculo,
                };
                context.cliente.Add(a);
                context.SaveChanges();
                IDCliente = a.Id_cliente;
            }

            return(IDCliente);
        }
Пример #5
0
        private void CargarVehiculo(int id_cliente)
        {
            int IDVehiculo = 0;

            using (var context = new PARKING_DBEntities(CadenaConexion))
            {
                var tVehiculo = (from cl in context.cliente
                                 join vh in context.vehiculo on cl.Id_Vehiculo equals vh.Id_Vehiculo
                                 where cl.Id_cliente == id_cliente
                                 select new Modelos.ModeloCargarVehiculo
                {
                    ID = vh.Id_Vehiculo,
                    Placa = vh.Placa,
                    Marca = vh.Marca,
                    Color = vh.Color,
                    Descripcion = vh.Descripcion
                }).ToList();
                foreach (var item in tVehiculo)
                {
                    IDVehiculo    = item.ID;
                    txtMarca.Text = item.Marca;
                    txtDesc.Text  = item.Descripcion;
                    txtColor.Text = item.Color;
                    txtPlaca.Text = item.Placa;
                }
                this.ID_Vehiculo = IDVehiculo;
            }
        }
Пример #6
0
        private void CargarTicket()
        {
            lista.Clear();
            using (var context = new PARKING_DBEntities(CadenaConexion))
            {
                ancho = (from cf in context.config_tickets
                         where cf.ID_ticket == 1
                         select cf.Tamaño_papel).FirstOrDefault();
                Console.WriteLine(ancho);

                var a = (from bp in context.banco_pension
                         join cl in context.cliente on bp.Id_cliente equals cl.Id_cliente
                         join vh in context.vehiculo on cl.Id_Vehiculo equals vh.Id_Vehiculo
                         where bp.ID == UltimoID
                         select new Modelos.ModeloTicketActivadoYPagado
                {
                    ID = bp.ID.ToString(),
                    Color = vh.Color,
                    Direccion = cl.Direccion,
                    Importe = bp.Costo.ToString(),
                    Marca = vh.Marca,
                    Placa = vh.Placa,
                    Nombre = cl.Nombre + " " + cl.Apellido_paterno + " " + cl.Apellido_materno,
                    Telefono = cl.Tel1,
                    ultimaFecha = bp.Fin_Pension
                }).ToList();
                lista = a;
            }
        }
Пример #7
0
 private void btnMostrarHistorialCortes_Click(object sender, EventArgs e)
 {
     dtHistorialCorte.DataSource = null;
     using (var context = new PARKING_DBEntities(CadenaConexion))
     {
         CantidadCortes = (from cs in context.cortes select cs.Id_Corte).Count();
         var can           = Convert.ToInt32(dmCortes.Value);
         var listabusqueda = (from bp in context.cortes
                              orderby bp.Id_Corte descending
                              select new Modelos.ModeloCorteHistorial
         {
             ID = bp.Id_Corte,
             CorteNormal = bp.CorteNormal.ToString(),
             CortePension = bp.CortePension.ToString(),
             CorteTarifa2 = bp.CorteTarifa2.ToString(),
             FechaCorte = bp.FechaCorte.ToString(),
             ImporteCortes = bp.Importe_Cortes.ToString(),
             ImporteParqueo = bp.Importe_Parqueo.ToString(),
             ImporteReportado = bp.Importe_Reportado.ToString(),
             Usuario = bp.Usuario
         }).Take(can).ToList();
         dtHistorialCorte.DataSource = listabusqueda;
         DataGridViewCheckBoxColumn btnCheck = new DataGridViewCheckBoxColumn();
         btnCheck.HeaderText = "";
         btnCheck.Name       = "Reporte";
         btnCheck.FalseValue = false;
         btnCheck.TrueValue  = true;
         if (dtHistorialCorte.Columns["Reporte"] == null)
         {
             dtHistorialCorte.Columns.Insert(0, btnCheck);
         }
     }
 }
Пример #8
0
 private void ckPagado_CheckedChanged(object sender, EventArgs e)
 {
     if (scPeriodo.SelectedIndex == 0)
     {
         lblCosto.Text      = "Seleccione un Periodo";
         lblCosto.ForeColor = Color.Red;
         ckPagado.Checked   = false;
     }
     if (ckPagado.Checked == true)
     {
         label14.Visible = true; txtCantidadAnticipados.Visible = true; txtCantidadAnticipados.Text = "1";
         if (scPeriodo.SelectedIndex != 0)
         {
             using (var context = new PARKING_DBEntities(CadenaConexion))
             {
                 var item = context.pensiones.ToList();
                 foreach (var valores in item.Where(n => n.ID_Tipo_Pension == ID_Plan))
                 {
                     PrecioNeto         = valores.Pens_Costo_Regular.GetValueOrDefault();
                     lblCosto.ForeColor = Color.Black;
                     lblCosto.Text      = ((PrecioNeto * 1) > 0) ? (PrecioNeto * 1).ToString("F", CultureInfo.InvariantCulture) : "Seleccione un Periodo";
                 }
                 ;
             }
         }
     }
     else
     {
         label14.Visible = false; txtCantidadAnticipados.Visible = false; txtCantidadAnticipados.Text = "1"; lblCosto.Text = null;
     }
 }
Пример #9
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidarCheck() == true && ValidarCampos() == true)
                {
                    using (var context = new PARKING_DBEntities(CadenaConexion))
                    {
                        var a = context.usuario.SingleOrDefault(n => n.ID_Usuario == IDUsuario);
                        if (a != null)
                        {
                            a.Privilegios      = scPrioridad.Text;
                            a.Usuario1         = txtUsuario.Text.Trim();
                            a.Password         = txtContra1.Text;
                            a.Nombre           = txtNombre.Text;
                            a.Telefono         = txtTelefono.Text;
                            a.ID_AreaPersonal  = IDAreaPersonal;
                            a.Puesto           = txtPuesto.Text.Trim();
                            a.mail_Correo      = txtCorreo.Text;
                            a.mail_Password    = (ckCorreo.Checked == true) ? txtContraseñaServidor.Text : null;
                            a.CorreoConfirmado = false;
                            if (ckCorreo.Checked == true)
                            {
                                a.ID_ProveedoresCorreo = IDServidor;
                            }
                            else
                            {
                                a.ID_ProveedoresCorreo = null;
                            }
                            context.SaveChanges();
                            MessageBox.Show("Actualizacion Correcta");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string path     = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                string filePath = path + @"\Error.txt";
                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine("-----------------------------------------------------------------------------");
                    writer.WriteLine("Date : " + DateTime.Now.ToString());
                    writer.WriteLine();

                    while (ex != null)
                    {
                        writer.WriteLine(ex.GetType().FullName);
                        writer.WriteLine("Message : " + ex.Message);
                        writer.WriteLine("StackTrace : " + ex.StackTrace);

                        ex = ex.InnerException;
                    }
                }
                MessageBox.Show(mensajeError);
            }
        }
 private void CargarBotones()
 {
     using (var context = new PARKING_DBEntities(CadenaConexion))
     {
         var usuario = (from us in context.usuario where (us.Usuario1 == Usuario) select us.Privilegios).FirstOrDefault();
         if (usuario != "Administrador")
         {
             this.Size = new Size(341, 248);
         }
     }
 }
Пример #11
0
 public void Cargar()
 {
     using (var context = new PARKING_DBEntities(CadenaConexion))
     {
         var a = context.serviciosadicionales.SingleOrDefault(n => n.ID_ServicioAd == ID);
         txtNombreServicio.Text = a.ServicioAdicional;
         txtImporte.Text        = a.Precio_ServiciosAd.ToString();
         dmTiempo.Value         = Convert.ToDecimal(a.Tiempo_Gracia);
         ckEstado.Checked       = a.ServicioAd_Activo.GetValueOrDefault();
     }
 }
        public async Task <int> Validar()
        {
            string nom  = UsuarioText.Text.Trim();
            string pass = ContraseniaText.Text.Trim();

            using (var context = new PARKING_DBEntities(CadenaConexion))
            {
                var a       = (from us in context.usuario where us.Usuario1 == nom && us.Password == pass select us.ID_Usuario).Count();
                var retorno = (a > 0) ? 1 : 0;
                return(retorno);
            }
        }
        private void CargarDatos()
        {
            using (var context = new PARKING_DBEntities(CadenaConexion))
            {
                var a = context.banco_pension.Where(n => n.ID == ID_Pension).FirstOrDefault();
                var b = context.cliente.Where(n => n.Id_cliente == a.Id_cliente).FirstOrDefault();
                var c = context.vehiculo.Where(n => n.Id_Vehiculo == b.Id_Vehiculo).FirstOrDefault();
                var d = context.pensiones.Where(n => n.ID_Tipo_Pension == a.ID_Tipo_Pension).FirstOrDefault();

                ID_Vehiculo = c.Id_Vehiculo;
                ID_Cliente  = b.Id_cliente;

                txtNombre.Text    = b.Nombre;
                txtApellidoP.Text = b.Apellido_paterno;
                txtApellidoM.Text = b.Apellido_materno;
                txtDireccion.Text = b.Direccion;
                txtCorreo.Text    = b.Correo;
                txtTel1.Text      = b.Tel1;
                txtTel2.Text      = b.Tel2;
                if (!string.IsNullOrEmpty(b.RFC))
                {
                    txtRFC.Text         = b.RFC;
                    txtRazonSocial.Text = b.Razon_Social;
                    ckRFC.Checked       = true;
                }
                txtMarca.Text = c.Marca;
                txtColor.Text = c.Color;
                txtDesc.Text  = c.Descripcion;
                txtPlaca.Text = c.Placa;

                fechaInicio.Value           = (a.Inicio_Pension.GetValueOrDefault() > fechaInicio.MinDate)? a.Inicio_Pension.GetValueOrDefault():DateTime.Today;
                txtCantidadAnticipados.Text = a.No_PagosAnticipados.ToString();
                switch (d.Pensn_Tipo)
                {
                case "Semanal":
                    scPeriodo.SelectedIndex = 1;
                    break;

                case "Quincenal":
                    scPeriodo.SelectedIndex = 2;
                    break;

                case "Mensual":
                    scPeriodo.SelectedIndex = 3;
                    break;

                case "Anual":
                    scPeriodo.SelectedIndex = 4;
                    break;
                }
                ckPagado.Checked = a.StatusPago.GetValueOrDefault();
            }
        }
Пример #14
0
 private void InsertarVehiculo(int IDvehiculo)
 {
     using (var context = new PARKING_DBEntities(CadenaConexion))
     {
         var a = context.vehiculo.SingleOrDefault(n => n.Id_Vehiculo == IDvehiculo);
         if (a != null)
         {
             a.Marca       = txtMarca.Text.Trim();
             a.Descripcion = txtDesc.Text.Trim();
             a.Color       = txtColor.Text.Trim();
             a.Placa       = txtPlaca.Text.Trim();
             context.SaveChanges();
         }
     }
 }
Пример #15
0
        private void dtServidores_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int?id = GetID();

            if (id != null)
            {
                using (var context = new PARKING_DBEntities(CadenaConexion))
                {
                    var datos = context.proveedorescorreo.Where(n => n.ID_ProveedoresCorreo == id).FirstOrDefault();
                    lblID.Text           = datos.ID_ProveedoresCorreo.ToString();
                    txtServidorSMTP.Text = datos.Servidor_SMTP;
                    txtPuerto.Text       = datos.Puerto.ToString();
                }
            }
        }
Пример #16
0
        public bool ComprobarNombre()
        {
            var nombreServicio = txtNombreServicio.Text.Trim();

            using (var context = new PARKING_DBEntities(CadenaConexion))
            {
                var query = (from sa in context.serviciosadicionales where sa.ServicioAdicional == nombreServicio && sa.ID_ServicioAd != ID select sa.ID_ServicioAd).Count();

                if (query > 0)
                {
                    MessageBox.Show("El nombre que intenta registrar ya existe");
                    return(false);
                }
            }
            return(true);
        }
Пример #17
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (ComprobarNombre() == true && ComprobarCampos() == true)
                {
                    string costoFormato = txtImporte.Text.Trim();
                    costoFormato = (Cultura() == ",") ? costoFormato.Replace('.', ',') : costoFormato;

                    using (var context = new PARKING_DBEntities(CadenaConexion))
                    {
                        var a = new serviciosadicionales()
                        {
                            ServicioAdicional  = txtNombreServicio.Text.Trim(),
                            Precio_ServiciosAd = Convert.ToDecimal(costoFormato),
                            Tiempo_Gracia      = Convert.ToInt32(dmTiempo.Value),
                            ServicioAd_Activo  = ckEstado.Checked
                        };
                        context.serviciosadicionales.Add(a);
                        context.SaveChanges();
                        MessageBox.Show("Insercion Correcta");
                        this.Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
                string path     = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                string filePath = path + @"\Error.txt";
                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine("-----------------------------------------------------------------------------");
                    writer.WriteLine("Date : " + DateTime.Now.ToString());
                    writer.WriteLine();

                    while (ex != null)
                    {
                        writer.WriteLine(ex.GetType().FullName);
                        writer.WriteLine("Message : " + ex.Message);
                        writer.WriteLine("StackTrace : " + ex.StackTrace);

                        ex = ex.InnerException;
                    }
                }
                MessageBox.Show(mensajeError);
            }
        }
Пример #18
0
        private void CargarProvedores()
        {
            using (var context = new PARKING_DBEntities(CadenaConexion))
            {
                Dictionary <string, string> diccionario = new Dictionary <string, string>();

                var item = context.proveedorescorreo.ToList();
                foreach (var valores in item)
                {
                    var nombre = valores.Dominio;
                    var id     = valores.ID_ProveedoresCorreo;
                    diccionario.Add(id.ToString(), nombre);
                }
                scServidor.DataSource    = new BindingSource(diccionario, null);
                scServidor.DisplayMember = "Value";
                scServidor.ValueMember   = "Key";
            }
        }
Пример #19
0
        private int Insertarvehiculo()
        {
            int IDVehiculo = 0;

            using (var context = new PARKING_DBEntities(CadenaConexion))
            {
                var a = new vehiculo()
                {
                    Marca       = txtMarca.Text.Trim(),
                    Placa       = txtPlaca.Text.Trim(),
                    Color       = txtColor.Text.Trim(),
                    Descripcion = txtDesc.Text.Trim()
                };
                context.vehiculo.Add(a);
                context.SaveChanges();
                IDVehiculo = a.Id_Vehiculo;
            }

            return(IDVehiculo);
        }
Пример #20
0
 private void btnCrear_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtDominioCrear.Text))
     {
         MessageBox.Show("Ingrese un Dominio");
     }
     else
     {
         using (var context = new PARKING_DBEntities(CadenaConexion))
         {
             var a = new proveedorescorreo()
             {
                 Dominio = txtDominioCrear.Text.Trim(),
             };
             context.proveedorescorreo.Add(a);
             context.SaveChanges();
             CargarTabla();
         }
     }
 }
Пример #21
0
        private void CargarAreas()
        {
            using (var context = new PARKING_DBEntities(CadenaConexion))
            {
                Dictionary <string, string> diccionario = new Dictionary <string, string>();

                var item = context.areas_personal.ToList();

                foreach (var valores in item)
                {
                    var nombre = valores.AreaPersonal;
                    var id     = valores.ID_AreaPersonal;
                    diccionario.Add(id.ToString(), nombre);
                }
                scArea.DataSource    = new BindingSource(diccionario, null);
                scArea.DisplayMember = "Value";
                scArea.ValueMember   = "Key";
            }
            scArea.SelectedIndex = 0;
        }
Пример #22
0
        private void btnConfirmarCorreo_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtCorreo.Text) || string.IsNullOrEmpty(txtContraseñaServidor.Text))
            {
                MessageBox.Show("Coloque el correo y contraseña");
            }
            else
            {
                MailMessage msg = new MailMessage();
                msg.To.Add(txtCorreo.Text.Trim());
                msg.Subject         = "Correo Prueba";
                msg.SubjectEncoding = Encoding.UTF8;

                msg.Body         = "Correo Prueba";
                msg.BodyEncoding = Encoding.UTF8;
                msg.From         = new MailAddress(txtCorreo.Text.Trim());

                SmtpClient cliente = new SmtpClient();
                cliente.Credentials = new NetworkCredential(txtCorreo.Text.Trim(), txtContraseñaServidor.Text.Trim());

                var provedor = new proveedorescorreo();
                using (var context = new PARKING_DBEntities(CadenaConexion))
                {
                    provedor = context.proveedorescorreo.Where(n => n.ID_ProveedoresCorreo == IDServidor).FirstOrDefault();
                }
                cliente.Port      = provedor.Puerto.GetValueOrDefault();
                cliente.EnableSsl = true;
                cliente.Host      = provedor.Servidor_SMTP;
                try
                {
                    cliente.Send(msg);
                    MessageBox.Show("Mensaje Enviado Correctamente!");
                }
                catch (Exception)
                {
                    MessageBox.Show("Error al enviar\n" +
                                    "Cuentas de Gmail deben garantizar el permiso a aplicaciones menos seguras\n"
                                    + "Cuentas de Outlook deben estar verificadas con numero de telefono");
                }
            }
        }
 private void InsertarCliente(int id)
 {
     using (var context = new PARKING_DBEntities(CadenaConexion))
     {
         var a = context.cliente.SingleOrDefault(n => n.Id_cliente == id);
         if (a != null)
         {
             a.Nombre           = txtNombre.Text.Trim();
             a.Apellido_paterno = txtApellidoP.Text.Trim();
             a.Apellido_materno = txtApellidoM.Text.Trim();
             a.Direccion        = txtDireccion.Text.Trim();
             a.Correo           = txtCorreo.Text.Trim();
             a.Tel1             = txtTel1.Text.Trim();
             a.Tel2             = txtTel2.Text.Trim();
             a.Direccion        = txtDireccion.Text.Trim();
             a.RFC          = txtRFC.Text.Trim();
             a.Razon_Social = txtRazonSocial.Text.Trim();
             context.SaveChanges();
         }
     }
 }
Пример #24
0
        public void CargarTabla()
        {
            using (var context = new PARKING_DBEntities(CadenaConexion))
            {
                var listabusqueda = (from us in context.usuario
                                     join ap in context.areas_personal on us.ID_AreaPersonal equals ap.ID_AreaPersonal
                                     select new Modelos.ModeloUsuarios
                {
                    IDU = us.ID_Usuario,
                    Privilegios = us.Privilegios,
                    Usuario = us.Usuario1,
                    Nombre = us.Nombre,
                    Telefono = us.Telefono,
                    AreaPersonal = ap.AreaPersonal,
                    Puesto = us.Puesto,
                    CorreoE = us.mail_Correo
                }).AsQueryable();

                dtUsuarios.DataSource = listabusqueda.ToList();
                Console.WriteLine(listabusqueda.Count());
            }
        }
Пример #25
0
        private void AgregarListaPensiones()
        {
            int a = scPeriodo.SelectedIndex;

            using (var context = new PARKING_DBEntities(CadenaConexion))
            {
                Dictionary <string, string> diccionario = new Dictionary <string, string>();

                var item = context.pensiones.ToList();
                diccionario.Add("0", "Seleccione");

                foreach (var valores in item)
                {
                    var nombre = valores.Pensn_Tipo;
                    var id     = valores.ID_Tipo_Pension;
                    diccionario.Add(id.ToString(), nombre);
                }
                scPeriodo.DataSource    = new BindingSource(diccionario, null);
                scPeriodo.DisplayMember = "Value";
                scPeriodo.ValueMember   = "Key";
            }
            scPeriodo.SelectedIndex = 0;
        }
Пример #26
0
        private void btnGraficar_Click(object sender, EventArgs e)
        {
            try
            {
                btnCrearImagen.Visible = true;
                chGrafico.Visible      = true;
                dtServicio.DataSource  = null;
                listagraficaventas.Clear();
                listagrafica.Clear();
                chGrafico.Titles.Clear();
                chGrafico.Series.Clear();
                lblImporte.Visible   = (radioImporte.Checked == true) ?true:false;
                lblVehiculos.Visible = (radioVehiculos.Checked == true) ? true : false;
                if (radioVehiculos.Checked == true)
                {
                    var semana = lista.Where(n => n.ID == IDPeriodo).FirstOrDefault();
                    var dias   = new List <DateTime>();
                    int total  = 0;
                    for (var date = semana.FechaInicio; date <= semana.FechaFinal; date = date.AddDays(1))
                    {
                        dias.Add(date);
                    }
                    using (var context = new PARKING_DBEntities(CadenaConexion))
                    {
                        foreach (var item in dias)
                        {
                            var cantidad = (from bp in context.banco_parking
                                            where ((bp.FechaEntrada == item || bp.FechaSalida == item) && bp.Importe > 0)
                                            select bp.Folio).Count();
                            total = cantidad + total;
                            Modelos.ModeloEstadisticasGraficaVehiculo subquery = new Modelos.ModeloEstadisticasGraficaVehiculo
                            {
                                CantidadVehiculos = cantidad,
                                Dia = item,
                            };
                            listagrafica.Add(subquery);
                        }
                    }
                    chGrafico.Titles.Add("Cantidad de vehiculos");
                    foreach (var variables in listagrafica)
                    {
                        Series s = chGrafico.Series.Add(variables.Dia.ToShortDateString());
                        s.Label = variables.CantidadVehiculos.ToString();
                        s.Points.Add(variables.CantidadVehiculos);
                    }
                    lblVehiculos.Text     = total.ToString();
                    dtServicio.DataSource = listagrafica;
                }
                if (radioImporte.Checked == true)
                {
                    var     semana = lista.Where(n => n.ID == IDPeriodo).FirstOrDefault();
                    var     dias   = new List <DateTime>();
                    decimal?total  = 0;
                    for (var date = semana.FechaInicio; date <= semana.FechaFinal; date = date.AddDays(1))
                    {
                        dias.Add(date);
                    }
                    using (var context = new PARKING_DBEntities(CadenaConexion))
                    {
                        foreach (var item in dias)
                        {
                            var totalCobrado = (from bp in context.banco_parking
                                                where ((bp.FechaEntrada == item || bp.FechaSalida == item) && bp.Importe > 0)
                                                select bp.Importe).Sum();
                            total = totalCobrado + total;
                            Modelos.ModeloEstadisticasGraficaVentas subquery = new Modelos.ModeloEstadisticasGraficaVentas
                            {
                                Total = (totalCobrado == null) ?0: totalCobrado,
                                Dia   = item,
                            };
                            listagraficaventas.Add(subquery);
                        }
                    }
                    total = (total == null) ?0:total;
                    chGrafico.Titles.Add("Total Ingresos");
                    foreach (var variables in listagraficaventas)
                    {
                        Series s = chGrafico.Series.Add(variables.Dia.ToShortDateString());
                        s.Label = variables.Total.ToString();
                        s.Points.Add(Convert.ToInt32(variables.Total));
                    }
                    lblImporte.Text       = total.ToString();
                    dtServicio.DataSource = listagraficaventas;
                }
            }
            catch (Exception ex)
            {
                string path     = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                string filePath = path + @"\Error.txt";
                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine("-----------------------------------------------------------------------------");
                    writer.WriteLine("Date : " + DateTime.Now.ToString());
                    writer.WriteLine();

                    while (ex != null)
                    {
                        writer.WriteLine(ex.GetType().FullName);
                        writer.WriteLine("Message : " + ex.Message);
                        writer.WriteLine("StackTrace : " + ex.StackTrace);

                        ex = ex.InnerException;
                    }
                }
                MessageBox.Show(mensajeError);
            }
        }
Пример #27
0
        private void scPeriodo_SelectedIndexChanged(object sender, EventArgs e)
        {
            int cantidad = Convert.ToInt32(txtCantidadAnticipados.Text.Trim());
            var a        = ((KeyValuePair <string, string>)scPeriodo.SelectedItem).Key;
            var b        = ((KeyValuePair <string, string>)scPeriodo.SelectedItem).Value;

            ID_Plan = Int32.Parse(a);

            if (scPeriodo.SelectedIndex == 0)
            {
                lblCosto.Text      = "Seleccione un Periodo";
                lblCosto.ForeColor = Color.Red;
                ckPagado.Checked   = false;
            }
            else
            {
                errorProvider.SetError(scPeriodo, null);
                if (ckPagado.Checked != false)
                {
                    using (var context = new PARKING_DBEntities(CadenaConexion))
                    {
                        var item = context.pensiones.ToList();
                        foreach (var valores in item.Where(n => n.ID_Tipo_Pension == ID_Plan))
                        {
                            PrecioNeto         = valores.Pens_Costo_Regular.GetValueOrDefault();
                            lblCosto.ForeColor = Color.Black;
                        }
                        ;
                    }
                }
                else
                {
                    PrecioNeto    = 0;
                    lblCosto.Text = PrecioNeto.ToString();
                }
            }

            switch (b)
            {
            case "Seleccione":
                fechaTermino.Text = " ";

                break;

            case "Semanal":
                var resultado1 = fechaInicio.Value.AddDays(cantidad * 7);
                fechaTermino.Text = resultado1.ToShortDateString();
                lblCosto.Text     = ((PrecioNeto * cantidad) > 0) ? (PrecioNeto * cantidad).ToString("F", CultureInfo.InvariantCulture) : null;
                dtTermino         = resultado1;

                break;

            case "Quincenal":
                var resultado2 = fechaInicio.Value.AddDays(cantidad * 15);
                fechaTermino.Text = resultado2.ToShortDateString();
                lblCosto.Text     = ((PrecioNeto * cantidad) > 0) ? (PrecioNeto * cantidad).ToString("F", CultureInfo.InvariantCulture) : null;
                dtTermino         = resultado2;
                break;

            case "Mensual":
                var resultado3 = fechaInicio.Value.AddDays(cantidad * 30);
                fechaTermino.Text = resultado3.ToShortDateString();
                lblCosto.Text     = ((PrecioNeto * cantidad) > 0) ? (PrecioNeto * cantidad).ToString("F", CultureInfo.InvariantCulture) : null;
                dtTermino         = resultado3;
                break;

            case "Anual":
                var resultado4 = fechaInicio.Value.AddDays(cantidad * 365);
                fechaTermino.Text = resultado4.ToShortDateString();
                lblCosto.Text     = ((PrecioNeto * cantidad) > 0) ? (PrecioNeto * cantidad).ToString("F", CultureInfo.InvariantCulture) : null;
                dtTermino         = resultado4;
                break;
            }
        }
Пример #28
0
        private void btnConfirmarCorreo_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtCorreo.Text) || string.IsNullOrEmpty(txtContraseñaServidor.Text))
                {
                    MessageBox.Show("Coloque el correo y contraseña");
                }
                else
                {
                    MailMessage msg = new MailMessage();
                    msg.To.Add(txtCorreo.Text.Trim());
                    msg.Subject         = "Correo Prueba";
                    msg.SubjectEncoding = Encoding.UTF8;

                    msg.Body         = "Correo Prueba";
                    msg.BodyEncoding = Encoding.UTF8;
                    msg.From         = new MailAddress(txtCorreo.Text.Trim());

                    SmtpClient cliente = new SmtpClient();
                    cliente.Credentials = new NetworkCredential(txtCorreo.Text.Trim(), txtContraseñaServidor.Text.Trim());

                    var provedor = new proveedorescorreo();
                    using (var context = new PARKING_DBEntities(CadenaConexion))
                    {
                        provedor = context.proveedorescorreo.Where(n => n.ID_ProveedoresCorreo == IDServidor).FirstOrDefault();
                    }
                    cliente.Port      = provedor.Puerto.GetValueOrDefault();
                    cliente.EnableSsl = true;
                    cliente.Host      = provedor.Servidor_SMTP;
                    try
                    {
                        cliente.Send(msg);
                        MessageBox.Show("Mensaje Enviado Correctamente!");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error al enviar\n" +
                                        "Cuentas de Gmail deben garantizar el permiso a aplicaciones menos seguras\n"
                                        + "Cuentas de Outlook deben estar verificadas con numero de telefono");
                    }
                }
            }
            catch (Exception ex)
            {
                string path     = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                string filePath = path + @"\Error.txt";
                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine("-----------------------------------------------------------------------------");
                    writer.WriteLine("Date : " + DateTime.Now.ToString());
                    writer.WriteLine();

                    while (ex != null)
                    {
                        writer.WriteLine(ex.GetType().FullName);
                        writer.WriteLine("Message : " + ex.Message);
                        writer.WriteLine("StackTrace : " + ex.StackTrace);

                        ex = ex.InnerException;
                    }
                }
                MessageBox.Show(mensajeError);
            }
        }
        private void InsertarPension(int idpension)
        {
            decimal?ultimoPago   = null;
            string  costoFormato = lblCosto.Text.Replace('.', ',');
            int     ultimoCorte;

            using (var context = new PARKING_DBEntities(CadenaConexion))
            {
                var b      = context.cortes.ToList();
                var ultimo = b.LastOrDefault();
                ultimoCorte = ultimo.Id_Corte;
            }
            if (ckPagado.Checked == true)
            {
                using (var context = new PARKING_DBEntities(CadenaConexion))
                {
                    var c = context.banco_pension.Where(n => n.Id_cliente == this.ID_Cliente).ToList();
                    if (c.Count > 0)
                    {
                        var ultimop = c.LastOrDefault();
                        ultimoPago = ultimop.Pagos;
                    }

                    var a = context.banco_pension.SingleOrDefault(n => n.ID == idpension);
                    if (a != null)
                    {
                        a.FechaInscripcion    = DateTime.Now;
                        a.FechaUltimoPago     = DateTime.Now;
                        a.CobradoPor          = Usuario;
                        a.Inicio_Pension      = fechaInicio.Value;
                        a.Fin_Pension         = dtTermino;
                        a.ID_Tipo_Pension     = ID_Plan;
                        a.StatusPago          = true;
                        a.No_PagosAnticipados = (Convert.ToInt32(txtCantidadAnticipados.Text) - 1);
                        a.Costo          = Convert.ToDecimal(costoFormato);
                        a.Pagos          = Convert.ToDecimal(costoFormato) + ultimoPago;
                        a.Id_cliente     = idpension;
                        a.Pension_Corte  = false;
                        a.Pension_Activa = true;
                        context.SaveChanges();
                    }
                }
            }
            else
            {
                using (var context = new PARKING_DBEntities(CadenaConexion))
                {
                    var c = context.banco_pension.Where(n => n.Id_cliente == this.ID_Cliente).ToList();
                    if (c.Count > 0)
                    {
                        var ultimop = c.LastOrDefault();
                        ultimoPago = ultimop.Pagos;
                    }


                    var a = context.banco_pension.SingleOrDefault(n => n.ID == idpension);
                    if (a != null)
                    {
                        a.FechaInscripcion    = DateTime.Now;
                        a.FechaUltimoPago     = null;
                        a.CobradoPor          = Usuario;
                        a.Inicio_Pension      = null;
                        a.Fin_Pension         = dtTermino;
                        a.ID_Tipo_Pension     = ID_Plan;
                        a.StatusPago          = false;
                        a.No_PagosAnticipados = null;
                        a.Costo          = Convert.ToDecimal(PrecioNeto);
                        a.Pagos          = ultimoPago;
                        a.Id_cliente     = idpension;
                        a.Pension_Corte  = true;
                        a.Pension_Activa = false;
                        a.Id_corte       = ultimoCorte;
                        context.SaveChanges();
                    }
                }
            }
        }
Пример #30
0
        private void InsertarPension(int IdCliente)
        {
            string   costoFormato = lblCosto.Text.Replace('.', ',');
            int      ultimoCorte;
            decimal? ultimoPago      = 0;
            DateTime?fechaUltimoPAgo = null;

            using (var context = new PARKING_DBEntities(CadenaConexion))
            {
                var b      = context.cortes.ToList();
                var ultimo = b.LastOrDefault();
                ultimoCorte = ultimo.Id_Corte;

                var c = context.banco_pension.Where(n => n.Id_cliente == IdCliente).ToList();
                if (c.Count > 0)
                {
                    var ultimop = c.LastOrDefault();
                    ultimoPago      = ultimop.Pagos;
                    fechaUltimoPAgo = ultimop.FechaUltimoPago;
                }
            }

            if (ckPagado.Checked == true)
            {
                using (var context = new PARKING_DBEntities(CadenaConexion))
                {
                    string identificador = "PE";
                    var    ultimoID      = context.banco_pension.ToList().LastOrDefault();
                    var    folio         = (ultimoID == null) ? "1" : (ultimoID.ID + 1).ToString();
                    var    tam           = folio.Length;
                    switch (tam)
                    {
                    case 1:
                        folio = "00000" + folio;
                        break;

                    case 2:
                        folio = "0000" + folio;
                        break;

                    case 3:
                        folio = "000" + folio;
                        break;

                    case 4:
                        folio = "00" + folio;
                        break;

                    case 5:
                        folio = "0" + folio;
                        break;
                    }
                    identificador = identificador + folio;



                    var a = new banco_pension()
                    {
                        FechaInscripcion    = DateTime.Now,
                        Folio               = identificador,
                        FechaUltimoPago     = DateTime.Now,
                        CobradoPor          = Usuario,
                        Inicio_Pension      = fechaInicio.Value,
                        Fin_Pension         = dtTermino,
                        ID_Tipo_Pension     = ID_Plan,
                        StatusPago          = true,
                        No_PagosAnticipados = (Convert.ToInt32(txtCantidadAnticipados.Text) - 1),
                        Costo               = Convert.ToDecimal(costoFormato),
                        Pagos               = ultimoPago + Convert.ToDecimal(costoFormato),
                        Id_cliente          = IdCliente,
                        Pension_Corte       = false,
                        Pension_Activa      = true,
                        Id_corte            = ultimoCorte,
                    };
                    context.banco_pension.Add(a);
                    context.SaveChanges();
                }
            }
            else
            {
                using (var context = new PARKING_DBEntities(CadenaConexion))
                {
                    string identificador = "PE";
                    var    ultimoID      = context.banco_pension.ToList().LastOrDefault();
                    var    folio         = (ultimoID == null) ? "1" : (ultimoID.ID + 1).ToString();
                    var    tam           = folio.Length;
                    switch (tam)
                    {
                    case 1:
                        folio = "00000" + folio;
                        break;

                    case 2:
                        folio = "0000" + folio;
                        break;

                    case 3:
                        folio = "000" + folio;
                        break;

                    case 4:
                        folio = "00" + folio;
                        break;

                    case 5:
                        folio = "0" + folio;
                        break;
                    }
                    identificador = identificador + folio;

                    var a = new banco_pension()
                    {
                        FechaInscripcion    = DateTime.Now,
                        Folio               = identificador,
                        FechaUltimoPago     = fechaUltimoPAgo,
                        CobradoPor          = Usuario,
                        Inicio_Pension      = DateTime.Now,
                        Fin_Pension         = dtTermino,
                        ID_Tipo_Pension     = ID_Plan,
                        StatusPago          = false,
                        No_PagosAnticipados = null,
                        Costo               = (from tp in context.pensiones where tp.ID_Tipo_Pension == ID_Plan select tp.Pens_Costo_Regular).FirstOrDefault(),
                        Pagos               = ultimoPago,
                        Id_cliente          = IdCliente,
                        Pension_Corte       = true,
                        Pension_Activa      = false,
                        Id_corte            = null,
                    };
                    context.banco_pension.Add(a);
                    context.SaveChanges();
                }
            }
        }