Пример #1
0
        private void readFileToImport()
        {
            List <string> archivos = commons.showOpenFile("Archivos de Excel (*.xlsx)|*.xlsx", true);

            if (archivos == null)
            {
                return;
            }

            clsRepo repo = new clsRepo();

            foreach (string archivo in archivos)
            {
                var             data   = File.ReadAllBytes(archivo);
                ImportFromExcel import = new ImportFromExcel();
                import.LoadXlsx(data);

                List <UsuarioExcel> output = import.ExcelToList <UsuarioExcel>(0, 1);

                foreach (UsuarioExcel usr in output)
                {
                    repo.Insertar <Dominio.Entidad>(usr.getEntidad());
                }
            }
        }
Пример #2
0
        private void btnIPsMasivo_Click(object sender, EventArgs e)
        {
            List <string> archivos = commons.showOpenFile("Archivos de Excel (*.xlsx)|*.xlsx", true);

            if (archivos == null)
            {
                return;
            }

            if (archivos.Count <= 0)
            {
                return;
            }

            foreach (string archivo in archivos)
            {
                byte[]          bits       = File.ReadAllBytes(archivo);
                ImportFromExcel importer   = new ImportFromExcel();
                bool            res        = importer.LoadXlsx(bits);
                List <Excel.Ip> excel_rows = importer.ExcelToList <Excel.Ip>(0, 1);
                clsRepo         repo       = new clsRepo();
                foreach (Excel.Ip ip in excel_rows)
                {
                    repo.Insertar <Dominio.Ip>(ip.getDBip());
                }
            }
        }
Пример #3
0
        public RegisterDto Register(string userName, string password)
        {
            try
            {
                var dataAccess   = new clsRepo(WebConfigurationManager.AppSettings["strDBconn"].ToString());
                var existingUser = dataAccess.SelectUserByUserName(userName);
                if (existingUser == null)
                {
                    // should decrypt the pwd before store in db, simplify for demo purpose
                    dataAccess.AddUser(userName, password);
                    return(new RegisterDto {
                        Status = true
                    });
                }
            }
            catch (Exception ex)
            {
                return(new RegisterDto {
                    Status = false, Message = ex.Message
                });
            }

            return(new RegisterDto
            {
                Status = false,
                Message = "UserName already exist in the system."
            });
        }
Пример #4
0
        private void btnGenerar_Click(object sender, EventArgs e)
        {
            if (cmbConReport.Items.Count == 0)
            {
                return;
            }
            if (cmbConReport.SelectedItem != null)
            {
                try
                {
                    Config.Reporte         rpt      = (Config.Reporte)cmbConReport.Items[cmbConReport.SelectedIndex];
                    clsRepo                repo     = new clsRepo();
                    DataTable              dt       = repo.Seleccionar(rpt.SQL);
                    ExcelReporter.Exporter exporter = new ExcelReporter.Exporter();
                    exporter.AgregarWorkSheet(dt, cleantext(rpt.Nombre));
                    exporter.CrearArchivoExcelDialog();
                }
                catch (Exception ex)
                {
                    string mensaje = "";
                    while (ex != null)
                    {
                        mensaje = mensaje + ex.Message + "\n\n";
                        ex      = ex.InnerException;
                    }

                    commons.mensajeError("El reporte regresó el siguiente error:\n" + mensaje, "Error al generar el reporte");
                }
            }
        }
Пример #5
0
 private void btnClearTable_Click(object sender, EventArgs e)
 {
     try
     {
         clsRepo repo = new clsRepo();
         repo.Actualizacion("delete from " + cmbTabla.SelectedItem.ToString());
         commons.mensajeInformativo("Tabla " + cmbTabla.SelectedItem.ToString() + " limpia!", "Limpieza de tablas");
     }
     catch (Exception ex)
     {
         commons.mensajeError(ex.Message, "Error");
     }
 }
Пример #6
0
        public panelArchLogs()
        {
            InitializeComponent();
            this._waitScreen        = new frmWait();
            this._waitScreen.Parent = this._formPadre;
            clsRepo repo = new clsRepo();

            foreach (string clase in repo.getEntidadesNombre())
            {
                cmbTabla.Items.Add(clase);
            }
            if (cmbTabla.Items.Count > 0)
            {
                cmbTabla.SelectedIndex = 0;
            }
        }
Пример #7
0
        public LoginDto Login(string userName, string password)
        {
            var dataAccess = new clsRepo(WebConfigurationManager.AppSettings["strDBconn"].ToString());
            var user       = dataAccess.SelectUserByUserNamePwd(userName, password);

            if (user != null)
            {
                return(new LoginDto
                {
                    Status = true,
                    UserId = user.UserId,
                    UserName = user.UserName
                });
            }

            return(new LoginDto {
                Status = false
            });
        }
Пример #8
0
        private void btnClearAllTables_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Esta seguro que desea vaciar todo el contenido de la base de datos?", "Limpiar Tablas", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (dr == DialogResult.No)
            {
                return;
            }

            try{
                clsRepo repo = new clsRepo();
                foreach (object tabla in cmbTabla.Items)
                {
                    repo.Actualizacion("delete from " + tabla.ToString());
                }
            }catch (Exception ex)
            {
                commons.mensajeError(ex.Message, "Error");
            }
        }
Пример #9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!verficaIp(txtIp.Text))
            {
                commons.mensajeInformativo("Verifique la IP ingresada", this.Text);
                return;
            }

            clsRepo repo = new clsRepo();

            Dominio.Ip ip = new Dominio.Ip();
            ip.descripcion    = txtDescripcion.Text;
            ip.ip             = txtIp.Text;
            ip.samaccountname = txtIDUsuario.Text;
            try
            {
                repo.Insertar <Dominio.Ip>(ip);
                this.Close();
            }
            catch (Exception ex)
            {
                commons.mensajeError(ex.Message, this.Text);
            }
        }