public void AddEmptyRecordTest()
        {
            DataTable  dt = new DataTable("Table");
            DataColumn dc = new DataColumn("Id", typeof(int));

            dt.Columns.Add(dc);
            dc = new DataColumn("Name", typeof(string));
            dt.Columns.Add(dc);

            DataRow newRow = dt.NewRow();

            newRow["Id"]   = 1;
            newRow["Name"] = "cici";
            dt.Rows.Add(newRow);
            newRow         = dt.NewRow();
            newRow["Id"]   = 2;
            newRow["Name"] = "mimi";
            dt.Rows.Add(newRow);
            newRow         = dt.NewRow();
            newRow["Id"]   = 3;
            newRow["Name"] = "lili";
            dt.Rows.Add(newRow);

            DSUtils.AddEmptyRecord(dt);

            Assert.AreEqual(4, dt.Rows.Count);
            Assert.AreEqual(DBNull.Value, dt.Rows[0]["Name"]);
            Assert.AreEqual(-1, dt.Rows[0]["Id"]);
        }
    private void LoadProgramsFiltered(int ownerId)
    {
        ProjectSelectorFilter projectSelectorFilter = new ProjectSelectorFilter(SessionManager.GetSessionValueNoRedirect(this, SessionStrings.CONNECTION_MANAGER));

        projectSelectorFilter.IdAssociate = CurrentUser.IdAssociate;
        projectSelectorFilter.ShowOnly    = cmbShowOnly.SelectedValue;
        projectSelectorFilter.OrderBy     = rbOrderProjects.SelectedValue;
        //Fill the project combo box with the values corresponding to the selected owner
        projectSelectorFilter.IdOwner = ownerId;

        DataSet programsDS = projectSelectorFilter.SelectProcedure("SelectPrograms");

        DSUtils.AddEmptyRecord(programsDS.Tables[0]);
        cmbPG.DataSource     = programsDS;
        cmbPG.DataMember     = programsDS.Tables[0].ToString();
        cmbPG.DataValueField = "ProgramId";
        cmbPG.DataTextField  = "Name";
        cmbPG.DataBind();

        //reset the function
        lblFunction.Text = String.Empty;
        //reset additional labels
        lblActiveMembers.Text          = String.Empty;
        lblTimingIntercoPercent.Text   = String.Empty;
        lblInitialBudgetValidated.Text = String.Empty;
    }
        public void SetDataSource(object[] attributes)
        {
            try
            {
                ReferenceMappingAttribute attribute = attributes[0] as ReferenceMappingAttribute;
                if (attribute == null)
                {
                    throw new IndException(ApplicationMessages.EXCEPTION_WRONG_ATTRIBUTE_RECEIVED);
                }


                IGenericEntity referencedEntity = EntityFactory.GetEntityInstance(attribute.ReferencedEntity, SessionManager.GetSessionValueNoRedirect((IndBasePage)this.Page, SessionStrings.CONNECTION_MANAGER));
                //Call the GetAll() method of the referenced object
                DataSet referencedDataSet = referencedEntity.GetAll();
                DSUtils.AddEmptyRecord(referencedDataSet.Tables[0]);
                //Set the DataSource, DataMember, DataValueField and DataTextField of the combobox
                this.DataSource = referencedDataSet;
                this.DataMember = referencedDataSet.Tables[0].TableName;
                this.DataBind();
                this.SelectedValue = ApplicationConstants.INT_NULL_VALUE.ToString();
            }
            catch (IndException ex)
            {
                ControlHierarchyManager.ReportError(ex);
                return;
            }
            catch (Exception ex)
            {
                ControlHierarchyManager.ReportError(new IndException(ex));
                return;
            }
        }
    protected void cmbCt_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        try
        {
            Associate associate = new Associate(SessionManager.GetSessionValueNoRedirect(this, SessionStrings.CONNECTION_MANAGER));
            associate.IdCountry = int.Parse(cmbCt.SelectedValue);
            DataSet associateDataSet = associate.SelectActiveAssociates();

            DSUtils.AddEmptyRecord(associateDataSet.Tables[0]);
            cmbAs.DataSource     = associateDataSet;
            cmbAs.DataMember     = associateDataSet.Tables[0].TableName;
            cmbAs.DataTextField  = "Name";
            cmbAs.DataValueField = "Id";
            cmbAs.DataBind();
        }
        catch (IndException ex)
        {
            ShowError(ex);
            return;
        }
        catch (Exception ex)
        {
            ShowError(new IndException(ex));
            return;
        }
    }
예제 #5
0
        public DataSet SelectProcedure(string spName)
        {
            DataSet ds;

            try
            {
                ds = this.GetEntity().GetCustomDataSet(spName.ToString(), this);
                DSUtils.AddEmptyRecord(ds.Tables[0]);
            }
            catch (Exception ex)
            {
                throw new IndException(ex);
            }
            return(ds);
        }
예제 #6
0
        /// <summary>
        /// Gets all roles in the database (except Program manager and core team member)
        /// </summary>
        /// <returns>datatable containing information about all roles in the database</returns>
        public DataTable GetRoles()
        {
            DataTable rolesDataTable;

            try
            {
                rolesDataTable = dbProfile.GetRoles();
                DSUtils.AddEmptyRecord(rolesDataTable);
            }
            catch (Exception ex)
            {
                throw new IndException(ex);
            }
            return(rolesDataTable);
        }
예제 #7
0
        /// <summary>
        /// Gets all associates in the database
        /// </summary>
        /// <returns>datatable containing information about all associates in the database</returns>
        public DataTable GetAssociates()
        {
            DataTable associatesDataTable;

            try
            {
                associatesDataTable = dbProfile.GetAssociates();
                DSUtils.AddEmptyRecord(associatesDataTable);
            }
            catch (Exception ex)
            {
                throw new IndException(ex);
            }
            return(associatesDataTable);
        }
예제 #8
0
    private void LoadCostCenterCodeCombo()
    {
        CostCenter costCenter = new CostCenter(SessionManager.GetSessionValueNoRedirect(this.Page, SessionStrings.CONNECTION_MANAGER));

        costCenter.IdInergyLocation = Int32.Parse(cmbInergyLocation.SelectedValue);
        DataSet ds = costCenter.GetAll(true);

        if (ds != null)
        {
            cmbCostCenter.Items.Clear();
            DSUtils.AddEmptyRecord(ds.Tables[0]);
            cmbCostCenter.DataSource     = ds;
            cmbCostCenter.DataMember     = ds.Tables[0].TableName;
            cmbCostCenter.DataTextField  = "Code";
            cmbCostCenter.DataValueField = "Id";
            cmbCostCenter.DataBind();
        }
    }
        private void LoadProgramsFiltered(int ownerId)
        {
            ProjectSelectorFilter projectSelectorFilter = new ProjectSelectorFilter(SessionManager.GetSessionValueNoRedirect(this, SessionStrings.CONNECTION_MANAGER));

            projectSelectorFilter.IdOwner     = ownerId;
            projectSelectorFilter.IdAssociate = currentUser.IdAssociate;
            projectSelectorFilter.ShowOnly    = string.Empty; //it is not used
            projectSelectorFilter.IdProgram   = -1;           //all program
            DataSet programsDS = projectSelectorFilter.SelectProcedure("SelectPrograms");

            DSUtils.AddEmptyRecord(programsDS.Tables[0], "ProgramId");

            cmbProgram.DataSource     = programsDS;
            cmbProgram.DataMember     = programsDS.Tables[0].ToString();
            cmbProgram.DataValueField = "ProgramId";
            cmbProgram.DataTextField  = "Name";
            cmbProgram.DataBind();
        }
    private void LoadOwnersFiltered(int ownerId)
    {
        ProjectSelectorFilter projectSelectorFilter = new ProjectSelectorFilter(SessionManager.GetSessionValueNoRedirect(this, SessionStrings.CONNECTION_MANAGER));

        projectSelectorFilter.IdAssociate = CurrentUser.IdAssociate;
        projectSelectorFilter.ShowOnly    = cmbShowOnly.SelectedValue;
        projectSelectorFilter.OrderBy     = rbOrderProjects.SelectedValue;
        //Fill the project combo box with the values corresponding to the selected owner
        projectSelectorFilter.IdOwner = ownerId;

        DataSet ownerDS = projectSelectorFilter.SelectProcedure("SelectOwners");

        DSUtils.AddEmptyRecord(ownerDS.Tables[0]);
        cmbOW.DataSource     = ownerDS;
        cmbOW.DataMember     = ownerDS.Tables[0].ToString();
        cmbOW.DataValueField = "OwnerId";
        cmbOW.DataTextField  = "Name";
        cmbOW.DataBind();
    }
예제 #11
0
    /// <summary>
    /// Loads the countries of the users that have the given inergy login from the database
    /// </summary>
    private void LoadCountries()
    {
        if (Session[SessionStrings.INERGY_LOGIN] == null)
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "SessionExpiredClose", "doReturn(-1);", true);
            return;
        }

        string inergyLogin = Session[SessionStrings.INERGY_LOGIN].ToString();
        //Build a currentUser object only to get the countries of the user having the known inergy login (the inergy login is the only
        //information we know so far when opening this window when the application starts or after the session has expired)
        CurrentUser newCurrentUser = new CurrentUser(inergyLogin, Session[SessionStrings.CONNECTION_MANAGER]);
        DataTable   tblCountries   = newCurrentUser.GetUserCountries();

        DSUtils.AddEmptyRecord(tblCountries);

        //Get the bool value indicating if the page is opened from user settings page or not
        bool isFromUserSettings = String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["UserSettings"]) ? false : true;

        if (isFromUserSettings)
        {
            if (Session[SessionStrings.CURRENT_USER] == null)
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "SessionExpiredClose", "doReturn(-1);", true);
                return;
            }
            tblCountries.PrimaryKey = new DataColumn[] { tblCountries.Columns["Id"] };

            int     currentCountryId  = ((CurrentUser)Session[SessionStrings.CURRENT_USER]).IdCountry;
            DataRow currentCountryRow = tblCountries.Rows.Find(currentCountryId);

            tblCountries.Rows.Remove(currentCountryRow);
        }

        cmbCountries.DataSource     = tblCountries;
        cmbCountries.DataValueField = "Id";
        cmbCountries.DataTextField  = "Name";
        cmbCountries.DataBind();
    }
    private void PopulateControls()
    {
        Country country        = new Country(SessionManager.GetSessionValueNoRedirect(this, SessionStrings.CONNECTION_MANAGER));
        DataSet countryDataSet = country.GetAll();

        DSUtils.AddEmptyRecord(countryDataSet.Tables[0]);
        cmbCt.DataSource     = countryDataSet;
        cmbCt.DataMember     = countryDataSet.Tables[0].TableName;
        cmbCt.DataTextField  = "Name";
        cmbCt.DataValueField = "Id";
        cmbCt.DataBind();

        Associate associate        = new Associate(SessionManager.GetSessionValueNoRedirect(this, SessionStrings.CONNECTION_MANAGER));
        DataSet   associateDataSet = associate.SelectActiveAssociates();

        DSUtils.AddEmptyRecord(associateDataSet.Tables[0]);
        cmbAs.DataSource     = associateDataSet;
        cmbAs.DataMember     = associateDataSet.Tables[0].TableName;
        cmbAs.DataTextField  = "Name";
        cmbAs.DataValueField = "Id";
        cmbAs.DataBind();
    }
    private void LoadProjectsFiltered(int programId)
    {
        ProjectSelectorFilter projectSelectorFilter = new ProjectSelectorFilter(SessionManager.GetSessionValueNoRedirect(this, SessionStrings.CONNECTION_MANAGER));

        if (!cmbOW.IsEmptyValueSelected())
        {
            projectSelectorFilter.IdOwner = Int32.Parse(cmbOW.SelectedValue);
        }

        projectSelectorFilter.IdAssociate = CurrentUser.IdAssociate;
        projectSelectorFilter.ShowOnly    = cmbShowOnly.SelectedValue;
        projectSelectorFilter.OrderBy     = rbOrderProjects.SelectedValue;
        projectSelectorFilter.IdProgram   = programId;

        DataSet projectDS = projectSelectorFilter.SelectProcedure("SelectProjects");;

        DSUtils.AddEmptyRecord(projectDS.Tables[0]);
        cmbPJ.DataSource     = projectDS;
        cmbPJ.DataMember     = projectDS.Tables[0].ToString();
        cmbPJ.DataValueField = "ProjectId";
        cmbPJ.DataTextField  = "ProjectName";
        cmbPJ.DataBind();
    }
        private void LoadProjectsFiltered(int programId)
        {
            ProjectSelectorFilter projectSelectorFilter = new ProjectSelectorFilter(SessionManager.GetSessionValueNoRedirect(this, SessionStrings.CONNECTION_MANAGER));
            CurrentUser           currentUser           = (CurrentUser)SessionManager.GetSessionValueRedirect(this, SessionStrings.CURRENT_USER);

            if (!cmbProgram.IsEmptyValueSelected())
            {
                projectSelectorFilter.IdProgram = Int32.Parse(cmbProgram.SelectedValue);
            }
            else
            {
                projectSelectorFilter.IdProgram = -1;
            }
            projectSelectorFilter.IdAssociate = currentUser.IdAssociate;

            DataSet projectDS = projectSelectorFilter.SelectProcedure("SelectProjects");;

            DSUtils.AddEmptyRecord(projectDS.Tables[0], "ProjectId");
            cmbProject.DataSource     = projectDS;
            cmbProject.DataMember     = projectDS.Tables[0].ToString();
            cmbProject.DataValueField = "ProjectId";
            cmbProject.DataTextField  = "ProjectName";
            cmbProject.DataBind();
        }