Exemplo n.º 1
0
    private void loadGridData(bool bind = true)
	{
        _dtResources = MasterData.WTS_Resource_Get(includeArchive: false);


		_dtUser = UserManagement.LoadUserList(organizationId: 0, excludeDeveloper: false, loadArchived: false, userNameSearch: "");
		Page.ClientScript.RegisterArrayDeclaration("_userList", JsonConvert.SerializeObject(_dtUser, Newtonsoft.Json.Formatting.None));
        DataTable dt = null, dtTemp = null;
        DataSet ds = null;
        if (_refreshData || Session["dtMD_AllocationDS"] == null)
        {
            ds = MasterData.AllocationList_Get(includeArchive: true);
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables.Contains("Allocation"))
                {
                    dt = ds.Tables["Allocation"];
                    HttpContext.Current.Session["dtMD_AllocationDS"] = ds;
                }
            }

        }
        else
        {
            ds = (DataSet) HttpContext.Current.Session["dtMD_AllocationDS"];
            if (ds.Tables.Contains("Allocation"))
            {
                dt = ds.Tables["Allocation"];
            }
        }

        if (dt != null)
		{
            // 12902 - 3:
            dtTemp = dt.DefaultView.ToTable(true, new string[] { "AllocationGroupID", "AllocationGroup", "AllocationCategoryID", "AllocationCategory" });
            dtTemp.DefaultView.RowFilter = "AllocationGroupID IS NOT NULL";

            //dtTemp = dt.DefaultView.ToTable(true, new string[] { "AllocationCategoryID", "AllocationCategory" });
            //dtTemp.DefaultView.RowFilter = "AllocationCategoryID IS NOT NULL";
            dtTemp = dtTemp.DefaultView.ToTable();

			this.DCC = dt.Columns;
			Page.ClientScript.RegisterArrayDeclaration("_dcc", JsonConvert.SerializeObject(DCC, Newtonsoft.Json.Formatting.None));

			if (ds.Tables.Contains("Category"))
			{
				_dtCat = ds.Tables["Category"];
				Page.ClientScript.RegisterArrayDeclaration("_AllocationCategoryList", JsonConvert.SerializeObject(_dtCat, Newtonsoft.Json.Formatting.None));
			}
            //12092 - 3:
            if (ds.Tables.Contains("Group"))
            {
                _dtGroup = ds.Tables["Group"];
                Page.ClientScript.RegisterArrayDeclaration("_AllocationGroupList", JsonConvert.SerializeObject(_dtGroup, Newtonsoft.Json.Formatting.None));
            }

            ListItem item = null;
			foreach (DataRow row in dtTemp.Rows)
			{
				item = ddlQF.Items.FindByValue(row["AllocationCategoryID"].ToString());
				if (item == null)
				{
					ddlQF.Items.Add(new ListItem(row["AllocationCategory"].ToString(), row["AllocationCategoryID"].ToString()));
				}

                // 12902 - 3:
                item = ddlQFGroup.Items.FindByValue(row["AllocationGroupID"].ToString());
                if (item == null)
                {
                    ddlQFGroup.Items.Add(new ListItem(row["AllocationGroup"].ToString(), row["AllocationGroupID"].ToString()));
                }

            }

            // 12092 - 3 - Remarked out:
   //         item = ddlQF.Items.FindByValue(_qfAllocationCategoryID.ToString());
			//if (item != null)
			//{
			//	item.Selected = true;
			//}

            // 12092 - 3:
            item = ddlQFGroup.Items.FindByValue(_qfAllocationGroupID.ToString());
            if (item != null)
            {
                item.Selected = true;
            }

            InitializeColumnData(ref dt);
			dt.AcceptChanges();

            iti_Tools_Sharp.DynamicHeader head = WTSUtility.CreateGridMultiHeader(dt);
			if (head != null)
			{
				grdMD.DynamicHeader = head;
			}
		}

        // 12902 - 3:
		if (_qfAllocationGroupID != 0 && dt != null && dt.Rows.Count > 0)
		{
			dt.DefaultView.RowFilter = string.Format(" AllocationGroupID =  {0}", _qfAllocationGroupID.ToString());
			dt = dt.DefaultView.ToTable();
		}
        //if (_qfAllocationCategoryID != 0 && dt != null && dt.Rows.Count > 0)
        //{
        //    dt.DefaultView.RowFilter = string.Format(" AllocationCategoryID =  {0}", _qfAllocationCategoryID.ToString());
        //    dt = dt.DefaultView.ToTable();
        //}

        int count = dt.Rows.Count;
		count = count > 0 ? count - 1 : count; //need to subtract the empty row
		spanRowCount.InnerText = count.ToString();

        if (_export)
        {
            exportExcel(dt);
        }

        grdMD.DataSource = dt;
		if (bind) grdMD.DataBind();
	}
Exemplo n.º 2
0
    protected static DataTable GetMasterDataValues(string idField, string columnName, string textField, bool includeArchive = false)
    {
        DataSet   ds = null;
        DataTable dt = null;

        try
        {
            switch (columnName.ToUpper())
            {
            case "ALLOCATION":
                ds = MasterData.AllocationList_Get(includeArchive: includeArchive);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null)
                {
                    dt = ds.Tables[0];
                    dt.Columns["ALLOCATIONID"].ColumnName = "valueField";
                    dt.Columns["ALLOCATION"].ColumnName   = "textField";
                }

                break;

            case "ARCHIVE":
                dt = new DataTable();
                dt.Columns.Add("valueField");
                dt.Columns.Add("textField");
                dt.AcceptChanges();

                dt.Rows.Add(new object[] { "0", "No" });
                dt.Rows.Add(new object[] { "1", "Yes" });

                break;

            case "ASSIGNED":
                dt = UserManagement.LoadUserList(organizationId: 0, excludeDeveloper: false, loadArchived: includeArchive, userNameSearch: "");
                if (dt != null)
                {
                    dt.Columns["WTS_RESOURCEID"].ColumnName = "valueField";
                    dt.Columns["UserName"].ColumnName       = "textField";
                }

                break;

            case "PRIMARY_DEVELOPER":
                dt = UserManagement.LoadUserList(organizationId: 0, excludeDeveloper: false, loadArchived: includeArchive, userNameSearch: "");
                if (dt != null)
                {
                    dt.Columns["WTS_RESOURCEID"].ColumnName = "valueField";
                    dt.Columns["UserName"].ColumnName       = "textField";
                }

                break;

            case "WORKITEMTYPE":
                dt = MasterData.WorkItemTypeList_Get(includeArchive: includeArchive);
                if (dt != null)
                {
                    dt.Columns["WORKITEMTYPEID"].ColumnName = "valueField";
                    dt.Columns["WORKITEMTYPE"].ColumnName   = "textField";
                }

                break;

            case "PRIORITY":
                dt = MasterData.PriorityList_Get(includeArchive: includeArchive);
                if (dt != null)
                {
                    dt.DefaultView.RowFilter = "PriorityType = 'Work Item'";
                    dt = dt.DefaultView.ToTable();
                    dt.Columns["PriorityID"].ColumnName = "valueField";
                    dt.Columns["Priority"].ColumnName   = "textField";
                }

                break;

            case "PRODUCTION":
                dt = new DataTable();
                dt.Columns.Add("valueField");
                dt.Columns.Add("textField");
                dt.AcceptChanges();

                dt.Rows.Add(new object[] { "0", "No" });
                dt.Rows.Add(new object[] { "1", "Yes" });

                break;

            case "VERSION":
                dt = MasterData.ProductVersionList_Get(includeArchive: includeArchive);
                if (dt != null)
                {
                    dt = dt.DefaultView.ToTable();
                    dt.Columns["ProductVersionID"].ColumnName = "valueField";
                    dt.Columns["ProductVersion"].ColumnName   = "textField";
                }

                break;

            case "WEBSYSTEM":
                dt = MasterData.SystemList_Get(includeArchive: includeArchive);
                if (dt != null)
                {
                    dt = dt.DefaultView.ToTable();
                    dt.Columns["WTS_SYSTEMID"].ColumnName = "valueField";
                    dt.Columns["WTS_SYSTEM"].ColumnName   = "textField";
                }

                break;

            case "WORKAREA":
                dt = MasterData.WorkAreaList_Get(includeArchive: includeArchive);
                if (dt != null)
                {
                    dt = dt.DefaultView.ToTable();
                    dt.Columns["WorkAreaID"].ColumnName = "valueField";
                    dt.Columns["WorkArea"].ColumnName   = "textField";
                }

                break;

            case "WORKREQUEST":
                dt = WorkRequest.WorkRequestList_Get(typeID: 0, requestGroupID: 0, myData: false);
                if (dt != null)
                {
                    dt = dt.DefaultView.ToTable();
                    dt.Columns["WORKREQUESTID"].ColumnName = "valueField";
                    dt.Columns["TITLE"].ColumnName         = "textField";
                }

                break;

            case "WORKTYPE":
                dt = MasterData.WorkTypeList_Get(includeArchive: includeArchive);
                if (dt != null)
                {
                    dt.Columns["WORKTYPEID"].ColumnName = "valueField";
                    dt.Columns["WORKTYPE"].ColumnName   = "textField";
                }

                break;

            case "WORKLOADGROUP":
                dt = MasterData.WorkloadGroupList_Get(includeArchive: includeArchive);
                if (dt != null)
                {
                    dt = dt.DefaultView.ToTable();
                    dt.Columns["WorkloadGroupID"].ColumnName = "valueField";
                    dt.Columns["WorkloadGroup"].ColumnName   = "textField";
                }

                break;

            default:
                dt = null;
                break;
            }
        }
        catch (Exception ex)
        {
            LogUtility.LogException(ex);
            dt = null;
        }

        return(dt);
    }
    private void loadGridData()
    {
        _dtSystem = MasterData.SystemList_Get(includeArchive: false);
        if (_dtSystem != null && _qfSystemID != 0)
        {
            _dtSystem.DefaultView.RowFilter = string.Format(" WTS_SYSTEMID IN (0, {0}) ", _qfSystemID.ToString());
            _dtSystem = _dtSystem.DefaultView.ToTable();
        }


        DataSet dsAllocation = MasterData.AllocationList_Get(includeArchive: false);

        if (dsAllocation != null && dsAllocation.Tables.Count > 0)
        {
            _dtAllocation = dsAllocation.Tables[0];
        }
        if (_dtAllocation != null && _qfAllocationID != 0)
        {
            _dtAllocation.DefaultView.RowFilter = string.Format(" AllocationID = {0} ", _qfAllocationID.ToString());
            _dtAllocation = _dtAllocation.DefaultView.ToTable();
        }

        DataTable dt = MasterData.Allocation_SystemList_Get(allocationID: this._qfAllocationID, systemID: this._qfSystemID);

        if (dt != null)
        {
            if (_qfSystemID > 0)
            {
                dt.Columns["WTS_SYSTEM"].SetOrdinal(dt.Columns["AllocationID"].Ordinal);
                dt.Columns["WTS_SYSTEMID"].SetOrdinal(dt.Columns["WTS_SYSTEM"].Ordinal);
                dt.AcceptChanges();
            }

            this.DCC = dt.Columns;
            Page.ClientScript.RegisterArrayDeclaration("_dcc", JsonConvert.SerializeObject(DCC, Newtonsoft.Json.Formatting.None));

            ListItem item = null;
            foreach (DataRow row in _dtAllocation.Rows)
            {
                item = ddlQF.Items.FindByValue(row["AllocationID"].ToString());
                if (item == null)
                {
                    ddlQF.Items.Add(new ListItem(row["Allocation"].ToString(), row["AllocationID"].ToString()));
                }
            }
            item = ddlQF.Items.FindByValue(_qfAllocationID.ToString());
            if (item != null)
            {
                item.Selected = true;
            }

            foreach (DataRow row in _dtSystem.Rows)
            {
                item = ddlQF_System.Items.FindByValue(row["WTS_SYSTEMID"].ToString());
                if (item == null)
                {
                    ddlQF_System.Items.Add(new ListItem(row["WTS_SYSTEM"].ToString(), row["WTS_SYSTEMID"].ToString()));
                }
            }
            item = ddlQF_System.Items.FindByValue(_qfSystemID.ToString());
            if (item != null)
            {
                item.Selected = true;
            }

            InitializeColumnData(ref dt);
            dt.AcceptChanges();
        }

        if (_qfAllocationID != 0 && dt != null && dt.Rows.Count > 0)
        {
            dt.DefaultView.RowFilter = string.Format(" AllocationID =  {0} OR (AllocationID = 0 AND WTS_SYSTEMID = 0) ", _qfAllocationID.ToString());
            dt = dt.DefaultView.ToTable();
        }
        if (_qfSystemID != 0 && dt != null && dt.Rows.Count > 0)
        {
            dt.DefaultView.RowFilter = string.Format(" WTS_SYSTEMID =  {0} OR (WTS_SYSTEMID = 0 AND AllocationID = 0) OR WTS_SYSTEMID IS NULL ", _qfSystemID.ToString());
            dt = dt.DefaultView.ToTable();
        }
        int count = dt.Rows.Count;

        count = count > 0 ? count - 1 : count;         //need to subtract the empty row
        spanRowCount.InnerText = count.ToString();

        grdMD.DataSource = dt;
        grdMD.DataBind();
    }