Ejemplo n.º 1
1
        /// <summary>
        /// Creates a new instance of the ViewSeguridadUsuario class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewSeguridadUsuarioInfo MakeViewSeguridadUsuario(SqlDataReader dataReader)
        {
            ViewSeguridadUsuarioInfo viewSeguridadUsuario = new ViewSeguridadUsuarioInfo();

            if (dataReader.IsDBNull(SeguridadUsuarioId) == false)
                viewSeguridadUsuario.SeguridadUsuarioId = dataReader.GetInt32(SeguridadUsuarioId);
            if (dataReader.IsDBNull(SeguridadRolId) == false)
                viewSeguridadUsuario.SeguridadRolId = dataReader.GetInt32(SeguridadRolId);
            if (dataReader.IsDBNull(Rol) == false)
                viewSeguridadUsuario.Rol = dataReader.GetString(Rol);
            if (dataReader.IsDBNull(NombreUsuario) == false)
                viewSeguridadUsuario.NombreUsuario = dataReader.GetString(NombreUsuario);
            if (dataReader.IsDBNull(Nombres) == false)
                viewSeguridadUsuario.Nombres = dataReader.GetString(Nombres);
            if (dataReader.IsDBNull(Apellidos) == false)
                viewSeguridadUsuario.Apellidos = dataReader.GetString(Apellidos);
            if (dataReader.IsDBNull(PaswordHash) == false)
                viewSeguridadUsuario.PaswordHash = dataReader.GetString(PaswordHash);
            if (dataReader.IsDBNull(Salt) == false)
                viewSeguridadUsuario.salt = dataReader.GetString(Salt);
            if (dataReader.IsDBNull(Activo) == false)
                viewSeguridadUsuario.Activo = dataReader.GetBoolean(Activo);
            if (dataReader.IsDBNull(NombreCompleto) == false)
                viewSeguridadUsuario.NombreCompleto = dataReader.GetString(NombreCompleto);

            return viewSeguridadUsuario;
        }
Ejemplo n.º 2
1
        /// <summary>
        /// Loads the entity from a <b>SqlDataReader</b> object.
        /// </summary>
        /// <param name="dr">The data reader to read from.</param>
        /// <returns>Returns the number of columns read.</returns>
        /// <remarks>
        /// Always reads at the current cursor position, doesn't calls the <b>Read</b> function
        /// on the <b>SqlDataReader</b> object. Reads data columns by their ordinal position in
        /// the query and not by their names.
        /// </remarks>
        internal override int LoadFromDataReader(SqlDataReader dr)
        {
            int o = base.LoadFromDataReader(dr);

            ++o;    // skip guid
            this.workflowTypeName = dr.GetString(++o);
            this.dateStarted = dr.IsDBNull(++o) ? DateTime.MinValue : dr.GetDateTime(o);
            this.dateFinished = dr.IsDBNull(++o) ? DateTime.MinValue : dr.GetDateTime(o);
            this.jobExecutionStatus = (JobExecutionState)dr.GetInt32(++o);
            this.suspendTimeout = dr.IsDBNull(++o) ? DateTime.MinValue : dr.GetDateTime(o);
            this.scheduleType = (ScheduleType)dr.GetInt32(++o);
            this.scheduleTime = dr.IsDBNull(++o) ? DateTime.MinValue : dr.GetDateTime(o);
            this.recurringPeriod = (RecurringPeriod)dr.GetInt32(++o);
            this.recurringInterval = dr.GetInt32(++o);
            this.recurringMask = dr.GetInt64(++o);
            this.workflowInstanceId = dr.IsDBNull(++o) ? Guid.Empty : dr.GetGuid(o);
            this.adminRequestTime = dr.IsDBNull(++o) ? DateTime.MinValue : dr.GetDateTime(o);
            if (!dr.IsDBNull(++o))
            {
                XmlSerializer ser = new XmlSerializer(typeof(JobAdminRequestData));
                StringReader sr = new StringReader(dr.GetString(o));
                this.adminRequestData = (JobAdminRequestData)ser.Deserialize(sr);
            }
            else
            {
                this.adminRequestData = null;
            }
            this.adminRequestResult = dr.GetInt32(++o);
            this.exceptionMessage = dr.IsDBNull(++o) ? null : dr.GetString(o);

            return o;
        }
 /** Descripcion:
  *
  * REQ: SqlDataReader, int
  *
  * RET: static string
  */
 public static string SafeGetString(SqlDataReader reader, int colIndex)
 {
     if (!reader.IsDBNull(colIndex))
         return reader.GetString(colIndex);
     else
         return string.Empty;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new instance of the ViewCalidadPlanAccion class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewCalidadPlanAccionInfo MakeViewCalidadPlanAccion(SqlDataReader dataReader)
        {
            ViewCalidadPlanAccionInfo viewCalidadPlanAccion = new ViewCalidadPlanAccionInfo();

            if (dataReader.IsDBNull(CalidadPlanAccionId) == false)
                viewCalidadPlanAccion.CalidadPlanAccionId = dataReader.GetInt32(CalidadPlanAccionId);
            if (dataReader.IsDBNull(AuditorId) == false)
                viewCalidadPlanAccion.AuditorId = dataReader.GetInt32(AuditorId);
            if (dataReader.IsDBNull(NombreAuditor) == false)
                viewCalidadPlanAccion.NombreAuditor = dataReader.GetString(NombreAuditor);
            if (dataReader.IsDBNull(TerritorioId) == false)
                viewCalidadPlanAccion.TerritorioId = dataReader.GetInt32(TerritorioId);
            if (dataReader.IsDBNull(Territorio) == false)
                viewCalidadPlanAccion.Territorio = dataReader.GetString(Territorio);
            if (dataReader.IsDBNull(AuditoriaCausaRaizId) == false)
                viewCalidadPlanAccion.AuditoriaCausaRaizId = dataReader.GetInt32(AuditoriaCausaRaizId);
            if (dataReader.IsDBNull(CausaRaiz) == false)
                viewCalidadPlanAccion.CausaRaiz = dataReader.GetString(CausaRaiz);
            if (dataReader.IsDBNull(AccionPreventiva) == false)
                viewCalidadPlanAccion.AccionPreventiva = dataReader.GetString(AccionPreventiva);
            if (dataReader.IsDBNull(FechaPlaneada) == false)
                viewCalidadPlanAccion.FechaPlaneada = dataReader.GetDateTime(FechaPlaneada);
            if (dataReader.IsDBNull(Observacion) == false)
                viewCalidadPlanAccion.Observacion = dataReader.GetString(Observacion);
            if (dataReader.IsDBNull(FechaCierre) == false)
                viewCalidadPlanAccion.FechaCierre = dataReader.GetDateTime(FechaCierre);
            if (dataReader.IsDBNull(Estatus) == false)
                viewCalidadPlanAccion.Estatus = dataReader.GetString(Estatus);

            return viewCalidadPlanAccion;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a new instance of the ViewControlesAsignados class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewControlesAsignadosInfo MakeViewControlesAsignados(SqlDataReader dataReader)
        {
            ViewControlesAsignadosInfo viewControlesAsignados = new ViewControlesAsignadosInfo();

            if (dataReader.IsDBNull(AuditoriaResultadoId) == false)
                viewControlesAsignados.AuditoriaResultadoId = dataReader.GetInt32(AuditoriaResultadoId);
            if (dataReader.IsDBNull(AuditoriaControlId) == false)
                viewControlesAsignados.AuditoriaControlId = dataReader.GetInt32(AuditoriaControlId);
            if (dataReader.IsDBNull(AuditoriaPuntoId) == false)
                viewControlesAsignados.AuditoriaPuntoId = dataReader.GetInt32(AuditoriaPuntoId);
            if (dataReader.IsDBNull(Punto) == false)
                viewControlesAsignados.Punto = dataReader.GetString(Punto);
            if (dataReader.IsDBNull(Control) == false)
                viewControlesAsignados.Control = dataReader.GetString(Control);
            if (dataReader.IsDBNull(AuditoriaId) == false)
                viewControlesAsignados.AuditoriaId = dataReader.GetInt32(AuditoriaId);
            if (dataReader.IsDBNull(PuntajeRequerido) == false)
                viewControlesAsignados.PuntajeRequerido = dataReader.GetDecimal(PuntajeRequerido);
            if (dataReader.IsDBNull(EsNoConformidad) == false)
                viewControlesAsignados.EsNoConformidad = dataReader.GetBoolean(EsNoConformidad);
            if (dataReader.IsDBNull(AuditoriaCausaRaizId) == false)
                viewControlesAsignados.AuditoriaCausaRaizId = dataReader.GetInt32(AuditoriaCausaRaizId);
            if (dataReader.IsDBNull(Observacion) == false)
                viewControlesAsignados.Observacion = dataReader.GetString(Observacion);
            if (dataReader.IsDBNull(Orden) == false)
                viewControlesAsignados.Orden = dataReader.GetByte(Orden);

            return viewControlesAsignados;
        }
Ejemplo n.º 6
0
        public static Request Map(SqlDataReader record)
        {
            if (record == null) throw new ArgumentNullException("record");
            var request = new Request();

            request.Id = (int) record["Id"];
            request.RequesTime = (DateTime) record["RequetTime"];
            if (record["CreatorId"].ToString() != string.Empty)
            {
                request.CreatorId = (int) record["CreatorId"];
            }
            request.PhoneNumber = (string) record["PhoneNumber"];
            request.Status = (int) record["Status"];
            request.StartPoint = (string) record["StartPoint"];
            request.FinishPoint = (string) record["FinishPoint"];
            request.OperatorId = record.IsDBNull(record.GetOrdinal("OperatorId")) == false
                              ? (int)record["OperatorId"]
                              : default(int?);
            request.DriverId = record.IsDBNull(record.GetOrdinal("DriverId")) == false
                ? (int?) record["DriverId"]
                : default(int?);
            request.Price = record.IsDBNull(record.GetOrdinal("Price")) == false
               ? (decimal?)record["Price"]
               : default(decimal?);
            request.Additional = record.IsDBNull(record.GetOrdinal("Additional")) == false
               ? (string)record["Additional"]
               : default(string);
            return request;
        }
Ejemplo n.º 7
0
 public void PopulateVolunteer(SqlDataReader _dtr, Volunteer obj)
 {
     int columnIndex = 0;
     columnIndex = _dtr.GetOrdinal(VolunteerDataMapper.CN_ID);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.ID = _dtr.GetInt32((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(VolunteerDataMapper.CN_NAME);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Name = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(VolunteerDataMapper.CN_EMAIL);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Email = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(VolunteerDataMapper.CN_CV);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.CV = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(VolunteerDataMapper.CN_MESSAGE);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Message = _dtr.GetString((columnIndex));
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a new instance of the ViewAPM class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewAPMInfo MakeViewAPM(SqlDataReader dataReader)
        {
            ViewAPMInfo viewAPM = new ViewAPMInfo();

            if (dataReader.IsDBNull(Cod_APM) == false)
                viewAPM.Cod_APM = dataReader.GetInt32(Cod_APM);
            if (dataReader.IsDBNull(Cod_Delegacion) == false)
                viewAPM.Cod_Delegacion = dataReader.GetInt32(Cod_Delegacion);
            if (dataReader.IsDBNull(Delegacion) == false)
                viewAPM.Delegacion = dataReader.GetString(Delegacion);
            if (dataReader.IsDBNull(Cod_Regional) == false)
                viewAPM.Cod_Regional = dataReader.GetInt32(Cod_Regional);
            if (dataReader.IsDBNull(Codigo_Completo) == false)
                viewAPM.Codigo_Completo = dataReader.GetString(Codigo_Completo);
            if (dataReader.IsDBNull(Numero_APM) == false)
                viewAPM.Numero_APM = dataReader.GetString(Numero_APM);
            if (dataReader.IsDBNull(Apellido) == false)
                viewAPM.Apellido = dataReader.GetString(Apellido);
            if (dataReader.IsDBNull(Nombre) == false)
                viewAPM.Nombre = dataReader.GetString(Nombre);
            if (dataReader.IsDBNull(Fecha_Nacimiento) == false)
                viewAPM.Fecha_Nacimiento = dataReader.GetDateTime(Fecha_Nacimiento);
            if (dataReader.IsDBNull(Action) == false)
                viewAPM.Action = dataReader.GetString(Action);
            if (dataReader.IsDBNull(Cod_Provincia) == false)
                viewAPM.Cod_Provincia = dataReader.GetInt32(Cod_Provincia);

            return viewAPM;
        }
Ejemplo n.º 9
0
 ///<summary></summary>
 protected override void ReadExecuted(System.Data.SqlClient.SqlDataReader dr)
 {
     if (dr != null && !dr.IsClosed)
     {
         #region Read Each Field
         if (!dr.IsDBNull(dr.GetOrdinal("Id")))
         {
             m_Current.Id = dr.GetInt32(dr.GetOrdinal("Id"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Name")))
         {
             m_Current.Name = dr.GetString(dr.GetOrdinal("Name"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("UrlSlug")))
         {
             m_Current.UrlSlug = dr.GetString(dr.GetOrdinal("UrlSlug"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Description")))
         {
             m_Current.Description = dr.GetString(dr.GetOrdinal("Description"));
         }
         #endregion
         ExistsInDB = true;
         Mode       = EditMode.None;
         SetOriginalValues();
     }
 }
Ejemplo n.º 10
0
        protected void lbtnforgetpass_Click(object sender, EventArgs e)
        {

            if (txtforgrtid.Text == "")
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "popup",
                        "alert('Please Enter The User_ID.');", true);
                return;
            }
            else
            {
                a = txtforgrtid.Text;
            }
            try
            {
                dr = cls.FillDataReader("select R_password , R_EmailId from Registerlist where R_logid='" + a + "'");
                if (dr.Read())
                {
                    if (!dr.IsDBNull(0))
                    {
                        pass = dr.GetValue(0).ToString();
                    }
                    if (!dr.IsDBNull(1))
                    {
                        emal = dr.GetValue(1).ToString();
                    }
                }
                dr.Close();
                if (pass == null && emal == null)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "popup",
                        "alert('Not a valid User_ID.');", true);
                    txtforgrtid.Text = "";
                    return;
                }
                else
                {
                    bool var = MailHelper.CheckForInternetConnection();
                    if (var == true)
                    {
                        MailHelper.SendMailMessage("*****@*****.**", emal, "Password", "Your Password:'******'");
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "popup",
                                 "alert('Password have been sent to your registered email_ID.');", true);
                        txtforgrtid.Text = "";
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "popup",
                            "alert('Please Check Your Internet Connection.');", true);
                        txtforgrtid.Text = "";
                    }
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "popup",
                   "alert(" + ex + ");", true);
            }
        }
Ejemplo n.º 11
0
 public Tarjeta(SqlDataReader reader)
 {
     this.codTarjeta = reader.IsDBNull(reader.GetOrdinal("codTarjeta")) ? null : (string)reader["codTarjeta"];
     this.fecEmision = reader.IsDBNull(reader.GetOrdinal("fechaEmi")) ? null : (string)reader["fechaEmi"].ToString();
     this.fecAnulado = reader.IsDBNull(reader.GetOrdinal("fechaAnu")) ? null : (string)reader["fechaAnu"].ToString();
     this.estado = reader.IsDBNull(reader.GetOrdinal("estado")) ? -1 : (int)reader["estado"];
     this.cliente = new Cliente(reader);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 数据转类别实体
        /// </summary>
        public static UserCategoryInfo DataToModel(SqlDataReader rdr)
        {
            UserCategoryInfo category = new UserCategoryInfo();
            if (!rdr.IsDBNull(0)) category.CategoryTypeID = rdr.GetInt32(0);
            if (!rdr.IsDBNull(1)) category.CategoryTypeName = rdr.GetString(1);
            if (!rdr.IsDBNull(2)) category.CategoryTypePrice = rdr.GetDecimal(2);

            return category;
        }
Ejemplo n.º 13
0
        public void PopulateCategory(SqlDataReader _dtr, Category obj)
        {
            int columnIndex = 0;
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.ID = _dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_NAME);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Name = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_DESCRIPTION);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Description = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_TYPE);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Type = (TG.ExpressCMS.DataLayer.Enums.RootEnums.CategoryType)_dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_ATTRIBUTES);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Attributes = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_ISDELETED);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.IsDeleted = _dtr.GetBoolean((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_XSL_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.XslID = _dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_image);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Image = _dtr.GetString((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_LANGUAGE_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.LanguageID = _dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_HASH);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Hash = _dtr.GetString((columnIndex));
            }
        }
Ejemplo n.º 14
0
 public EntityBase PopulateEntity(SqlDataReader reader)
 {
     Customer customer = new Customer();
     if (!reader.IsDBNull(ord_CustomerID)) customer.CustomerID = reader.GetInt32(ord_CustomerID);
     if (!reader.IsDBNull(ord_FirstName)) customer.FirstName = reader.GetString(ord_FirstName);
     if (!reader.IsDBNull(ord_LastName)) customer.LastName = reader.GetString(ord_LastName);
     if (!reader.IsDBNull(ord_Age)) customer.Age = reader.GetInt32(ord_Age);
     if (!reader.IsDBNull(ord_EmailAddress)) customer.EmailAddress = reader.GetString(ord_EmailAddress);
     return customer;
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Creates a new instance of the TipoEspecialidad class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static TipoEspecialidadInfo MakeTipoEspecialidad(SqlDataReader dataReader)
        {
            TipoEspecialidadInfo tipoEspecialidad = new TipoEspecialidadInfo();

            if (dataReader.IsDBNull(Cod_TipoEspecialidad) == false)
                tipoEspecialidad.Cod_TipoEspecialidad = dataReader.GetInt32(Cod_TipoEspecialidad);
            if (dataReader.IsDBNull(Descripcion) == false)
                tipoEspecialidad.Descripcion = dataReader.GetString(Descripcion);

            return tipoEspecialidad;
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Creates a new instance of the DelegacionProvincia class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static DelegacionProvinciaInfo MakeDelegacionProvincia(SqlDataReader dataReader)
        {
            DelegacionProvinciaInfo delegacionProvincia = new DelegacionProvinciaInfo();

            if (dataReader.IsDBNull(Cod_Delegacion) == false)
                delegacionProvincia.Cod_Delegacion = dataReader.GetInt32(Cod_Delegacion);
            if (dataReader.IsDBNull(Cod_Provincia) == false)
                delegacionProvincia.Cod_Provincia = dataReader.GetInt32(Cod_Provincia);
            if (dataReader.IsDBNull(Cod_APM) == false)
                delegacionProvincia.Cod_APM = dataReader.GetInt32(Cod_APM);

            return delegacionProvincia;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Creates a new instance of the ART_SeguridadAcceso class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ART_SeguridadAccesoInfo MakeART_SeguridadAcceso(SqlDataReader dataReader)
        {
            ART_SeguridadAccesoInfo aRT_SeguridadAcceso = new ART_SeguridadAccesoInfo();

            if (dataReader.IsDBNull(SeguridadAccesoId) == false)
                aRT_SeguridadAcceso.SeguridadAccesoId = dataReader.GetInt32(SeguridadAccesoId);
            if (dataReader.IsDBNull(SeguridadModuloId) == false)
                aRT_SeguridadAcceso.SeguridadModuloId = dataReader.GetInt32(SeguridadModuloId);
            if (dataReader.IsDBNull(SeguridadRolId) == false)
                aRT_SeguridadAcceso.SeguridadRolId = dataReader.GetInt32(SeguridadRolId);

            return aRT_SeguridadAcceso;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Creates a new instance of the ViewAuditoresLideres class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewAuditoresLideresInfo MakeViewAuditoresLideres(SqlDataReader dataReader)
        {
            ViewAuditoresLideresInfo viewAuditoresLideres = new ViewAuditoresLideresInfo();

            if (dataReader.IsDBNull(AuditoriaId) == false)
                viewAuditoresLideres.AuditoriaId = dataReader.GetInt32(AuditoriaId);
            if (dataReader.IsDBNull(AuditorId) == false)
                viewAuditoresLideres.AuditorId = dataReader.GetInt32(AuditorId);
            if (dataReader.IsDBNull(NombreAuditor) == false)
                viewAuditoresLideres.NombreAuditor = dataReader.GetString(NombreAuditor);

            return viewAuditoresLideres;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Creates a new instance of the ViewCargosPorLista class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewCargosPorListaInfo MakeViewCargosPorLista(SqlDataReader dataReader)
        {
            ViewCargosPorListaInfo viewCargosPorLista = new ViewCargosPorListaInfo();

            if (dataReader.IsDBNull(AuditoriaListaVerificacionId) == false)
                viewCargosPorLista.AuditoriaListaVerificacionId = dataReader.GetInt32(AuditoriaListaVerificacionId);
            if (dataReader.IsDBNull(CargoId) == false)
                viewCargosPorLista.CargoId = dataReader.GetInt32(CargoId);
            if (dataReader.IsDBNull(Descripcion) == false)
                viewCargosPorLista.Descripcion = dataReader.GetString(Descripcion);

            return viewCargosPorLista;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Creates a new instance of the ART_SeguridadRol class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ART_SeguridadRolInfo MakeART_SeguridadRol(SqlDataReader dataReader)
        {
            ART_SeguridadRolInfo aRT_SeguridadRol = new ART_SeguridadRolInfo();

            if (dataReader.IsDBNull(SeguridadRolId) == false)
                aRT_SeguridadRol.SeguridadRolId = dataReader.GetInt32(SeguridadRolId);
            if (dataReader.IsDBNull(DescripcionRol) == false)
                aRT_SeguridadRol.DescripcionRol = dataReader.GetString(DescripcionRol);
            if (dataReader.IsDBNull(Activo) == false)
                aRT_SeguridadRol.Activo = dataReader.GetBoolean(Activo);

            return aRT_SeguridadRol;
        }
        public IProject Resolve(IProject project, SqlDataReader reader)
        {
            project.ProjectId = Convert.ToInt32(reader["projectId"]);
            project.Name = Convert.ToString(reader["name"]);
            project.StatusId = Convert.ToInt32(reader["statusId"]);

            if(!reader.IsDBNull(reader.GetOrdinal("PlannedEndDate"))) project.PlannedEndDate = Convert.ToDateTime(reader["PlannedEndDate"]);
            if (!reader.IsDBNull(reader.GetOrdinal("ActualEndDate"))) project.ActualEndDate = Convert.ToDateTime(reader["ActualEndDate"]);
            if (!reader.IsDBNull(reader.GetOrdinal("PlannedStartDate"))) project.PlannedStartDate = Convert.ToDateTime(reader["PlannedStartDate"]);
            if (!reader.IsDBNull(reader.GetOrdinal("ActualStartDate"))) project.ActualEndDate = Convert.ToDateTime(reader["ActualStartDate"]);

               project.CompanyId = Convert.ToInt32(reader["companyId"]);

            return project;
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Creates a new instance of the ViewProductoObjetivo class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewProductoObjetivoInfo MakeViewProductoObjetivo(SqlDataReader dataReader)
        {
            ViewProductoObjetivoInfo viewProductoObjetivo = new ViewProductoObjetivoInfo();

            if (dataReader.IsDBNull(Cod_Producto) == false)
                viewProductoObjetivo.Cod_Producto = dataReader.GetInt32(Cod_Producto);
            if (dataReader.IsDBNull(Cod_Trilogia) == false)
                viewProductoObjetivo.Cod_Trilogia = dataReader.GetInt32(Cod_Trilogia);
            if (dataReader.IsDBNull(Producto) == false)
                viewProductoObjetivo.Producto = dataReader.GetString(Producto);
            if (dataReader.IsDBNull(Cantidad) == false)
                viewProductoObjetivo.Cantidad = dataReader.GetInt16(Cantidad);

            return viewProductoObjetivo;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Creates a new instance of the ART_SeguridadOpcion class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ART_SeguridadOpcionInfo MakeART_SeguridadOpcion(SqlDataReader dataReader)
        {
            ART_SeguridadOpcionInfo aRT_SeguridadOpcion = new ART_SeguridadOpcionInfo();

            if (dataReader.IsDBNull(SeguridadOpcionId) == false)
                aRT_SeguridadOpcion.SeguridadOpcionId = dataReader.GetInt32(SeguridadOpcionId);
            if (dataReader.IsDBNull(CodigoOpcion) == false)
                aRT_SeguridadOpcion.CodigoOpcion = dataReader.GetString(CodigoOpcion);
            if (dataReader.IsDBNull(Descripcion) == false)
                aRT_SeguridadOpcion.Descripcion = dataReader.GetString(Descripcion);
            if (dataReader.IsDBNull(Activo) == false)
                aRT_SeguridadOpcion.Activo = dataReader.GetBoolean(Activo);

            return aRT_SeguridadOpcion;
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Creates a new instance of the ART_SeguridadModulo class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ART_SeguridadModuloInfo MakeART_SeguridadModulo(SqlDataReader dataReader)
        {
            ART_SeguridadModuloInfo aRT_SeguridadModulo = new ART_SeguridadModuloInfo();

            if (dataReader.IsDBNull(SeguridadModuloId) == false)
                aRT_SeguridadModulo.SeguridadModuloId = dataReader.GetInt32(SeguridadModuloId);
            if (dataReader.IsDBNull(DescripcionModulo) == false)
                aRT_SeguridadModulo.DescripcionModulo = dataReader.GetString(DescripcionModulo);
            if (dataReader.IsDBNull(NombreFormulario) == false)
                aRT_SeguridadModulo.NombreFormulario = dataReader.GetString(NombreFormulario);
            if (dataReader.IsDBNull(Activo) == false)
                aRT_SeguridadModulo.Activo = dataReader.GetBoolean(Activo);

            return aRT_SeguridadModulo;
        }
Ejemplo n.º 25
0
        public List <Product> GetProductList()
        {
            List <Product> ProductList  = new List <Product>();
            Dao            dao          = new Dao();
            string         sqlStatement = "SELECT ProductID, ProductName, Price, Quantity, Image, Description, CategoryID FROM Product";

            System.Data.SqlClient.SqlDataReader reader = dao.Get(sqlStatement);
            if (reader == null)
            {
                return(null);
            }
            while (reader.Read())
            {
                try
                {
                    int    id          = reader.GetInt32(0);
                    string name        = reader.GetString(1);
                    double price       = (double)reader.GetDecimal(2);
                    int    quantity    = reader.GetInt32(3);
                    string image       = reader.GetString(4);
                    string description = reader.IsDBNull(5) ? null : reader.GetString(5);
                    int    categoryID  = reader.GetInt32(6);

                    ProductList.Add(new Product(id, name, price, quantity, image, description, categoryID));
                }
                catch (Exception)
                {
                }
            }
            dao.Con.Close();
            return(ProductList);
        }
Ejemplo n.º 26
0
        static Document CreateDocument(SqlDataReader reader, IDictionary<int, List<string>> packageFrameworks)
        {
            var package = new Dictionary<string, string>();
            for (var i = 0; i < reader.FieldCount; i++)
            {
                if (!reader.IsDBNull(i))
                {
                    string name = reader.GetName(i);
                    object obj = reader.GetValue(i);

                    if (name == "key")
                    {
                        var key = (int)obj;
                        List<string> targetFrameworks;
                        if (packageFrameworks.TryGetValue(key, out targetFrameworks))
                        {
                            package.Add("supportedFrameworks", string.Join("|", targetFrameworks));
                        }
                    }

                    var value = (obj is DateTime) ? ((DateTime)obj).ToUniversalTime().ToString("O") : obj.ToString();

                    package.Add(name, value);
                }
            }

            return DocumentCreator.CreateDocument(package);
        }
Ejemplo n.º 27
0
 /** Descripcion:
  *
  * REQ: SqlDataReader,int
  *
  * RET: static int
  */
 public static int SafeGetInt32(SqlDataReader reader, int colIndex)
 {
     if (!reader.IsDBNull(colIndex))
         return reader.GetInt32(colIndex);
     else
         return -1;
 }
 protected override Exception ProcessSqlResult(SqlDataReader reader)
 {
     Exception nextResultSet = StoreUtilities.GetNextResultSet(base.InstancePersistenceCommand.Name, reader);
     if (nextResultSet == null)
     {
         bool flag = !reader.IsDBNull(1);
         TimeSpan? taskIntervalOverride = null;
         bool flag2 = false;
         if (flag)
         {
             DateTime dateTime = reader.GetDateTime(1);
             DateTime time2 = reader.GetDateTime(2);
             if (dateTime <= time2)
             {
                 flag2 = true;
             }
             else
             {
                 taskIntervalOverride = new TimeSpan?(dateTime.Subtract(time2));
             }
         }
         if (flag2)
         {
             base.Store.UpdateEventStatus(true, InstancePersistenceEvent<HasRunnableWorkflowEvent>.Value);
             return nextResultSet;
         }
         base.Store.UpdateEventStatus(false, InstancePersistenceEvent<HasRunnableWorkflowEvent>.Value);
         base.StoreLock.InstanceDetectionTask.ResetTimer(false, taskIntervalOverride);
     }
     return nextResultSet;
 }
Ejemplo n.º 29
0
        /// <summary>
        /// Creates a new instance of the ViewAuditoriaResultado class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewAuditoriaResultadoInfo MakeViewAuditoriaResultado(SqlDataReader dataReader)
        {
            ViewAuditoriaResultadoInfo viewAuditoriaResultado = new ViewAuditoriaResultadoInfo();

            if (dataReader.IsDBNull(AuditoriaResultadoId) == false)
                viewAuditoriaResultado.AuditoriaResultadoId = dataReader.GetInt32(AuditoriaResultadoId);
            if (dataReader.IsDBNull(AuditoriaId) == false)
                viewAuditoriaResultado.AuditoriaId = dataReader.GetInt32(AuditoriaId);
            if (dataReader.IsDBNull(AuditoriaPuntoId) == false)
                viewAuditoriaResultado.AuditoriaPuntoId = dataReader.GetInt32(AuditoriaPuntoId);
            if (dataReader.IsDBNull(AuditoriaControlId) == false)
                viewAuditoriaResultado.AuditoriaControlId = dataReader.GetInt32(AuditoriaControlId);
            if (dataReader.IsDBNull(PuntajeRequerido) == false)
                viewAuditoriaResultado.PuntajeRequerido = dataReader.GetDecimal(PuntajeRequerido);
            if (dataReader.IsDBNull(PuntajeObtenido) == false)
                viewAuditoriaResultado.PuntajeObtenido = dataReader.GetDecimal(PuntajeObtenido);
            if (dataReader.IsDBNull(ResultadoPunto) == false)
                viewAuditoriaResultado.ResultadoPunto = dataReader.GetDecimal(ResultadoPunto);
            if (dataReader.IsDBNull(Control) == false)
                viewAuditoriaResultado.Control = dataReader.GetString(Control);
            if (dataReader.IsDBNull(Punto) == false)
                viewAuditoriaResultado.Punto = dataReader.GetString(Punto);
            if (dataReader.IsDBNull(EsNoConformidad) == false)
                viewAuditoriaResultado.EsNoConformidad = dataReader.GetBoolean(EsNoConformidad);
            if (dataReader.IsDBNull(AuditoriaCausaRaizId) == false)
                viewAuditoriaResultado.AuditoriaCausaRaizId = dataReader.GetInt32(AuditoriaCausaRaizId);
            if (dataReader.IsDBNull(CausaRaiz) == false)
                viewAuditoriaResultado.CausaRaiz = dataReader.GetString(CausaRaiz);
            if (dataReader.IsDBNull(CargoId) == false)
                viewAuditoriaResultado.CargoId = dataReader.GetInt32(CargoId);
            if (dataReader.IsDBNull(PuntajeCargo) == false)
                viewAuditoriaResultado.PuntajeCargo = dataReader.GetDecimal(PuntajeCargo);

            return viewAuditoriaResultado;
        }
Ejemplo n.º 30
0
 /**
  * Descripción: Obtiene el campo fecha de la tabla de forma segura (revisando si es null o no antes de leerlo)
  * Recibe un SqlDataReader con el que se obtiene el campo y el índice de la columna a consultar
  * Devuelve un valor DateTime dependiendo del resultado de la consulta. La fecha actual si el campo está nulo
  */
 public static DateTime SafeGetDate(SqlDataReader reader, int colIndex)
 {
     if (!reader.IsDBNull(colIndex))
         return reader.GetDateTime(colIndex);
     else
         return DateTime.Now;
 }
Ejemplo n.º 31
0
        private Value GetValue(SqlDataReader reader, int column)
        {
            Value value = new Value();

            value.Item = reader.GetValue(column);

            Type type = value.Item.GetType();
            if (reader.IsDBNull(column))
            {
                value.Type = ColumnType.Null;
            }
            else if(typeof(bool).IsAssignableFrom(type))
            {
                value.Type = ColumnType.Boolean;
            }
            else if(typeof(int).IsAssignableFrom(type))
            {
                value.Type = ColumnType.Integer;
            }
            else if (typeof(float).IsAssignableFrom(type) || typeof(double).IsAssignableFrom(type))
            {
                value.Type = ColumnType.Double;
            }
            else if (typeof(byte[]).IsAssignableFrom(type))
            {
                value.Type = ColumnType.Blob;
            }
            else
            {
                value.Type = ColumnType.String;
            }

            return value;
        }
Ejemplo n.º 32
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     db_command.CommandText = "SELECT [id_user], [id_post], [id_point], [guid], [name], [сontact], [login], [password], [permission], [postname], [pointname] FROM [vwUserFull] WHERE [login] = '" + txtLogin.Text + "' AND [password] = '" + txtPassword.Text + "'";
     db_reader = db_command.ExecuteReader();
     if (db_reader.Read())
     {
         this.FormOK = true;
         this.DialogResult = DialogResult.OK;
         usr = new UserInfo();
         if (!db_reader.IsDBNull(0))
             usr.Id_user = Convert.ToInt32(db_reader[0]);
         if (!db_reader.IsDBNull(1))
             usr.Id_point = Convert.ToInt32(db_reader[1]);
         if (!db_reader.IsDBNull(2))
             usr.Id_post = Convert.ToInt32(db_reader[2]);
         if (!db_reader.IsDBNull(3))
             usr.Guid = Convert.ToString(db_reader[3]);
         if (!db_reader.IsDBNull(4))
             usr.Name = Convert.ToString(db_reader[4]);
         if (!db_reader.IsDBNull(5))
             usr.Contact = Convert.ToString(db_reader[5]);
         if (!db_reader.IsDBNull(6))
             usr.Login = Convert.ToString(db_reader[6]);
         if (!db_reader.IsDBNull(7))
             usr.Password = Convert.ToString(db_reader[7]);
         if (!db_reader.IsDBNull(8))
             usr.Permission = Convert.ToInt64(db_reader[8]);
         if (!db_reader.IsDBNull(9))
             usr.Post = Convert.ToString(db_reader[9]);
         if (!db_reader.IsDBNull(10))
             usr.Point = Convert.ToString(db_reader[10]);
         if (!usr.prmCanLogin)
         {
             this.FormOK = false;
             this.DialogResult = DialogResult.Retry;
             MessageBox.Show("Доступ в программу запрещен!", "Вход в программу", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         this.FormOK = false;
         this.DialogResult = DialogResult.Retry;
         MessageBox.Show("Неверный пароль!", "Вход в программу", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     db_reader.Close();
 }
Ejemplo n.º 33
0
        public TList_Empreendimento Select(TpBusca[] vBusca, Int32 vTop, string vNM_Campo)
        {
            bool podeFecharBco         = false;
            TList_Empreendimento lista = new TList_Empreendimento();

            if (Banco_Dados == null)
            {
                this.CriarBanco_Dados(false);
                podeFecharBco = true;
            }
            System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, vTop, vNM_Campo));
            try
            {
                while (reader.Read())
                {
                    TRegistro_Empreendimento reg = new TRegistro_Empreendimento();
                    if (!(reader.IsDBNull(reader.GetOrdinal("ID_Empreendimento"))))
                    {
                        reg.Id_empreendimento = reader.GetDecimal(reader.GetOrdinal("ID_Empreendimento"));
                    }
                    if (!(reader.IsDBNull(reader.GetOrdinal("CD_Empresa"))))
                    {
                        reg.Cd_empresa = reader.GetString(reader.GetOrdinal("CD_Empresa"));
                    }
                    if (!(reader.IsDBNull(reader.GetOrdinal("NM_Empresa"))))
                    {
                        reg.Nm_empresa = reader.GetString(reader.GetOrdinal("NM_Empresa"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DS_Empreendimento")))
                    {
                        reg.Ds_empreendimento = reader.GetString(reader.GetOrdinal("DS_Empreendimento"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DS_Observacao")))
                    {
                        reg.Ds_observacao = reader.GetString(reader.GetOrdinal("DS_Observacao"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DT_IniEmpreendimento")))
                    {
                        reg.Dt_iniempreendimento = reader.GetDateTime(reader.GetOrdinal("DT_IniEmpreendimento"));
                    }
                    if (!(reader.IsDBNull(reader.GetOrdinal("ST_Registro"))))
                    {
                        reg.St_registro = reader.GetString(reader.GetOrdinal("ST_Registro"));
                    }

                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    this.deletarBanco_Dados();
                }
            }
            return(lista);
        }
Ejemplo n.º 34
0
        } //gets string or null when pulling records

        public int GetInt32OrZero(System.Data.SqlClient.SqlDataReader r, int i)
        {
            int rv = 0;

            if (!r.IsDBNull(i))
            {
                rv = r.GetInt32(i);
            }
            return(rv);
        } //gets int or defaults value to '0'
 ///<summary></summary>
 protected override void ReadExecuted(System.Data.SqlClient.SqlDataReader dr)
 {
     if (dr != null && !dr.IsClosed)
     {
         #region Read Each Field
         if (!dr.IsDBNull(dr.GetOrdinal("Code")))
         {
             m_Current.Code = dr.GetString(dr.GetOrdinal("Code"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Value")))
         {
             m_Current.Value = dr.GetString(dr.GetOrdinal("Value"));
         }
         #endregion
         ExistsInDB = true;
         Mode       = EditMode.None;
         SetOriginalValues();
     }
 }
Ejemplo n.º 36
0
        } //gets int or defaults value to '0'

        public DateTime GetDateTimeOrMinValue(System.Data.SqlClient.SqlDataReader r, int i)
        {
            DateTime rv = DateTime.MinValue;

            if (!r.IsDBNull(i))
            {
                rv = r.GetDateTime(i);
            }
            return(rv);
        } //gets the date or sets the minimum value
Ejemplo n.º 37
0
        public bool GetBoolean(System.Data.SqlClient.SqlDataReader r, int i)
        {
            bool rv = true;

            if (!r.IsDBNull(i))
            {
                rv = r.GetBoolean(i);
            }
            return(rv);
        }
Ejemplo n.º 38
0
        public int GetInt32OrZero(System.Data.SqlClient.SqlDataReader r, int i)
        {
            int rv = 0;

            if (!r.IsDBNull(i))
            {
                rv = r.GetInt32(i);
            }
            return(rv);
        }
Ejemplo n.º 39
0
        public string GetStringOrNull(System.Data.SqlClient.SqlDataReader r, int i)
        {
            string rv = null;

            if (!r.IsDBNull(i))
            {
                rv = r.GetString(i);
            }
            return(rv);
        } //gets string or null when pulling records
Ejemplo n.º 40
0
        public TList_LanServico_X_Duplicata Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNM_Campo)
        {
            bool podeFecharBco = false;
            TList_LanServico_X_Duplicata lista = new TList_LanServico_X_Duplicata();

            if (Banco_Dados == null)
            {
                podeFecharBco = this.CriarBanco_Dados(false);
            }
            System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, vTop, vNM_Campo));
            try
            {
                while (reader.Read())
                {
                    TRegistro_LanServico_X_Duplicata reg = new TRegistro_LanServico_X_Duplicata();
                    if (!reader.IsDBNull(reader.GetOrdinal("id_os")))
                    {
                        reg.Id_os = reader.GetDecimal(reader.GetOrdinal("id_os"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("cd_empresa")))
                    {
                        reg.Cd_empresa = reader.GetString(reader.GetOrdinal("cd_empresa"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("nr_lancto")))
                    {
                        reg.Nr_lancto = reader.GetDecimal(reader.GetOrdinal("nr_lancto"));
                    }

                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    this.deletarBanco_Dados();
                }
            }
            return(lista);
        }
Ejemplo n.º 41
0
        public List <Persona> GetAllDocentes()
        {
            List <Persona> listadoPersonas = new List <Persona>();

            try
            {
                this.OpenConnection();
                SqlCommand consulta = new SqlCommand("SELECT id_persona,nombre,apellido,direccion,email,telefono,fecha_nac FROM personas WHERE tipo_persona = 2 ", SqlConn);
                System.Data.SqlClient.SqlDataReader dr = consulta.ExecuteReader();
                while (dr.Read())
                {
                    Persona per = new Persona();
                    per.ID              = Convert.ToInt32(dr[0]);
                    per.Nombre          = dr.IsDBNull(1) ? string.Empty : dr[1].ToString();
                    per.Apellido        = dr.IsDBNull(2) ? string.Empty : dr[2].ToString();
                    per.Direccion       = dr.IsDBNull(3) ? string.Empty : dr[3].ToString();
                    per.Email           = dr.IsDBNull(4) ? string.Empty : dr[4].ToString();
                    per.Telefono        = dr.IsDBNull(5) ? string.Empty : dr[5].ToString();
                    per.FechaNacimiento = Convert.ToDateTime(dr[6]);


                    //per.Legajo = dr.IsDBNull(3) ? string.Empty : dr[3].ToString();
                    //per.Id_Tipo_Persona = dr.IsDBNull(8) ? 0 : Convert.ToInt32(dr[8]);
                    //per.Plan = dr.IsDBNull(9) ? null : PlanAdapter.GetOne(Convert.ToInt32(dr[9]));



                    listadoPersonas.Add(per);
                }
                return(listadoPersonas);
            }
            catch (Exception e)
            {
                Exception ExcepcionManejada = new Exception("Error al tratar de abrir la conexion", e);
                throw ExcepcionManejada;
            }
            finally
            {
                this.CloseConnection();
            }
        }
Ejemplo n.º 42
0
 ///<summary></summary>
 protected override void ReadExecuted(System.Data.SqlClient.SqlDataReader dr)
 {
     if (dr != null && !dr.IsClosed)
     {
         #region Read Each Field
         if (!dr.IsDBNull(dr.GetOrdinal("ImageId")))
         {
             m_Current.ImageId = dr.GetInt32(dr.GetOrdinal("ImageId"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("FileName")))
         {
             m_Current.FileName = dr.GetString(dr.GetOrdinal("FileName"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Extension")))
         {
             m_Current.Extension = dr.GetString(dr.GetOrdinal("Extension"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("ProjectFileDirectory")))
         {
             m_Current.ProjectFileDirectory = dr.GetString(dr.GetOrdinal("ProjectFileDirectory"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Description")))
         {
             m_Current.Description = dr.GetString(dr.GetOrdinal("Description"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Enabled")))
         {
             m_Current.Enabled = dr.GetBoolean(dr.GetOrdinal("Enabled"));
         }
         #endregion
         ExistsInDB = true;
         Mode       = EditMode.None;
         SetOriginalValues();
     }
 }
Ejemplo n.º 43
0
        public TList_Empreendimento_X_LanCCusto Select(TpBusca[] vBusca, Int32 vTop, string vNM_Campo)
        {
            bool podeFecharBco = false;
            TList_Empreendimento_X_LanCCusto lista = new TList_Empreendimento_X_LanCCusto();

            if (Banco_Dados == null)
            {
                this.CriarBanco_Dados(false);
                podeFecharBco = true;
            }
            System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, vTop, vNM_Campo));
            try
            {
                while (reader.Read())
                {
                    TRegistro_Empreendimento_X_lanCCusto reg = new TRegistro_Empreendimento_X_lanCCusto();
                    if (!(reader.IsDBNull(reader.GetOrdinal("ID_Empreendimento"))))
                    {
                        reg.Id_empreendimento = reader.GetDecimal(reader.GetOrdinal("ID_Empreendimento"));
                    }
                    if (!(reader.IsDBNull(reader.GetOrdinal("ID_CCustoLan"))))
                    {
                        reg.Id_ccustolan = reader.GetDecimal(reader.GetOrdinal("ID_CCustoLan"));
                    }

                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    this.deletarBanco_Dados();
                }
            }
            return(lista);
        }
Ejemplo n.º 44
0
        public static void setFieldValue(ref object Variable, string Field, System.Data.SqlClient.SqlDataReader Reader)
        {
            if (!Reader.IsDBNull(Reader.GetOrdinal(Field)))
            {
                Variable = Reader.GetValue(Reader.GetOrdinal(Field));
                if (Variable.GetType().Name == "String")
                {
                    Variable = Variable.ToString().Trim();
                }
                if (Variable.GetType().Name == "DateTime")
                {
                    Variable = Variable.ToString();
                }
            }
            else
            {
                if ((Variable != null))
                {
                    switch (Variable.GetType().Name)
                    {
                    case "Short":
                        Variable = 0;
                        break;

                    case "Double":
                        Variable = 0;
                        break;

                    case "Int64":
                        Variable = 0;
                        break;

                    case "Boolean":
                        Variable = false;
                        break;

                    case "String":
                        Variable = "";
                        break;

                    case "DateTime":
                        Variable = new System.DateTime(1, 1, 1);
                        break;
                    }
                }
                else
                {
                    Variable = "";
                }
            }
        }
Ejemplo n.º 45
0
        private void CreatePLMParameterModes(int plmId, int userId, System.Data.SqlClient.SqlCommand command)
        {
            List <BusinessLogic.Json.PlmParameterModeInfo> modes = new List <BusinessLogic.Json.PlmParameterModeInfo>();

            string sql = "SELECT Id, DefaultHostSpeedId, DefaultPowerId FROM PLMParameterModeType WHERE (Id NOT IN (SELECT Id FROM PLMParameterMode WHERE (PLMId = " + plmId + ")))";

            command.CommandText = sql;
            System.Data.SqlClient.SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                BusinessLogic.Json.PlmParameterModeInfo mode = new Durados.Web.Mvc.Specifics.SanDisk.Allegro.BusinessLogic.Json.PlmParameterModeInfo();
                mode.Id = reader.GetInt32(reader.GetOrdinal("Id"));
                if (!reader.IsDBNull(reader.GetOrdinal("DefaultHostSpeedId")))
                {
                    mode.DefaultHostSpeedId = reader.GetInt32(reader.GetOrdinal("DefaultHostSpeedId"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("DefaultPowerId")))
                {
                    mode.DefaultPowerId = reader.GetInt32(reader.GetOrdinal("DefaultPowerId"));
                }
                modes.Add(mode);
            }

            reader.Close();

            foreach (BusinessLogic.Json.PlmParameterModeInfo mode in modes)
            {
                sql = "insert into PLMParameterMode (PLMId, PLMParameterModeTypeId" + (mode.DefaultHostSpeedId.HasValue ? ",HostSpeedId" : "") + (mode.DefaultPowerId.HasValue ? ",PowerId" : "") + ") values (" + plmId + "," + mode.Id + (mode.DefaultHostSpeedId.HasValue ? "," + mode.DefaultHostSpeedId.Value : "") + (mode.DefaultPowerId.HasValue ? "," + mode.DefaultPowerId.Value : "") + "); SELECT IDENT_CURRENT('[PLMParameterMode]') AS ID";
                command.CommandText = sql;
                int id = Convert.ToInt32(command.ExecuteScalar());

                sql = "insert into durados_ChangeHistory (ViewName, PK, ActionId, UpdateUserId) values ('PLMParameterMode', '" + id + "', 1, " + userId + ")";
                command.CommandText = sql;
                command.ExecuteNonQuery();
            }
        }
Ejemplo n.º 46
0
 ///<summary></summary>
 protected override void ReadExecuted(System.Data.SqlClient.SqlDataReader dr)
 {
     if (dr != null && !dr.IsClosed)
     {
         #region Read Each Field
         if (!dr.IsDBNull(dr.GetOrdinal("Id")))
         {
             m_Current.Id = dr.GetInt32(dr.GetOrdinal("Id"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("UserHostAddress")))
         {
             m_Current.UserHostAddress = dr.GetString(dr.GetOrdinal("UserHostAddress"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Browser")))
         {
             m_Current.Browser = dr.GetString(dr.GetOrdinal("Browser"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("BrowserVersion")))
         {
             m_Current.BrowserVersion = dr.GetString(dr.GetOrdinal("BrowserVersion"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Url")))
         {
             m_Current.Url = dr.GetString(dr.GetOrdinal("Url"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("UserAgent")))
         {
             m_Current.UserAgent = dr.GetString(dr.GetOrdinal("UserAgent"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("AccessTime")))
         {
             m_Current.AccessTime = dr.GetDateTime(dr.GetOrdinal("AccessTime"));
         }
         #endregion
         ExistsInDB = true;
         Mode       = EditMode.None;
         SetOriginalValues();
     }
 }
Ejemplo n.º 47
0
        /// <summary>
        ///     Populate a <see cref="QueryResult"/> with result-sets from the specified <see cref="SqlClient.SqlDataReader"/>.
        /// </summary>
        /// <param name="reader">
        ///     The <see cref="SqlClient.SqlDataReader"/> to read from.
        /// </param>
        /// <param name="queryResult">
        ///     The <see cref="QueryResult"/> to populate.
        /// </param>
        /// <returns>
        ///     A <see cref="Task"/> representing the operation.
        /// </returns>
        async Task ReadResults(SqlClient.SqlDataReader reader, QueryResult queryResult)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            if (queryResult == null)
            {
                throw new ArgumentNullException(nameof(queryResult));
            }

            ResultSet resultSet = new ResultSet();

            queryResult.ResultSets.Add(resultSet);
            while (await reader.ReadAsync())
            {
                var row = new ResultRow();
                resultSet.Rows.Add(row);

                for (int fieldIndex = 0; fieldIndex < reader.FieldCount; fieldIndex++)
                {
                    string fieldName = reader.GetName(fieldIndex);
                    if (!reader.IsDBNull(fieldIndex))
                    {
                        row.Columns[fieldName] = new JValue(
                            reader.GetValue(fieldIndex)
                            );
                    }
                    else
                    {
                        row.Columns[fieldName] = null;
                    }
                }
            }
        }
Ejemplo n.º 48
0
        public TList_Plantio_X_Talhoes Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNm_Campo)
        {
            TList_Plantio_X_Talhoes lista = new TList_Plantio_X_Talhoes();

            System.Data.SqlClient.SqlDataReader reader = null;
            bool podeFecharBco = false;

            if (Banco_Dados == null)
            {
                podeFecharBco = this.CriarBanco_Dados(false);
            }
            try
            {
                reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNm_Campo));
                while (reader.Read())
                {
                    TRegistro_Plantio_X_Talhoes reg = new TRegistro_Plantio_X_Talhoes();

                    if (!reader.IsDBNull(reader.GetOrdinal("Id_Plantio")))
                    {
                        reg.Id_plantio = reader.GetDecimal(reader.GetOrdinal("Id_Plantio"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("ID_Talhao")))
                    {
                        reg.Id_talhao = reader.GetDecimal(reader.GetOrdinal("ID_Talhao"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DS_Talhao")))
                    {
                        reg.Ds_talhao = reader.GetString(reader.GetOrdinal("DS_Talhao"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("area_talhao")))
                    {
                        reg.Area_talhao = reader.GetDecimal(reader.GetOrdinal("area_talhao"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("ID_Area")))
                    {
                        reg.Id_area = reader.GetDecimal(reader.GetOrdinal("ID_Area"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DS_Area")))
                    {
                        reg.Ds_area = reader.GetString(reader.GetOrdinal("DS_Area"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("CD_Fazenda")))
                    {
                        reg.Cd_fazenda = reader.GetString(reader.GetOrdinal("CD_Fazenda"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("NM_Fazenda")))
                    {
                        reg.Nm_fazenda = reader.GetString(reader.GetOrdinal("NM_Fazenda"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("sigla_unidade")))
                    {
                        reg.Sigla_unidade = reader.GetString(reader.GetOrdinal("sigla_unidade"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("Area_Plantada")))
                    {
                        reg.Area_plantada = reader.GetDecimal(reader.GetOrdinal("Area_Plantada"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("producao_prevista")))
                    {
                        reg.Producao_prevista = reader.GetDecimal(reader.GetOrdinal("producao_prevista"));
                    }

                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    this.deletarBanco_Dados();
                }
            }
            return(lista);
        }
Ejemplo n.º 49
0
 ///<summary></summary>
 protected override void ReadExecuted(System.Data.SqlClient.SqlDataReader dr)
 {
     if (dr != null && !dr.IsClosed)
     {
         #region Read Each Field
         if (!dr.IsDBNull(dr.GetOrdinal("Id")))
         {
             m_Current.Id = dr.GetInt32(dr.GetOrdinal("Id"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Title")))
         {
             m_Current.Title = dr.GetString(dr.GetOrdinal("Title"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Body")))
         {
             m_Current.Body = dr.GetString(dr.GetOrdinal("Body"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("ShortDesc")))
         {
             m_Current.ShortDesc = dr.GetString(dr.GetOrdinal("ShortDesc"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Description")))
         {
             m_Current.Description = dr.GetString(dr.GetOrdinal("Description"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Meta")))
         {
             m_Current.Meta = dr.GetString(dr.GetOrdinal("Meta"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("UrlSlug")))
         {
             m_Current.UrlSlug = dr.GetString(dr.GetOrdinal("UrlSlug"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Published")))
         {
             m_Current.Published = dr.GetBoolean(dr.GetOrdinal("Published"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("PostedOn")))
         {
             m_Current.PostedOn = dr.GetDateTime(dr.GetOrdinal("PostedOn"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Modified")))
         {
             m_Current.Modified = dr.GetDateTime(dr.GetOrdinal("Modified"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Category")))
         {
             m_Current.Category = dr.GetString(dr.GetOrdinal("Category"));
         }
         if (!dr.IsDBNull(dr.GetOrdinal("Enabled")))
         {
             m_Current.Enabled = dr.GetBoolean(dr.GetOrdinal("Enabled"));
         }
         #endregion
         ExistsInDB = true;
         Mode       = EditMode.None;
         SetOriginalValues();
     }
 }
Ejemplo n.º 50
0
        private int ReadBytes(byte[] buffer, int offset, int count)
        {
            bool gotData  = true;
            int  intCount = 0;
            int  cb       = 0;

            if (_reader.IsClosed || _endOfColumn)
            {
                return(0);
            }
            try {
                while (count > 0)
                {
                    // if I haven't read any bytes, get the next row
                    if (_advanceReader && (0 == _bytesCol))
                    {
                        gotData = false;

                        if (_readFirstRow && !_processAllRows)
                        {
                            // for XML column, stop processing after the first row
                            // no op here - reader is closed after the end of this loop
                        }
                        else if (AdvanceToNextRow(_reader))
                        {
                            _readFirstRow = true;

                            if (_reader.IsDBNull(_columnOrdinal))
                            {
                                // VSTFDEVDIV 479659: handle row with DBNULL as empty data
                                // for XML column, processing is stopped on the next loop since _readFirstRow is true
                                continue;
                            }

                            // the value is not null, read it
                            gotData = true;
                        }
                        // else AdvanceToNextRow has returned false - no more rows or result sets remained, stop processing
                    }

                    if (gotData)
                    {
                        cb = (int)_reader.GetBytesInternal(_columnOrdinal, _bytesCol, buffer, offset, count);

                        if (cb < count)
                        {
                            _bytesCol = 0;
                            gotData   = false;
                            if (!_advanceReader)
                            {
                                _endOfColumn = true;
                            }
                        }
                        else
                        {
                            Debug.Assert(cb == count);
                            _bytesCol += cb;
                        }

                        // we are guaranteed that cb is < Int32.Max since we always pass in count which is of type Int32 to
                        // our getbytes interface
                        count    -= (int)cb;
                        offset   += (int)cb;
                        intCount += (int)cb;
                    }
                    else
                    {
                        break; // no more data available, we are done
                    }
                }
                if (!gotData && _advanceReader)
                {
                    _reader.Close();    // Need to close the reader if we are done reading
                }
            }
            catch (Exception e) {
                if (_advanceReader && ADP.IsCatchableExceptionType(e))
                {
                    _reader.Close();
                }
                throw;
            }

            return(intCount);
        }
Ejemplo n.º 51
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <returns>[To be supplied.]</returns>
        public bool Refresh()
        {
            this.displayName = null;

            this.col_TitleWasUpdated = false;
            this.col_TitleWasSet     = false;
            this.col_Title           = System.Data.SqlTypes.SqlString.Null;

            bool alreadyOpened = false;

            Params.spS_Title Param = new Params.spS_Title(true);
            Param.CommandTimeOut = this.selectCommandTimeOut;
            switch (this.lastKnownConnectionType)
            {
            case Bob.DataClasses.ConnectionType.ConnectionString:
                Param.SetUpConnection(this.connectionString);
                break;

            case Bob.DataClasses.ConnectionType.SqlConnection:
                Param.SetUpConnection(this.sqlConnection);
                alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open);
                break;

            case Bob.DataClasses.ConnectionType.SqlTransaction:
                Param.SetUpConnection(this.sqlTransaction);
                break;
            }

            if (!this.col_TitleId.IsNull)
            {
                Param.Param_TitleId = this.col_TitleId;
            }


            System.Data.SqlClient.SqlDataReader sqlDataReader = null;
            SPs.spS_Title Sp = new SPs.spS_Title(false);
            if (Sp.Execute(ref Param, out sqlDataReader))
            {
                if (sqlDataReader.Read())
                {
                    if (!sqlDataReader.IsDBNull(SPs.spS_Title.Resultset1.Fields.Column_Title.ColumnIndex))
                    {
                        this.col_Title = sqlDataReader.GetSqlString(SPs.spS_Title.Resultset1.Fields.Column_Title.ColumnIndex);
                    }

                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    this.recordIsLoaded = true;

                    return(true);
                }
                else
                {
                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    this.recordIsLoaded = false;

                    return(false);
                }
            }
            else
            {
                if (sqlDataReader != null && !sqlDataReader.IsClosed)
                {
                    sqlDataReader.Close();
                }

                CloseConnection(Sp.Connection, alreadyOpened);

                throw new Bob.DataClasses.CustomException(Param, "Bob.BusinessComponents.Title", "Refresh");
            }
        }
Ejemplo n.º 52
0
        public TList_Plantio Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNm_Campo)
        {
            TList_Plantio lista = new TList_Plantio();

            System.Data.SqlClient.SqlDataReader reader = null;
            bool podeFecharBco = false;

            if (Banco_Dados == null)
            {
                podeFecharBco = this.CriarBanco_Dados(false);
            }
            try
            {
                reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNm_Campo));
                while (reader.Read())
                {
                    TRegistro_Plantio reg = new TRegistro_Plantio();

                    if (!reader.IsDBNull(reader.GetOrdinal("Id_Plantio")))
                    {
                        reg.Id_plantio = reader.GetDecimal(reader.GetOrdinal("Id_Plantio"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("id_cultura")))
                    {
                        reg.Id_cultura = reader.GetDecimal(reader.GetOrdinal("id_cultura"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("ds_cultura")))
                    {
                        reg.Ds_cultura = reader.GetString(reader.GetOrdinal("ds_cultura"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("sigla_unidade")))
                    {
                        reg.Sigla_unidade = reader.GetString(reader.GetOrdinal("sigla_unidade"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("cd_produto")))
                    {
                        reg.Cd_produto = reader.GetString(reader.GetOrdinal("cd_produto"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("ds_produto")))
                    {
                        reg.Ds_produto = reader.GetString(reader.GetOrdinal("ds_produto"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DS_Observacao")))
                    {
                        reg.Ds_observacao = reader.GetString(reader.GetOrdinal("DS_Observacao"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("AnoSafra")))
                    {
                        reg.Anosafra = reader.GetString(reader.GetOrdinal("AnoSafra"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DS_Safra")))
                    {
                        reg.Ds_safra = reader.GetString(reader.GetOrdinal("DS_Safra"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DT_IniPlantio")))
                    {
                        reg.Dt_iniplantio = reader.GetDateTime(reader.GetOrdinal("DT_IniPlantio"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DT_FinPlantio")))
                    {
                        reg.Dt_finplantio = reader.GetDateTime(reader.GetOrdinal("DT_FinPlantio"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("QT_SementesPorMetro")))
                    {
                        reg.Qt_sementespormetro = reader.GetDecimal(reader.GetOrdinal("QT_SementesPorMetro"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("EspacoSemente")))
                    {
                        reg.Espacosemente = reader.GetDecimal(reader.GetOrdinal("EspacoSemente"));
                    }

                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    this.deletarBanco_Dados();
                }
            }
            return(lista);
        }
Ejemplo n.º 53
0
        void FillBirthAndDeathDates()
        {
            if (Persons.Count == 0)
            {
                // Nothing to do here.
                return;
            }

            // Craft query for all the persons.
            //
            using (var connection = new QC.SqlConnection(GetConnectionString(HomeController.DefaultProviderName)))
            {
                connection.Open();
                using (var command = new QC.SqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandType = DT.CommandType.Text;
                    // This shouldn't be done like this.
                    command.CommandText =
                        "SELECT name, birth_date, death_date FROM persons WHERE name IN ("
                        + string.Join(", ", Persons.Keys.Select(p => "'" + p.Replace("'", "''") + "'").ToArray()) + ")";

                    QC.SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        Person person = Persons[reader.GetString(0)];

                        string birthDateStringRaw = null;
                        string deathDateStringRaw = null;

                        if (!reader.IsDBNull(1))
                        {
                            birthDateStringRaw = reader.GetString(1);
                        }

                        if (!reader.IsDBNull(2))
                        {
                            deathDateStringRaw = reader.GetString(2);
                        }

                        // TODO: Need better logic for handling BC dates.
                        Action <string, Action <DateTime> > fillDate = (inputRaw, setter) =>
                        {
                            if (inputRaw != null)
                            {
                                DateTime dt;

                                // Try to extract something useful from date strings.
                                if (DateTime.TryParse(inputRaw, out dt) || DateTime.TryParse(inputRaw.Replace("\"", ""), out dt))
                                {
                                    setter(dt);
                                }
                                else
                                {
                                    int year;
                                    if (Int32.TryParse(inputRaw.Replace("\"", ""), out year))
                                    {
                                        dt = new DateTime(year, 1, 1);
                                        setter(dt);
                                    }
                                }
                            }
                        };

                        fillDate(birthDateStringRaw, (dt) => person.BirthDate = dt);
                        fillDate(deathDateStringRaw, (dt) => person.DeathDate = dt);
                    }
                }
            }
        }
Ejemplo n.º 54
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <returns>[To be supplied.]</returns>
        public bool Refresh()
        {
            this.displayName = null;

            this.col_JobIdWasUpdated = false;
            this.col_JobIdWasSet     = false;
            this.col_JobId           = System.Data.SqlTypes.SqlInt32.Null;

            this.col_DescriptionWasUpdated = false;
            this.col_DescriptionWasSet     = false;
            this.col_Description           = System.Data.SqlTypes.SqlString.Null;

            this.col_JobPartTypeIdWasUpdated = false;
            this.col_JobPartTypeIdWasSet     = false;
            this.col_JobPartTypeId           = System.Data.SqlTypes.SqlInt32.Null;

            this.col_UnitsWasUpdated = false;
            this.col_UnitsWasSet     = false;
            this.col_Units           = System.Data.SqlTypes.SqlDecimal.Null;

            this.col_PricePerUnitWasUpdated = false;
            this.col_PricePerUnitWasSet     = false;
            this.col_PricePerUnit           = System.Data.SqlTypes.SqlMoney.Null;

            this.col_TotalPriceWasUpdated = false;
            this.col_TotalPriceWasSet     = false;
            this.col_TotalPrice           = System.Data.SqlTypes.SqlMoney.Null;

            bool alreadyOpened = false;

            Params.spS_JobPart Param = new Params.spS_JobPart(true);
            Param.CommandTimeOut = this.selectCommandTimeOut;
            switch (this.lastKnownConnectionType)
            {
            case Bob.DataClasses.ConnectionType.ConnectionString:
                Param.SetUpConnection(this.connectionString);
                break;

            case Bob.DataClasses.ConnectionType.SqlConnection:
                Param.SetUpConnection(this.sqlConnection);
                alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open);
                break;

            case Bob.DataClasses.ConnectionType.SqlTransaction:
                Param.SetUpConnection(this.sqlTransaction);
                break;
            }

            if (!this.col_JobPartId.IsNull)
            {
                Param.Param_JobPartId = this.col_JobPartId;
            }


            System.Data.SqlClient.SqlDataReader sqlDataReader = null;
            SPs.spS_JobPart Sp = new SPs.spS_JobPart(false);
            if (Sp.Execute(ref Param, out sqlDataReader))
            {
                if (sqlDataReader.Read())
                {
                    if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_JobId.ColumnIndex))
                    {
                        this.col_JobId = sqlDataReader.GetSqlInt32(SPs.spS_JobPart.Resultset1.Fields.Column_JobId.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_Description.ColumnIndex))
                    {
                        this.col_Description = sqlDataReader.GetSqlString(SPs.spS_JobPart.Resultset1.Fields.Column_Description.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_JobPartTypeId.ColumnIndex))
                    {
                        this.col_JobPartTypeId = sqlDataReader.GetSqlInt32(SPs.spS_JobPart.Resultset1.Fields.Column_JobPartTypeId.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_Units.ColumnIndex))
                    {
                        this.col_Units = sqlDataReader.GetSqlDecimal(SPs.spS_JobPart.Resultset1.Fields.Column_Units.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_PricePerUnit.ColumnIndex))
                    {
                        this.col_PricePerUnit = sqlDataReader.GetSqlMoney(SPs.spS_JobPart.Resultset1.Fields.Column_PricePerUnit.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_TotalPrice.ColumnIndex))
                    {
                        this.col_TotalPrice = sqlDataReader.GetSqlMoney(SPs.spS_JobPart.Resultset1.Fields.Column_TotalPrice.ColumnIndex);
                    }

                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    this.recordIsLoaded = true;

                    return(true);
                }
                else
                {
                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    this.recordIsLoaded = false;

                    return(false);
                }
            }
            else
            {
                if (sqlDataReader != null && !sqlDataReader.IsClosed)
                {
                    sqlDataReader.Close();
                }

                CloseConnection(Sp.Connection, alreadyOpened);

                throw new Bob.DataClasses.CustomException(Param, "Bob.BusinessComponents.JobPart_Record", "Refresh");
            }
        }
Ejemplo n.º 55
0
    protected void LoginButton_Click(object sender, EventArgs e)
    {
        String connectionString = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;

        System.Data.SqlClient.SqlConnection sql = new System.Data.SqlClient.SqlConnection(connectionString);

        sql.Open();
        System.Data.SqlClient.SqlCommand query = new System.Data.SqlClient.SqlCommand();
        query.Connection = sql;

        //query to grab the password of the username entered in
        query.CommandText = "SELECT DISTINCT dbo.Password.PasswordHash FROM dbo.Password INNER JOIN  " +
                            "dbo.UserEntity ON dbo.Password.UserEntityID = dbo.UserEntity.UserEntityID where upper(username) = upper(@userName)";

        query.Parameters.AddWithValue("@userName", HttpUtility.HtmlEncode(username.Value));

        System.Data.SqlClient.SqlDataReader reader = query.ExecuteReader();


        String storedPassword = "******";

        while (reader.Read())
        {
            //Lazy way to handle null usernames.
            if (reader.IsDBNull(0))
            {
                storedPassword = "******";
            }
            else
            {
                storedPassword = reader.GetString(0);
            }
        }
        sql.Close();
        reader.Close();

        //method to validate if password in hashed textbox matches our hashed password in the DB
        if (PasswordHash.ValidatePassword(password.Value, storedPassword))
        {
            Label10.Text = "Success!";
            String permissions = " ";
            int    school      = 0;

            sql.Open();
            System.Data.SqlClient.SqlCommand query1 = new System.Data.SqlClient.SqlCommand();

            query1.Connection  = sql;
            query1.CommandText = "SELECT dbo.UserEntity.UserEntityID from dbo.userentity where upper(username) like upper(@userName1)";

            query1.Parameters.AddWithValue("@userName1", HttpUtility.HtmlEncode(username.Value));
            System.Data.SqlClient.SqlDataReader reader1 = query1.ExecuteReader();
            int id = 0;
            while (reader1.Read())
            {
                if (reader1.IsDBNull(0))
                {
                    username.Value = "null";
                }


                else
                {
                    id = reader1.GetInt32(0);
                }
            }

            query1.CommandText = "SELECT dbo.SchoolEmployee.SchoolEmployeeEntityType from dbo.schoolemployee where SchoolEmployeeEntityID = @SchoolEmployeeEntityID";
            query1.Parameters.AddWithValue("@SchoolEmployeeEntityID", id);
            reader1.Close();
            System.Data.SqlClient.SqlDataReader reader2 = query1.ExecuteReader();
            while (reader2.Read())
            {
                if (reader2.IsDBNull(0))
                {
                    username.Value = "null";
                }


                else
                {
                    permissions = reader2.GetString(0);
                }
            }



            int    schoolEntityId = 0;
            String schoolName     = "";
            String schoolCounty   = "";
            int    userEntityID   = 0;

            query1.CommandText = "SELECT School.SchoolEntityID, School.SchoolName, School.SchoolCounty, SchoolEmployee.SchoolEmployeeEntityID FROM School INNER JOIN SchoolEmployee ON School.SchoolEntityID = SchoolEmployee.SchoolEntityID" +
                                 " where SchoolEmployeeEntityID = @userEntityID";
            query1.Parameters.AddWithValue("@userEntityID", id);
            reader2.Close();
            System.Data.SqlClient.SqlDataReader reader3 = query1.ExecuteReader();
            while (reader3.Read())

            {
                schoolEntityId = reader3.GetInt32(0);
                schoolName     = reader3.GetString(1);
                schoolCounty   = reader3.GetString(2);
                userEntityID   = reader3.GetInt32(3);
            }

            query1.CommandText = "SELECT dbo.SchoolEmployee.SchoolentityID from dbo.schoolemployee where SchoolEmployeeEntityID = @SchoolEmployeeEntityID1";
            query1.Parameters.AddWithValue("@SchoolEmployeeEntityID1", id);
            reader3.Close();
            System.Data.SqlClient.SqlDataReader reader4 = query1.ExecuteReader();
            while (reader4.Read())
            {
                if (reader4.IsDBNull(0))
                {
                    school = 0;
                }


                else
                {
                    school = reader4.GetInt32(0);
                }
            }


            Session["schoolID"]   = schoolEntityId;
            Session["userCounty"] = schoolCounty;
            Session["schoolName"] = schoolName;
            Session["EntityID"]   = userEntityID;


            //Test the permsissions
            if (permissions.Equals("Admin"))
            {
                Session["user"]       = username.Value;
                Session["permission"] = permissions;

                Session["schoolid"] = school;
                Response.Redirect("LandingPage.aspx");
            }
            else if (permissions.Equals("Counselor"))
            {
                Session["user"]       = username.Value;
                Session["permission"] = permissions;
                Session["schoolid"]   = school;
                Response.Redirect("CounselorLandingPage.aspx");
            }
            else if (permissions.Equals("Teacher"))
            {
                Session["user"]       = username.Value;
                Session["permission"] = permissions;
                Session["schoolid"]   = school;
                Response.Redirect("TeacherLandingPage.aspx");
            }
        }
        else
        {
            Label10.Text = "Your username or password is incorrect, please try again.";

            username.Value = "";
            password.Value = "";
        }
    }
Ejemplo n.º 56
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <returns>[To be supplied.]</returns>
        public bool Refresh()
        {
            this.displayName = null;

            this.col_Ord_DatOrderedOnWasUpdated = false;
            this.col_Ord_DatOrderedOnWasSet     = false;
            this.col_Ord_DatOrderedOn           = System.Data.SqlTypes.SqlDateTime.Null;

            this.col_Ord_LngCustomerIDWasUpdated = false;
            this.col_Ord_LngCustomerIDWasSet     = false;
            this.col_Ord_LngCustomerID           = System.Data.SqlTypes.SqlInt32.Null;

            this.col_Ord_CurTotalWasUpdated = false;
            this.col_Ord_CurTotalWasSet     = false;
            this.col_Ord_CurTotal           = System.Data.SqlTypes.SqlMoney.Null;

            bool alreadyOpened = false;

            Params.spS_tblOrder Param = new Params.spS_tblOrder(true);
            Param.CommandTimeOut = this.selectCommandTimeOut;
            switch (this.lastKnownConnectionType)
            {
            case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                Param.SetUpConnection(this.connectionString);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                Param.SetUpConnection(this.sqlConnection);
                alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction:
                Param.SetUpConnection(this.sqlTransaction);
                break;
            }

            if (!this.col_Ord_GuidID.IsNull)
            {
                Param.Param_Ord_GuidID = this.col_Ord_GuidID;
            }


            System.Data.SqlClient.SqlDataReader sqlDataReader = null;
            SPs.spS_tblOrder Sp = new SPs.spS_tblOrder(false);
            if (Sp.Execute(ref Param, out sqlDataReader))
            {
                if (sqlDataReader.Read())
                {
                    if (!sqlDataReader.IsDBNull(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_DatOrderedOn.ColumnIndex))
                    {
                        this.col_Ord_DatOrderedOn = sqlDataReader.GetSqlDateTime(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_DatOrderedOn.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_LngCustomerID.ColumnIndex))
                    {
                        this.col_Ord_LngCustomerID = sqlDataReader.GetSqlInt32(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_LngCustomerID.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_CurTotal.ColumnIndex))
                    {
                        this.col_Ord_CurTotal = sqlDataReader.GetSqlMoney(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_CurTotal.ColumnIndex);
                    }

                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    this.recordIsLoaded = true;

                    return(true);
                }
                else
                {
                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    this.recordIsLoaded = false;

                    return(false);
                }
            }
            else
            {
                if (sqlDataReader != null && !sqlDataReader.IsClosed)
                {
                    sqlDataReader.Close();
                }

                CloseConnection(Sp.Connection, alreadyOpened);

                throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.tblOrder_Record", "Refresh");
            }
        }
Ejemplo n.º 57
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <returns>[To be supplied.]</returns>
        public bool Refresh()
        {
            this.displayName = null;

            this.col_CompanyNameWasUpdated = false;
            this.col_CompanyNameWasSet     = false;
            this.col_CompanyName           = System.Data.SqlTypes.SqlString.Null;

            this.col_ContactNameWasUpdated = false;
            this.col_ContactNameWasSet     = false;
            this.col_ContactName           = System.Data.SqlTypes.SqlString.Null;

            this.col_TitleIdWasUpdated = false;
            this.col_TitleIdWasSet     = false;
            this.col_TitleId           = System.Data.SqlTypes.SqlInt32.Null;

            this.col_AddressWasUpdated = false;
            this.col_AddressWasSet     = false;
            this.col_Address           = System.Data.SqlTypes.SqlString.Null;

            this.col_CityWasUpdated = false;
            this.col_CityWasSet     = false;
            this.col_City           = System.Data.SqlTypes.SqlString.Null;

            this.col_PostalCodeWasUpdated = false;
            this.col_PostalCodeWasSet     = false;
            this.col_PostalCode           = System.Data.SqlTypes.SqlString.Null;

            this.col_PhoneWasUpdated = false;
            this.col_PhoneWasSet     = false;
            this.col_Phone           = System.Data.SqlTypes.SqlString.Null;

            this.col_EmailWasUpdated = false;
            this.col_EmailWasSet     = false;
            this.col_Email           = System.Data.SqlTypes.SqlString.Null;

            this.col_WebAddressWasUpdated = false;
            this.col_WebAddressWasSet     = false;
            this.col_WebAddress           = System.Data.SqlTypes.SqlString.Null;

            this.col_FaxWasUpdated = false;
            this.col_FaxWasSet     = false;
            this.col_Fax           = System.Data.SqlTypes.SqlString.Null;

            this.col_ActiveWasUpdated = false;
            this.col_ActiveWasSet     = false;
            this.col_Active           = System.Data.SqlTypes.SqlBoolean.Null;

            bool alreadyOpened = false;

            Params.spS_Customers Param = new Params.spS_Customers(true);
            Param.CommandTimeOut = this.selectCommandTimeOut;
            switch (this.lastKnownConnectionType)
            {
            case Bob.DataClasses.ConnectionType.ConnectionString:
                Param.SetUpConnection(this.connectionString);
                break;

            case Bob.DataClasses.ConnectionType.SqlConnection:
                Param.SetUpConnection(this.sqlConnection);
                alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open);
                break;

            case Bob.DataClasses.ConnectionType.SqlTransaction:
                Param.SetUpConnection(this.sqlTransaction);
                break;
            }

            if (!this.col_CustomerID.IsNull)
            {
                Param.Param_CustomerID = this.col_CustomerID;
            }


            System.Data.SqlClient.SqlDataReader sqlDataReader = null;
            SPs.spS_Customers Sp = new SPs.spS_Customers(false);
            if (Sp.Execute(ref Param, out sqlDataReader))
            {
                if (sqlDataReader.Read())
                {
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_CompanyName.ColumnIndex))
                    {
                        this.col_CompanyName = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_CompanyName.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_ContactName.ColumnIndex))
                    {
                        this.col_ContactName = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_ContactName.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_TitleId.ColumnIndex))
                    {
                        this.col_TitleId = sqlDataReader.GetSqlInt32(SPs.spS_Customers.Resultset1.Fields.Column_TitleId.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Address.ColumnIndex))
                    {
                        this.col_Address = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Address.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_City.ColumnIndex))
                    {
                        this.col_City = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_City.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_PostalCode.ColumnIndex))
                    {
                        this.col_PostalCode = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_PostalCode.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Phone.ColumnIndex))
                    {
                        this.col_Phone = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Phone.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Email.ColumnIndex))
                    {
                        this.col_Email = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Email.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_WebAddress.ColumnIndex))
                    {
                        this.col_WebAddress = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_WebAddress.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Fax.ColumnIndex))
                    {
                        this.col_Fax = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Fax.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Active.ColumnIndex))
                    {
                        this.col_Active = sqlDataReader.GetSqlBoolean(SPs.spS_Customers.Resultset1.Fields.Column_Active.ColumnIndex);
                    }

                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    this.recordIsLoaded = true;

                    return(true);
                }
                else
                {
                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    this.recordIsLoaded = false;

                    return(false);
                }
            }
            else
            {
                if (sqlDataReader != null && !sqlDataReader.IsClosed)
                {
                    sqlDataReader.Close();
                }

                CloseConnection(Sp.Connection, alreadyOpened);

                throw new Bob.DataClasses.CustomException(Param, "Bob.BusinessComponents.Customer", "Refresh");
            }
        }
        } //  GetLayerSourceInfo()

        public PDX.BTS.DataMaintenance.MaintTools.FeatureClassSourceInfo GetLayerSourceInfo(string FeatureClassName, string OutputGeodatabaseName)
        {
            System.Data.SqlClient.SqlCommand    getSourceInfoSQLCommand    = null;
            System.Data.SqlClient.SqlDataReader getSourceInfoSQLDataReader = null;
            ESRI.ArcGIS.esriSystem.IPropertySet sourcePropertySet          = null;
            PDX.BTS.DataMaintenance.MaintTools.GeneralUtilities      maintenanceGeneralUtilities = null;
            PDX.BTS.DataMaintenance.MaintTools.PathManager           shapefilePathGenerator      = null;
            PDX.BTS.DataMaintenance.MaintTools.FeatureClassUtilities featureClassUtilities       = null;

            try
            {
                //  Make sure there is a valid connection to the Load Metadata Database before attempting to update it.
                if (!ConnecttoImportMonitorDatabase())
                {
                    //  Send a Message to the calling application to let the user know why this process failed.
                    if (ErrorMessage != null)
                    {
                        ErrorMessage("     Could not establish a connection to the Load Metadata Database!  LoaderUtilities.DatabaseTools.GetLayerSourceInfo() Failed!");
                    }

                    //  Return a NULL String to the calling routine to indicate that this process failed.
                    return(null);
                }


                //  Build the SQL Statement that will be used to retrieve the Source Information for the Feature Class.
                string getSourceInfoSQLStatement = "SELECT [Load_Source], [Data_Source], [Dataset], [GeoDB_File], [Source_Server_Name],"
                                                   + "       [Source_Instance], [Source_Database_Name], [Source_Database_User_Name],"
                                                   + "       [Input_Dataset_Name], [Output_Database] "
                                                   + "FROM " + _monitorTableName + " "
                                                   + "WHERE [Feature_Class_Name] = '" + FeatureClassName + "'";


                //  If the Output Geodatabase Name was passed to this method, include it in the query.
                if (!System.String.IsNullOrEmpty(OutputGeodatabaseName))
                {
                    //  Add the Output Geodatabase Name to the SQL Statement.
                    getSourceInfoSQLStatement = getSourceInfoSQLStatement + " AND [Output_Database] = '" + OutputGeodatabaseName + "'";
                }


                //  Build the SQL Command Object that will be used to retrieve the Source Data Info for the specified Feature Class.
                getSourceInfoSQLCommand                = new System.Data.SqlClient.SqlCommand();
                getSourceInfoSQLCommand.Connection     = _importMonitorDatabaseConnection;
                getSourceInfoSQLCommand.CommandType    = System.Data.CommandType.Text;
                getSourceInfoSQLCommand.CommandText    = getSourceInfoSQLStatement;
                getSourceInfoSQLCommand.CommandTimeout = 30;


                //  Use the SQL Command Object that was just instantiated to populate a SQL Data Reader Object with the info about the specified
                //  Feature Class.
                getSourceInfoSQLDataReader = getSourceInfoSQLCommand.ExecuteReader();


                //  Instantiate a Feature Class Source Info Object.
                PDX.BTS.DataMaintenance.MaintTools.FeatureClassSourceInfo currentFeatureClassSourceInfo = new PDX.BTS.DataMaintenance.MaintTools.FeatureClassSourceInfo();

                //  If some information was retrieved, populate a Feature Class Source Info Object and return it to the calling method.  If not,
                //  return a NULL Pointer to indicate that this method failed.
                if (getSourceInfoSQLDataReader.HasRows)
                {
                    if (getSourceInfoSQLDataReader.Read())
                    {
                        //  Populate the New Feature Class Source Info Object with the Source Info for the specified Feature Class.
                        //  Populate the Source Type Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Load_Source")))
                        {
                            currentFeatureClassSourceInfo.SourceType = (string)getSourceInfoSQLDataReader["Load_Source"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceType = "";
                        }
                        //  Populate the Source Data Share Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Data_Source")))
                        {
                            currentFeatureClassSourceInfo.SourceDataShare = (string)getSourceInfoSQLDataReader["Data_Source"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceDataShare = "";
                        }
                        //  Populate the Source Dataset Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Dataset")))
                        {
                            currentFeatureClassSourceInfo.SourceDataset = (string)getSourceInfoSQLDataReader["Dataset"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceDataset = "";
                        }
                        //  Populate the Source Geodatabase File Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("GeoDB_File")))
                        {
                            currentFeatureClassSourceInfo.SourceGeoDBFile = (string)getSourceInfoSQLDataReader["GeoDB_File"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceGeoDBFile = "";
                        }
                        //  Populate the Source Server Name Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Source_Server_Name")))
                        {
                            currentFeatureClassSourceInfo.SourceServerName = (string)getSourceInfoSQLDataReader["Source_Server_Name"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceServerName = "";
                        }
                        //  Populate the Source Instance Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Source_Instance")))
                        {
                            currentFeatureClassSourceInfo.SourceInstance = (string)getSourceInfoSQLDataReader["Source_Instance"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceInstance = "";
                        }
                        //  Populate the Source Database Name Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Source_Database_Name")))
                        {
                            currentFeatureClassSourceInfo.SourceDatabaseName = (string)getSourceInfoSQLDataReader["Source_Database_Name"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceDatabaseName = "";
                        }
                        //  Populate the Source Database User Name Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Source_Database_User_Name")))
                        {
                            currentFeatureClassSourceInfo.SourceDatabaseUser = (string)getSourceInfoSQLDataReader["Source_Database_User_Name"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceDatabaseUser = "";
                        }
                        //  Populate the Input Feature Class Name Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Input_Dataset_Name")))
                        {
                            currentFeatureClassSourceInfo.SourceFeatureClassName = (string)getSourceInfoSQLDataReader["Input_Dataset_Name"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceFeatureClassName = "";
                        }
                        //  Populate the Output Geodatabase Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Output_Database")))
                        {
                            currentFeatureClassSourceInfo.OutputGeodatabaseName = (string)getSourceInfoSQLDataReader["Output_Database"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.OutputGeodatabaseName = "";
                        }
                    }
                    else
                    {
                        //  Send a Message to the calling application to let the user know why this process failed.
                        if (ErrorMessage != null)
                        {
                            ErrorMessage("     No Source Information for the Specified Feature Class was found in the Load Metadata Database!  LoaderUtilities.DatabaseTools.GetLayerSourceInfo() Failed!");
                        }
                        //  Return a NULL String to the calling routine to indicate that this process failed.
                        return(null);
                    }
                }
                else
                {
                    //  Send a Message to the calling application to let the user know why this process failed.
                    if (ErrorMessage != null)
                    {
                        ErrorMessage("     The query to retrieve Source Information for the Specified Feature Class failed to retrieve any data from the Load Metadata Database!  LoaderUtilities.DatabaseTools.GetLayerSourceInfo() Failed!");
                    }

                    //  Return a NULL String to the calling routine to indicate that this process failed.
                    return(null);
                }


                //  Instantiate a Feature Class Utilities Object.
                featureClassUtilities = new PDX.BTS.DataMaintenance.MaintTools.FeatureClassUtilities();


                //  Build the Property Set for the Source Dataset and determine its Last Update Date.
                sourcePropertySet = new ESRI.ArcGIS.esriSystem.PropertySet();
                switch (currentFeatureClassSourceInfo.SourceType)
                {
                case "FILEGEODB":
                    //  Build the File Geodatabase PropertySet.
                    sourcePropertySet.SetProperty("DATABASE", currentFeatureClassSourceInfo.SourceGeoDBFile);
                    //  Determine the File Geodatabase Feature Class Last Update Date.
                    currentFeatureClassSourceInfo.SourceLastUpdateDate = featureClassUtilities.GetFileGeodatabaseFeatureClassLastUpdate(currentFeatureClassSourceInfo.SourceGeoDBFile, currentFeatureClassSourceInfo.SourceFeatureClassName);
                    //  Exit this case.
                    break;

                case "PERSONALGEODB":
                    //  Build the Personal Geodatabase PropertySet.
                    sourcePropertySet.SetProperty("DATABASE", currentFeatureClassSourceInfo.SourceGeoDBFile);
                    //  Determine the Source Personal Geodatabase Last Update Date.
                    currentFeatureClassSourceInfo.SourceLastUpdateDate = featureClassUtilities.GetPersonalGeoDBLastUpdateDate(currentFeatureClassSourceInfo.SourceGeoDBFile);
                    //  Exit this case.
                    break;

                case "GEODATABASE":
                    //  Determine the Server User Password.
                    maintenanceGeneralUtilities = new PDX.BTS.DataMaintenance.MaintTools.GeneralUtilities();
                    string serverUserPassword = maintenanceGeneralUtilities.RetrieveParameterValue(currentFeatureClassSourceInfo.SourceDatabaseUser + "_Password", _parameterTableName, _parameterDatabaseConnectionString, true);
                    //  Build the Enterprise Geodatabase Property Set.
                    sourcePropertySet.SetProperty("SERVER", currentFeatureClassSourceInfo.SourceServerName);
                    sourcePropertySet.SetProperty("INSTANCE", currentFeatureClassSourceInfo.SourceInstance);
                    sourcePropertySet.SetProperty("DATABASE", currentFeatureClassSourceInfo.SourceDatabaseName);
                    sourcePropertySet.SetProperty("USER", currentFeatureClassSourceInfo.SourceDatabaseUser);
                    sourcePropertySet.SetProperty("PASSWORD", serverUserPassword);
                    sourcePropertySet.SetProperty("VERSION", "SDE.Default");
                    //  Determine the Enterprise Geodatabase Feature Class Last Udpate Date.
                    currentFeatureClassSourceInfo.SourceLastUpdateDate = featureClassUtilities.GetEntGeoDBFeatureClassLastUpdate(currentFeatureClassSourceInfo.SourceFeatureClassName, currentFeatureClassSourceInfo.SourceServerName, currentFeatureClassSourceInfo.SourceDatabaseName, currentFeatureClassSourceInfo.SourceDatabaseUser, serverUserPassword);
                    //  Exit this case.
                    break;

                case "SHAPEFILE":
                    //  Instantiate a City of Portland Path Manager Object that will be used to determine the Path to the Source Shapefile.
                    shapefilePathGenerator = new PDX.BTS.DataMaintenance.MaintTools.PathManager();
                    string shapefileDirectoryPath = shapefilePathGenerator.BuildShapefileDirectoryPath(currentFeatureClassSourceInfo.SourceDataShare, currentFeatureClassSourceInfo.SourceDataset, currentFeatureClassSourceInfo.SourceFeatureClassName);
                    //  Build the Shapefile PropertySet.
                    sourcePropertySet.SetProperty("DATABASE", shapefileDirectoryPath);
                    //  Determine the Source Shapefile Last Update Date.
                    string fullShapefilePath = shapefilePathGenerator.BuildShapefilePath(currentFeatureClassSourceInfo.SourceDataShare, currentFeatureClassSourceInfo.SourceDataset, currentFeatureClassSourceInfo.SourceFeatureClassName);
                    currentFeatureClassSourceInfo.SourceLastUpdateDate = featureClassUtilities.GetShapefileLastUpdateDate(fullShapefilePath);
                    //  Exit this case.
                    break;

                default:
                    //  Exit this case.
                    break;
                }

                //  Set the Source PropertySet Property of the Current Source Feature Class Info Object.
                currentFeatureClassSourceInfo.SourceDatasetPropertySet = sourcePropertySet;


                //  Return the populated Current Feature Class Source Info Object to the calling method.
                return(currentFeatureClassSourceInfo);
            }
            catch (Exception caught)
            {
                //  Send a Message to the calling application to let the user know why this process failed.
                if (ErrorMessage != null)
                {
                    ErrorMessage("    The LoaderUtilities.DatabaseTools.GetLayerSourceInfo() Method Failed with error message:  " + caught.Message);
                }

                //  Return a NULL String to the calling routine to indicate that this process failed.
                return(null);
            }
            finally
            {
                //  If the Get Source Info SQL Data Reader Object was instantiated, close it.
                if (getSourceInfoSQLDataReader != null)
                {
                    if (!getSourceInfoSQLDataReader.IsClosed)
                    {
                        getSourceInfoSQLDataReader.Close();
                    }
                    getSourceInfoSQLDataReader.Dispose();
                    getSourceInfoSQLDataReader = null;
                }
                //  If the Get Source Info SQL Command Object was instantiated, close it.
                if (getSourceInfoSQLCommand != null)
                {
                    getSourceInfoSQLCommand.Dispose();
                    getSourceInfoSQLCommand = null;
                }
            }
        } //  GetLayerSourceInfo()
Ejemplo n.º 59
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <returns>[To be supplied.]</returns>
        public override string ToString()
        {
            if (!this.recordWasLoadedFromDB)
            {
                throw new ArgumentException("No record was loaded from the database. The DisplayName is not available.");
            }

            if (this.displayName == null)
            {
                bool alreadyOpened = false;

                Params.spS_Customers_Display Param = new Params.spS_Customers_Display(true);

                switch (this.lastKnownConnectionType)
                {
                case Bob.DataClasses.ConnectionType.ConnectionString:
                    Param.SetUpConnection(this.connectionString);
                    break;

                case Bob.DataClasses.ConnectionType.SqlConnection:
                    Param.SetUpConnection(this.sqlConnection);
                    alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open);
                    break;

                case Bob.DataClasses.ConnectionType.SqlTransaction:
                    Param.SetUpConnection(this.sqlTransaction);
                    break;
                }

                Param.Param_CustomerID = this.col_CustomerID;

                System.Data.SqlClient.SqlDataReader sqlDataReader = null;
                SPs.spS_Customers_Display           Sp            = new SPs.spS_Customers_Display(false);
                if (Sp.Execute(ref Param, out sqlDataReader))
                {
                    if (sqlDataReader.Read())
                    {
                        if (!sqlDataReader.IsDBNull(SPs.spS_Customers_Display.Resultset1.Fields.Column_Display.ColumnIndex))
                        {
                            if (sqlDataReader.GetFieldType(SPs.spS_Customers_Display.Resultset1.Fields.Column_Display.ColumnIndex) == typeof(string))
                            {
                                this.displayName = sqlDataReader.GetString(SPs.spS_Customers_Display.Resultset1.Fields.Column_Display.ColumnIndex);
                            }
                            else
                            {
                                this.displayName = sqlDataReader.GetValue(SPs.spS_Customers_Display.Resultset1.Fields.Column_Display.ColumnIndex).ToString();
                            }
                        }
                    }

                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);
                }
                else
                {
                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    throw new Bob.DataClasses.CustomException(Param, "Bob.BusinessComponents.Customer", "ToString");
                }
            }

            return(this.displayName);
        }
Ejemplo n.º 60
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Master.Title = "执行SQL语句";
        builder.Append(Out.Tab("<div class=\"title\">执行SQL语句</div>", ""));
        string act = Utils.GetRequest("act", "post", 1, "", "");

        if (act == "ok")
        {
            string SqlText = Request.Form["SqlText"];
            if (string.IsNullOrEmpty(SqlText))
            {
                Utils.Error("SQL语句不能为空", "");
            }
            SqlText = SqlText.ToLower();
            string   SqlKey = "exec,declare,netuser,xp_cmdshell,drop,master,create,alter";//truncate
            string[] temp   = SqlKey.Split(",".ToCharArray());
            for (int i = 0; i < temp.Length; i++)
            {
                if (SqlText.Contains(temp[i]))
                {
                    Utils.Error("为了系统安全," + temp[i] + "方法已被禁止", "");
                }
            }
            builder.Append(Out.Tab("<div>", ""));
            try
            {
                if (!SqlText.Contains("select"))
                {
                    int rows = BCW.Data.SqlHelper.ExecuteSql(SqlText.Trim());
                    builder.Append("执行" + SqlText + "成功|影响" + rows + "行");
                }
                else
                {
                    builder.Append("执行" + SqlText + "<br />");
                    using (System.Data.SqlClient.SqlDataReader reader = BCW.Data.SqlHelper.ExecuteReader(SqlText))
                    {
                        int fieldCount = reader.FieldCount;
                        builder.Append("<table><tr>");
                        for (int i = 0; i < fieldCount; i++)
                        {
                            builder.Append("<td>" + reader.GetName(i) + "</td>");
                        }
                        builder.Append("</tr>");

                        while (reader.Read())
                        {
                            builder.Append("<tr>");
                            for (int i = 0; i < fieldCount; i++)
                            {
                                builder.Append("<td><textarea>");
                                if (!reader.IsDBNull(i))
                                {
                                    builder.Append(GetObjectValue(reader, i));
                                }
                                builder.Append("</textarea></td>");
                            }
                            builder.Append("</tr>");
                        }
                        builder.Append("</table>");
                    }
                }
            }
            catch
            {
                builder.Append("执行" + SqlText + "失败");
            }
            builder.Append(Out.Tab("</div>", ""));
            builder.Append(Out.Tab("<div>", "<br />"));
            builder.Append("<a href=\"" + Utils.getUrl("datasql.aspx") + "\">返回上一级</a>");
            builder.Append(Out.Tab("</div>", ""));
        }
        else
        {
            builder.Append(Out.Tab("<div>", ""));
            builder.Append("语句案例:<br />插入语句: insert into 表名(字段1,字段2)values('内容1','内容2')<br />更新语句: update 表名 set 字段1='内容1',字段2='内容2' where 字段3='内容3'<br />删除语句: delete from 表名 where 字段='内容'<br />查询语句: select top 显示的记录数目 字段1,字段2 from 表名 where 字段1='内容1'");
            builder.Append(Out.Tab("</div>", ""));
            string strText = "输入一条SQL语句:/,";
            string strName = "SqlText,act";
            string strType = "big,hidden";
            string strValu = "'ok";
            string strEmpt = "true,false";
            string strIdea = "/";
            string strOthe = "确定执行|reset,datasql.aspx,post,1,red|blue";

            builder.Append(Out.wapform(strText, strName, strType, strValu, strEmpt, strIdea, strOthe));
            builder.Append(Out.Tab("<div>", "<br />"));
            builder.Append("重要提示:<br />必须先备份数据库再进行操作.<br />必须熟悉SQL语句才可以进行操作.");
            builder.Append(Out.Tab("</div>", ""));
        }
        builder.Append(Out.Tab("<div class=\"hr\"></div>", Out.Hr()));
        builder.Append(Out.Tab("<div>", ""));
        builder.Append("<a href=\"" + Utils.getUrl("default.aspx") + "\">系统服务中心</a><br />");
        builder.Append(Out.Tab("</div><div class=\"title\"><a href=\"" + Utils.getUrl("../default.aspx") + "\">返回管理中心</a>", "<a href=\"" + Utils.getUrl("../default.aspx") + "\">返回管理中心</a>"));
        builder.Append(Out.Tab("</div>", "<br />"));
    }