예제 #1
0
 protected void btnBindResource_Click(object sender, System.EventArgs e)
 {
     this.ReplaceViewState();
     if (!string.IsNullOrEmpty(this.hfldResourceId.Value))
     {
         ISerializable serializable = new cn.justwin.Serialize.JsonSerializer();
         string[]      array        = serializable.Deserialize <string[]>(this.hfldResourceId.Value);
         if (array != null)
         {
             DataTable dataTable = new DataTable();
             if (this.hfldIsWBSRelevance.Value == "1")
             {
                 dataTable = BudModifyTaskResBll.showResForAdd(DBHelper.GetInParameterSql(array), this.modifyTaskId);
             }
             else
             {
                 dataTable = BudModifyTaskResBll.showResForAddByModify(DBHelper.GetInParameterSql(array), this.prjId);
             }
             DataTable dataTable2 = this.ViewState["ResourcesTable"] as DataTable;
             if (dataTable2 != null)
             {
                 dataTable2.PrimaryKey = new DataColumn[]
                 {
                     dataTable2.Columns["ResourceCode"]
                 };
                 dataTable.PrimaryKey = new DataColumn[]
                 {
                     dataTable.Columns["ResourceCode"]
                 };
                 dataTable2.Merge(dataTable, true);
                 dataTable = dataTable2;
             }
             if (!dataTable.Columns.Contains("LossCoefficient"))
             {
                 DataColumn dataColumn = new DataColumn();
                 dataColumn.ColumnName   = "LossCoefficient";
                 dataColumn.DataType     = System.Type.GetType("System.Decimal");
                 dataColumn.DefaultValue = 1.0;
                 dataTable.Columns.Add(dataColumn);
             }
             this.ViewState["ResourcesTable"] = dataTable;
             this.gvResource.DataSource       = dataTable;
             this.gvResource.DataBind();
         }
     }
     this.hfldResourceId.Value = string.Empty;
 }
예제 #2
0
    private void BindGv()
    {
        DataTable dataTable = new DataTable();

        if (this.hfldIsWBSRelevance.Value == "1")
        {
            HttpCookie httpCookie = base.Request.Cookies[this.modifyTaskId];
            System.Collections.Generic.List <BudModifyTaskRes> list = new System.Collections.Generic.List <BudModifyTaskRes>();
            if (httpCookie == null)
            {
                goto IL_353;
            }
            string value = httpCookie.Value;
            if (!string.IsNullOrEmpty(value))
            {
                list = JsonConvert.DeserializeObject <System.Collections.Generic.List <BudModifyTaskRes> >(value);
            }
            System.Collections.Generic.List <string> list2 = new System.Collections.Generic.List <string>();
            foreach (BudModifyTaskRes current in list)
            {
                list2.Add(current.ResourceId);
            }
            dataTable = BudModifyTaskResBll.showResForAdd(DBHelper.GetInParameterSql(list2.ToArray()), this.modifyTaskId);
            System.Collections.IEnumerator enumerator2 = dataTable.Rows.GetEnumerator();
            try
            {
                while (enumerator2.MoveNext())
                {
                    DataRow dataRow = (DataRow)enumerator2.Current;
                    string  b       = dataRow["ResourceId"].ToString();
                    foreach (BudModifyTaskRes current2 in list)
                    {
                        if (current2.ResourceId == b)
                        {
                            dataRow["price"]           = current2.ResourcePrice;
                            dataRow["number"]          = current2.ResourceQuantity;
                            dataRow["LossCoefficient"] = ((!current2.LossCoefficient.HasValue) ? new decimal?(1m) : current2.LossCoefficient);
                            break;
                        }
                    }
                }
                goto IL_353;
            }
            finally
            {
                System.IDisposable disposable = enumerator2 as System.IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
        HttpCookie httpCookie2 = base.Request.Cookies[this.modifyId];

        System.Collections.Generic.List <BudModifyTaskRes> list3 = new System.Collections.Generic.List <BudModifyTaskRes>();
        if (httpCookie2 != null)
        {
            string value2 = httpCookie2.Value;
            if (!string.IsNullOrEmpty(value2))
            {
                list3 = JsonConvert.DeserializeObject <System.Collections.Generic.List <BudModifyTaskRes> >(value2);
            }
            System.Collections.Generic.List <string> list4 = new System.Collections.Generic.List <string>();
            foreach (BudModifyTaskRes current3 in list3)
            {
                list4.Add(current3.ResourceId);
            }
            dataTable = BudModifyTaskResBll.showResForAddByModify(DBHelper.GetInParameterSql(list4.ToArray()), this.modifyId);
            foreach (DataRow dataRow2 in dataTable.Rows)
            {
                string b2 = dataRow2["ResourceId"].ToString();
                foreach (BudModifyTaskRes current4 in list3)
                {
                    if (current4.ResourceId == b2)
                    {
                        dataRow2["price"]           = current4.ResourcePrice;
                        dataRow2["number"]          = current4.ResourceQuantity;
                        dataRow2["LossCoefficient"] = ((!current4.LossCoefficient.HasValue) ? new decimal?(1m) : current4.LossCoefficient);
                        break;
                    }
                }
            }
        }
IL_353:
        this.ViewState["ResourcesTable"] = dataTable;
        this.gvResource.DataSource       = dataTable;
        this.gvResource.DataBind();
    }