/// <summary>
    /// Returns true if the data in this item was modified by the user since the last postback, false otherwise
    /// </summary>
    /// <param name="item"></param>
    /// <returns></returns>
    private bool IsItemModified(GridDataItem item)
    {
        //Get the new values hashtable
        Hashtable newValues = new Hashtable();

        item.ExtractValues(newValues);

        //Get the saved old values hashtable
        Hashtable savedOldValues = (Hashtable)item.SavedOldValues;

        foreach (string key in newValues.Keys)
        {
            //Null case treated here
            if (newValues[key] == null && savedOldValues[key] == null)
            {
                continue;
            }

            if ((newValues[key] == null && savedOldValues[key] != null) ||
                (newValues[key] != null && savedOldValues[key] == null))
            {
                return(true);
            }

            if (newValues[key].ToString() != savedOldValues[key].ToString())
            {
                return(true);
            }
        }
        return(false);
    }
示例#2
0
        protected void rdAssetTypeGrid_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
        {
            if (_assetReclamationServiceLocation != null)
            {
                GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
                Hashtable    values   = new Hashtable();
                dataItem.ExtractValues(values);

                int assetCategoryId = Convert.ToInt32(values["AssetCategoryId"].ToString());
                AssetCategoryEntity assetCategory = new AssetCategoryEntity(assetCategoryId);

                var assetTypes = from at in _db.AssetType
                                 where at.AssetCategoryId == assetCategory.AssetCategoryId
                                 orderby at.Name
                                 select at;

                var serviceLocationAssetTypes = from slat in _db.ServiceLocationAssetType
                                                join at in _db.AssetType on slat.AssetTypeId equals at.AssetTypeId
                                                join ac in _db.AssetCategory on at.AssetCategoryId equals ac.AssetCategoryId
                                                where at.AssetCategoryId == assetCategory.AssetCategoryId &&
                                                slat.ServiceLocationId == _assetReclamationServiceLocation.ServiceLocationId
                                                select slat;

                List <ServiceLocationAssetTypeEntity> slats = new List <ServiceLocationAssetTypeEntity>();

                foreach (AssetTypeEntity ate in assetTypes)
                {
                    if (serviceLocationAssetTypes.Where(x => x.AssetTypeId == ate.AssetTypeId).Count() > 0)
                    {
                        slats.Add(serviceLocationAssetTypes.Where(x => x.AssetTypeId == ate.AssetTypeId).First());
                    }
                    else
                    {
                        ServiceLocationAssetTypeEntity slat = new ServiceLocationAssetTypeEntity();
                        slat.ServiceLocationId = _assetReclamationServiceLocation.ServiceLocationId;
                        slat.AssetTypeId       = ate.AssetTypeId;
                        slat.PricePerUnit      = 0;
                        slat.Save();
                        slats.Add(slat);
                    }
                }

                e.DetailTableView.DataSource = slats.OrderBy(x => x.AssetType.Name);
            }
            else
            {
                e.DetailTableView.DataSource = null;
            }
        }
示例#3
0
        protected void rdAssetTypeGrid_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
        {
            GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
            Hashtable    values   = new Hashtable();

            dataItem.ExtractValues(values);

            int assetCategoryId = Convert.ToInt32(values["AssetCategoryId"].ToString());
            AssetCategoryEntity assetCategory = new AssetCategoryEntity(assetCategoryId);

            var assetTypes = from at in _db.AssetType
                             where at.AssetCategoryId == assetCategory.AssetCategoryId
                             orderby at.Name
                             select at;

            e.DetailTableView.DataSource = assetTypes;
        }
        protected void ConsultaOpciones(object sender, GridDetailTableDataBindEventArgs e)
        {
            con.ConnectionString = ConfigurationManager.ConnectionStrings["IconoCRM"].ToString();
            GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
            Hashtable    values   = new Hashtable();

            dataItem.ExtractValues(values);
            string idPregunta = values["idPregunta"].ToString();
            string Command    = "select * from sm_OpcionPregunta where idPregunta='" + idPregunta + "' and idEncuesta ='" + hdfEncuestaActual.Value + "'";

            using (SqlDataAdapter myDataAdapter = new SqlDataAdapter(Command, con))
            {
                DataTable dtResult = new DataTable();
                myDataAdapter.Fill(dtResult);
                e.DetailTableView.DataSource = dtResult;
            }
        }
示例#5
0
        protected void rdAccountGrid_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
        {
            GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
            Hashtable    values   = new Hashtable();

            dataItem.ExtractValues(values);

            int           accountId = Convert.ToInt32(values["AccountId"].ToString());
            AccountEntity account   = new AccountEntity(accountId);

            var accountEmployeeAssignment = from aea in _db.AccountEmployeeAssignment
                                            where aea.AccountId == account.AccountId
                                            select aea;

            if (accountEmployeeAssignment.Count() == 0)
            {
                AccountEmployeeAssignmentEntity aeae = new AccountEmployeeAssignmentEntity();
                aeae.AccountId = accountId;
                aeae.Save();
            }

            e.DetailTableView.DataSource = account.AccountEmployeeAssignment.ToList();
        }
        protected void RadGridUsuarios_ItemCommand(object sender, GridCommandEventArgs e)
        {
            try
            {
                switch (e.CommandName)
                {
                case "InitInsert":    //Insercion
                    e.Canceled                      = true;
                    panelGrilla.Visible             = false;
                    panelComboUsuario.Visible       = true;
                    panelAgregarUsuario.Visible     = false;
                    cboTipoIdentificacion.Enabled   = true;
                    txtNumeroIdentificacion.Enabled = true;
                    break;

                case "Buscar":
                    pacienteNegocio = new PacienteNegocio();
                    sm_Persona   persona = new sm_Persona();
                    Hashtable    valores = new Hashtable();
                    GridDataItem item    = (GridDataItem)e.Item;
                    item.ExtractValues(valores);
                    cargarEmpresas();
                    cargarCiudades();
                    cargarRoles();
                    cargarTiposIdentificacion();
                    /*Carga la informacion de la persona*/
                    cboTipoIdentificacion.SelectedValue = item.GetDataKeyValue("idTipoIdentificacion").ToString();
                    txtNumeroIdentificacion.Text        = valores["numeroIdentificacion"].ToString();
                    persona = pacienteNegocio.ConsultarPersona(Convert.ToInt16(item.GetDataKeyValue("idTipoIdentificacion")), valores["numeroIdentificacion"].ToString());
                    txtPrimerNombre.Text = item.GetDataKeyValue("primerNombre").ToString();
                    if (item.GetDataKeyValue("segundoNombre") != null)
                    {
                        txtSegundoNombre.Text = item.GetDataKeyValue("segundoNombre").ToString();
                    }
                    else
                    {
                        txtSegundoNombre.Text = string.Empty;
                    }
                    txtPrimerApellido.Text = item.GetDataKeyValue("primerApellido").ToString();
                    if (item.GetDataKeyValue("segundoApellido") != null)
                    {
                        txtSegundoApellido.Text = item.GetDataKeyValue("segundoApellido").ToString();
                    }
                    else
                    {
                        txtSegundoApellido.Text = string.Empty;
                    }
                    rdpFechaNacimiento.SelectedDate = persona.fechaNacimiento;
                    cboCiudad.SelectedValue         = item.GetDataKeyValue("idCiudad").ToString();
                    txtCelular.Text      = valores["celular"].ToString();
                    txtTelefonoFijo.Text = valores["telefonoFijo"].ToString();
                    txtCorreo.Text       = valores["correo"].ToString();
                    /*Carga la informacion del usuario*/
                    adminNegocio = new AdministracionNegocio();
                    int     tipoID  = Convert.ToInt32(item.GetDataKeyValue("idTipoIdentificacion").ToString());
                    Usuario usuario = adminNegocio.ListarUsuarios(tipoID, valores["numeroIdentificacion"].ToString(), 1).FirstOrDefault();
                    if (usuario == null)
                    {
                        chkMedicoTratante.Checked = true;
                    }
                    else
                    {
                        txtUsuario.Text          = usuario.usuario;
                        txtContrasena.Text       = usuario.contrasena;
                        cboEmpresa.SelectedValue = usuario.idEmpresa.ToString();
                        foreach (sm_Rol rol in usuario.Roles)
                        {
                            foreach (RadComboBoxItem c in cboRol.Items)
                            {
                                if (c.Value.ToString().Equals(rol.idRol.ToString()))
                                {
                                    c.Checked = true;
                                }
                            }
                        }
                        cboEstado.SelectedValue = usuario.estado.ToString();
                    }
                    /*Hidden Fields*/
                    if (usuario != null)
                    {
                        hdfIdUsuario.Value = item.GetDataKeyValue("idUsuario").ToString();
                    }
                    else
                    {
                        hdfIdUsuario.Value = "0";
                    }
                    hdfCreatedBy.Value              = item.GetDataKeyValue("createdBy").ToString();;
                    hdfCreatedDate.Value            = item.GetDataKeyValue("createdDate").ToString();;
                    panelGrilla.Visible             = false;
                    panelComboUsuario.Visible       = false;
                    panelAgregarUsuario.Visible     = true;
                    btnAgregarUsuario.Visible       = false;
                    btnActualizar.Visible           = true;
                    cboTipoIdentificacion.Enabled   = false;
                    txtNumeroIdentificacion.Enabled = false;
                    break;
                }
            }
            catch (Exception ex)
            {
                MostrarMensaje("Error: " + ex.Message, true);
            }
        }
示例#7
0
        public override void SaveOldValues()
        {
            DataSet reforecastDS = (DataSet)SessionManager.GetSessionValueNoRedirect(this.Page, REFORECAST_DATASET);

            if (reforecastDS == null)
            {
                return;
            }
            //Search through each detail item
            for (int i = 0; i < this.MasterTableView.Items.Count; i++)
            {
                GridDataItem masterItem = this.MasterTableView.Items[i];
                Hashtable    masterData = new Hashtable();
                masterItem.ExtractValues(masterData);
                DataRow masterRow = reforecastDS.Tables[0].Rows.Find(new object[] { masterItem["IdPhase"].Text, masterItem["IdWP"].Text });
                if (masterRow != null)
                {
                    masterRow["Progress"] = GetGridItemValue(masterData["Progress"]);
                }

                GridTableView detailTableView = this.MasterTableView.Items[i].ChildItem.NestedTableViews[0];
                for (int j = 0; j < detailTableView.Items.Count; j++)
                {
                    GridDataItem detailItem = detailTableView.Items[j];
                    Hashtable    detailData = new Hashtable();

                    //If a DeletedReforecastBudgetKey object has been stored in the session
                    DeletedReforecastBudgetKey key = (DeletedReforecastBudgetKey)SessionManager.GetSessionValueNoRedirect(this.Page, DELETED_COST_CENTER_KEY);
                    if (key != null)
                    {
                        //If the stored budget key is the same one as the current budget, do not save the old values of this budget since
                        //this budget has been deleted
                        if (key.IdProject == int.Parse(detailItem["IdProject"].Text) && key.IdPhase == int.Parse(detailItem["IdPhase"].Text) &&
                            key.IdWP == int.Parse(detailItem["IdWP"].Text) && key.IdCostCenter == int.Parse(detailItem["IdCostCenter"].Text))
                        {
                            continue;
                        }
                    }

                    detailItem.ExtractValues(detailData);
                    DataRow detailRow = reforecastDS.Tables[1].Rows.Find(new object[] { detailItem["IdPhase"].Text, detailItem["IdWP"].Text, detailItem["IdCostCenter"].Text });
                    if (detailRow != null)
                    {
                        detailRow["New"] = GetGridItemValue(detailData["New"]);
                    }

                    GridTableView lastTableView = detailTableView.Items[j].ChildItem.NestedTableViews[0];
                    for (int k = 0; k < lastTableView.Items.Count; k++)
                    {
                        GridDataItem detailDetailItem = lastTableView.Items[k];
                        if (lastTableView.Items[k].IsInEditMode)
                        {
                            Hashtable detailDetailData = new Hashtable();
                            detailDetailItem.ExtractValues(detailDetailData);
                            DataRow detailDetailRow = reforecastDS.Tables[2].Rows.Find(new object[] { detailDetailItem["IdPhase"].Text, detailDetailItem["IdWP"].Text, detailDetailItem["IdCostCenter"].Text, detailDetailItem["YearMonth"].Text });
                            if (detailDetailRow != null)
                            {
                                detailDetailRow["New"] = GetGridItemValue(detailDetailData["New"]);
                            }
                        }
                    }
                }
            }
            SessionManager.SetSessionValue(this.Page, REFORECAST_DATASET, reforecastDS);
        }