private void UpdateSheet() { IList <string> list = new List <string>(); if (this.hfldSheetId.Value.Contains("[")) { ISerializable serializable = new cn.justwin.Serialize.JsonSerializer(); string[] array = serializable.Deserialize <string[]>(this.hfldSheetId.Value); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string item = array2[i]; list.Add(item); } } else { list.Add(this.hfldSheetId.Value); } this.incometModifyBll.DeleteSheet(this.hdGuid.Value); if (list.Count > 0) { foreach (string current in list) { this.incometModifyBll.InsertSheet(this.hdGuid.Value, current); } } }
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; }
private void DataBindSheet(string modifyId) { List <int> list = new List <int>(); StringBuilder stringBuilder = new StringBuilder(); DataTable sheet = this.incometModifyBll.GetSheet(modifyId); foreach (DataRow dataRow in sheet.Rows) { int num = Convert.ToInt32(dataRow["TechnologyId"]); list.Add(num); string sheetNameById = this.incometModifyBll.GetSheetNameById(num); stringBuilder.Append(sheetNameById).Append(","); } ISerializable serializable = new cn.justwin.Serialize.JsonSerializer(); this.hfldSheetId.Value = serializable.Serialize <int[]>(list.ToArray()); this.txtSheetName.Value = stringBuilder.ToString(); }
public static string JsonSerializer <T>(T t) { cn.justwin.Serialize.JsonSerializer serializer = new cn.justwin.Serialize.JsonSerializer(); return(serializer.Serialize <T>(t)); }
public static T JsonDeserialize <T>(string jsonString) where T : class { cn.justwin.Serialize.JsonSerializer serializer = new cn.justwin.Serialize.JsonSerializer(); return(serializer.Deserialize <T>(jsonString)); }
public static DataTable getResources(string ids) { string strIDs = ids; DataTable dataTable = null; //["4b0ae68c-ff0b-403c-bcd5-39a0d07a7ee0|000400002|99","82eddac8-0546-447f-b96b-eacd75d7d9f1|000400001|66"] if (!string.IsNullOrEmpty(strIDs)) { //b89b1b0c - 6d3b - 4b37 - a5f1 - eafdd81f0acb | 000400005 | 1,a7ca9325 - 91dd - 4026 - 9dd6 - fbd4482c81a8 | 000400002 | 1,563c0bc1 - f223 - 4db9 - 928d - 2177e1d1e0c0 | 000400004 | 1 ISerializable serializable = new cn.justwin.Serialize.JsonSerializer(); string[] array = serializable.Deserialize <string[]>(strIDs); //string[] array = strIDs.Split(','); ; //4b0ae68c - ff0b - 403c - bcd5 - 39a0d07a7ee0 | 000400002 | 99 //82eddac8 - 0546 - 447f - b96b - eacd75d7d9f1 | 000400001 | 66 string[] array2 = null; if (array != null) { string strIDS = string.Empty; foreach (string str in array) { strIDS += "'" + str.Split('|')[0].ToString().Trim() + "',"; } string strSQL = "select FID,CID,NUM from Res_ResourceRelation where FID in (" + strIDS.Substring(0, strIDS.Length - 1) + ")"; DataTable dt = publicDbOpClass.DataTableQuary(strSQL); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { foreach (string str in array) { string strID = str.Split('|')[0].ToString(); string strNUM = str.Split('|')[2].ToString(); if (dr["FID"].ToString() == strID) { try { dr["NUM"] = Convert.ToString(Convert.ToDouble(dr["NUM"].ToString().Trim()) * Convert.ToDouble(strNUM)); } catch { } } } } array2 = new string[dt.Rows.Count]; int ii = 0; foreach (DataRow dr in dt.Rows) { array2[ii] = dr["CID"].ToString().Trim(); ii++; } string str2 = "select CID from Res_ResourceRelation where FID in (" + strIDS.Substring(0, strIDS.Length - 1) + ")"; string strSql2 = @"select distinct p1.ResourceId, 0.000 as number,p1.ResourceCode scode,0.000 sprice,0.000 Total, '' CorpId ,'' Corp,0.000 snumber,p1.ResourceName,p1.Specification,p4.Name ,p1.Brand,ModelNumber,TechnicalParameter from dbo.Res_Resource as p1 left join Res_Unit as p4 on p1.Unit=p4.UnitID WHERE 1 = 1 and p1.ResourceId in(" + str2 + ")"; dataTable = publicDbOpClass.DataTableQuary(strSql2); if (dt != null && dt.Rows.Count > 0 && dataTable != null && dataTable.Rows.Count > 0) { foreach (DataRow drA in dataTable.Rows) { foreach (DataRow drB in dt.Rows) { string number = drA["number"].ToString(); string ResourceId = drA["ResourceId"].ToString(); string NUM = drB["NUM"].ToString(); string CID = drB["CID"].ToString(); if (ResourceId == CID) { try { double db = Convert.ToDouble(drA["number"].ToString()); db += Convert.ToDouble(NUM); drA["number"] = db.ToString(); } catch { } } } } } } } } return(dataTable); }
//if (dt.Rows.Count > 0) //{ // foreach (DataRow dr in dt.Rows) // { // foreach (string str3 in array) // { // string strID = str3.Split('|')[0].ToString(); // string strNUM = str3.Split('|')[2].ToString(); // if (dr["FID"].ToString() == strID) // { // try // { // dr["NUM"] = Convert.ToString(Convert.ToDouble(dr["NUM"].ToString().Trim()) * Convert.ToDouble(strNUM)); // } // catch // { // } // } // } // } //} //return dt; //} private DataTable GetList(string tsid, string tcode, string ids) { string str = "''"; if (!string.IsNullOrEmpty(tsid)) { str = ""; foreach (string str2 in JsonHelper.GetListFromJson(tsid)) { string[] strArray = str2.Split(new char[] { '|' }); str = str + treasuryStock2.GetTsidBySSc(strArray[0], strArray[1], strArray[2], tcode); } if (str.Length > 0) { str = str.Substring(0, str.Length - 1); } } else { str = "''"; } string strIDs = string.Empty; //DataTable dataTable = null; //["4b0ae68c-ff0b-403c-bcd5-39a0d07a7ee0|000400002|99","82eddac8-0546-447f-b96b-eacd75d7d9f1|000400001|66"] if (!string.IsNullOrEmpty(ids)) { //b89b1b0c - 6d3b - 4b37 - a5f1 - eafdd81f0acb | 000400005 | 1,a7ca9325 - 91dd - 4026 - 9dd6 - fbd4482c81a8 | 000400002 | 1,563c0bc1 - f223 - 4db9 - 928d - 2177e1d1e0c0 | 000400004 | 1 ISerializable serializable = new cn.justwin.Serialize.JsonSerializer(); string[] array = serializable.Deserialize <string[]>(ids); //string[] array = strIDs.Split(','); ; //4b0ae68c - ff0b - 403c - bcd5 - 39a0d07a7ee0 | 000400002 | 99 //82eddac8 - 0546 - 447f - b96b - eacd75d7d9f1 | 000400001 | 66 //string[] array2 = null; if (array != null) { //string strIDS = string.Empty; foreach (string str2 in array) { strIDs += "'" + str2.Split('|')[0].ToString().Trim() + "',"; } strIDs = strIDs.Substring(0, strIDs.Length - 1); } else { strIDs = "''"; } } else { strIDs = "''"; } string strXQID = ""; DataTable dtTemp = BindNeedNote(); if (dtTemp != null && dtTemp.Rows.Count > 0) { foreach (DataRow dr in dtTemp.Rows) { strXQID += "'" + dr["scode"].ToString() + "',"; } strXQID = strXQID.Substring(0, strXQID.Length - 1); } else { strXQID = "''"; } // string strSQL = "select FID,CID,NUM from Res_ResourceRelation where FID in (" + strIDS.Substring(0, strIDS.Length - 1) + ")"; // string strSQL1 = string.Format(@"--with t as // select distinct --s.tsid,s.scode,s.snumber,t.NUM,p1.ResourceId, // 0.000 as number,p1.ResourceCode scode,s.sprice sprice,(0*s.sprice) Total, // ISNULL(s.Corp,'') as CorpId ,p5.corpName Corp,s.snumber snumber,p1.ResourceName,p1.Specification,p4.Name // ,p1.Brand,ModelNumber,TechnicalParameter // from dbo.Res_Resource as p1 // left join Res_Unit as p4 on p1.Unit=p4.UnitID //left join (select FID,CID,NUM NUM from Res_ResourceRelation where FID in ({0})) t on t.CID=p1.ResourceId //right join Sm_Treasury_Stock s on s.scode= p1.ResourceCode //left join dbo.XPM_Basic_ContactCorp as p5 on ISNULL(s.corp,'') = p5.CorpId // WHERE 1 = 1 and ((s.tcode= '{1}' and p1.ResourceId in( //select CID from Res_ResourceRelation where FID in ({0}))) //or (s.tsid in({2}))) order by scode asc; ", strIDs, tcode, str); string strSQL = string.Format(@"SELECT number,scode,sprice,Total,CorpId,Corp,SUM(snumber) snumber,ResourceName,Specification,Name,Brand,ModelNumber,TechnicalParameter from ( select distinct --s.tsid,s.scode,s.snumber,t.NUM,p1.ResourceId, 0.000 as number,p1.ResourceCode scode,s.sprice sprice,(0*s.sprice) Total, ISNULL(s.Corp,'') as CorpId ,p5.corpName Corp,s.snumber snumber,p1.ResourceName,p1.Specification,p4.Name ,p1.Brand,ModelNumber,TechnicalParameter from dbo.Res_Resource as p1 left join Res_Unit as p4 on p1.Unit=p4.UnitID left join (select FID,CID,NUM NUM from Res_ResourceRelation where FID in ({0})) t on t.CID=p1.ResourceId right join Sm_Treasury_Stock s on s.scode= p1.ResourceCode left join dbo.XPM_Basic_ContactCorp as p5 on ISNULL(s.corp,'') = p5.CorpId WHERE 1 = 1 and ((s.tcode= '{1}' and (p1.ResourceId in( select CID from Res_ResourceRelation where FID in ({0})) or p1.ResourceCode in({3})) ) or (s.tsid in({2}))) ) t GROUP BY number,scode,sprice,Total,CorpId,Corp,ResourceName,Specification,Name,Brand,ModelNumber,TechnicalParameter order by scode asc; " , strIDs, tcode, str, strXQID); DataTable dt = publicDbOpClass.DataTableQuary(strSQL); return(dt); #region //if (dt.Rows.Count > 0) //{ // foreach (DataRow dr in dt.Rows) // { // foreach (string str3 in array) // { // string strID = str3.Split('|')[0].ToString(); // string strNUM = str3.Split('|')[2].ToString(); // if (dr["ResourceId"].ToString() == strID) // { // try // { // dr["NUM"] = Convert.ToString(Convert.ToDouble(dr["NUM"].ToString().Trim()) * Convert.ToDouble(strNUM)); // } // catch // { // } // } // } // } //} // return publicDbOpClass.DataTableQuary(strSQL); //string strIDs = ids; //DataTable dataTable = null; ////["4b0ae68c-ff0b-403c-bcd5-39a0d07a7ee0|000400002|99","82eddac8-0546-447f-b96b-eacd75d7d9f1|000400001|66"] //if (!string.IsNullOrEmpty(strIDs)) //{ // //b89b1b0c - 6d3b - 4b37 - a5f1 - eafdd81f0acb | 000400005 | 1,a7ca9325 - 91dd - 4026 - 9dd6 - fbd4482c81a8 | 000400002 | 1,563c0bc1 - f223 - 4db9 - 928d - 2177e1d1e0c0 | 000400004 | 1 // ISerializable serializable = new cn.justwin.Serialize.JsonSerializer(); // string[] array = serializable.Deserialize<string[]>(strIDs); // //string[] array = strIDs.Split(','); ; // //4b0ae68c - ff0b - 403c - bcd5 - 39a0d07a7ee0 | 000400002 | 99 // //82eddac8 - 0546 - 447f - b96b - eacd75d7d9f1 | 000400001 | 66 // string[] array2 = null; // if (array != null) // { // string strIDS = string.Empty; // foreach (string str in array) // { // strIDS += "'" + str.Split('|')[0].ToString().Trim() + "',"; // } // string strSQL = "select FID,CID,NUM from Res_ResourceRelation where FID in (" + strIDS.Substring(0, strIDS.Length - 1) + ")"; // DataTable dt = publicDbOpClass.DataTableQuary(strSQL); // if (dt.Rows.Count > 0) // { // foreach (DataRow dr in dt.Rows) // { // foreach (string str in array) // { // string strID = str.Split('|')[0].ToString(); // string strNUM = str.Split('|')[2].ToString(); // if (dr["FID"].ToString() == strID) // { // try // { // dr["NUM"] = Convert.ToString(Convert.ToDouble(dr["NUM"].ToString().Trim()) * Convert.ToDouble(strNUM)); // } // catch // { // } // } // } // } // array2 = new string[dt.Rows.Count]; // int ii = 0; // foreach (DataRow dr in dt.Rows) // { // array2[ii] = dr["CID"].ToString().Trim(); // ii++; // } // string str2 = "select CID from Res_ResourceRelation where FID in (" + strIDS.Substring(0, strIDS.Length - 1) + ")"; // string strSql2 = @"select distinct p1.ResourceId, 0.000 as number,p1.ResourceCode scode,0.000 sprice,0.000 Total, // '' CorpId ,'' Corp,0.000 snumber,p1.ResourceName,p1.Specification,p4.Name // ,p1.Brand,ModelNumber,TechnicalParameter // from dbo.Res_Resource as p1 // left join Res_Unit as p4 on p1.Unit=p4.UnitID // WHERE 1 = 1 and p1.ResourceId in(" + str2 + ")"; // dataTable = publicDbOpClass.DataTableQuary(strSql2); // if (dt != null && dt.Rows.Count > 0 && dataTable != null && dataTable.Rows.Count > 0) // { // foreach (DataRow drA in dataTable.Rows) // { // foreach (DataRow drB in dt.Rows) // { // string number = drA["number"].ToString(); // string ResourceId = drA["ResourceId"].ToString(); // string NUM = drB["NUM"].ToString(); // string CID = drB["CID"].ToString(); // if (ResourceId == CID) // { // try // { // double db = Convert.ToDouble(drA["number"].ToString()); // db += Convert.ToDouble(NUM); // drA["number"] = db.ToString(); // } // catch // { // } // } // } // } // } // } // } //} //return null; #endregion }
private DataTable GetList(string ids) { string strIDs = string.Empty; //DataTable dataTable = null; //["4b0ae68c-ff0b-403c-bcd5-39a0d07a7ee0|000400002|99","82eddac8-0546-447f-b96b-eacd75d7d9f1|000400001|66"] if (!string.IsNullOrEmpty(ids)) { //b89b1b0c - 6d3b - 4b37 - a5f1 - eafdd81f0acb | 000400005 | 1,a7ca9325 - 91dd - 4026 - 9dd6 - fbd4482c81a8 | 000400002 | 1,563c0bc1 - f223 - 4db9 - 928d - 2177e1d1e0c0 | 000400004 | 1 ISerializable serializable = new cn.justwin.Serialize.JsonSerializer(); string[] array = serializable.Deserialize <string[]>(ids); //string[] array = strIDs.Split(','); ; //4b0ae68c - ff0b - 403c - bcd5 - 39a0d07a7ee0 | 000400002 | 99 //82eddac8 - 0546 - 447f - b96b - eacd75d7d9f1 | 000400001 | 66 //string[] array2 = null; if (array != null) { //string strIDS = string.Empty; foreach (string str2 in array) { strIDs += "'" + str2.Split('|')[0].ToString().Trim() + "',"; } strIDs = strIDs.Substring(0, strIDs.Length - 1); } else { strIDs = "''"; } string strSQLA = string.Format(@"--with t as (select FID,CID,NUM NUM from Res_ResourceRelation where FID in ({0})) select distinct p1.ResourceId, 0.000 NUM,0.000 as number,p1.ResourceCode scode,0.000 sprice,0.000 Total, '' CorpId ,'' Corp,0.000 snumber,p1.ResourceName,p1.Specification,p4.Name ,p1.Brand,ModelNumber,TechnicalParameter from dbo.Res_Resource as p1 left join Res_Unit as p4 on p1.Unit=p4.UnitID --left join t on t.CID=p1.ResourceId left join Sm_Treasury_Stock s on s.scode= p1.ResourceCode WHERE 1 = 1 and p1.ResourceId in( select CID from Res_ResourceRelation where FID in ({0})) order by scode asc", strIDs); DataTable dtA = publicDbOpClass.DataTableQuary(strSQLA); //----------------------------------------------------------------- string strSQLB = "select FID,CID,NUM from Res_ResourceRelation where FID in (" + strIDs + ")"; DataTable dtB = publicDbOpClass.DataTableQuary(strSQLB); if (dtB != null && dtB.Rows.Count > 0) { foreach (DataRow dr in dtB.Rows) { foreach (string str in array) { string strID = str.Split('|')[0].ToString(); string strNUM = str.Split('|')[2].ToString(); if (dr["FID"].ToString() == strID) { try { dr["NUM"] = Convert.ToString(Convert.ToDouble(dr["NUM"].ToString().Trim()) * Convert.ToDouble(strNUM)); } catch { } } } } } if (dtA != null && dtA.Rows.Count > 0 && dtB != null && dtB.Rows.Count > 0) { foreach (DataRow drA in dtA.Rows) { foreach (DataRow drB in dtB.Rows) { string number = drA["NUM"].ToString(); string ResourceId = drA["ResourceId"].ToString(); string NUM = drB["NUM"].ToString(); string CID = drB["CID"].ToString(); if (ResourceId == CID) { try { double db = Convert.ToDouble(drA["NUM"].ToString()); db += Convert.ToDouble(NUM); drA["NUM"] = db.ToString(); } catch { } } } } } return(dtA); } else { return(null); } }
private void InitResource(string resources) { if (!string.IsNullOrEmpty(resources)) { ISerializable serializable = new cn.justwin.Serialize.JsonSerializer(); string[] array = serializable.Deserialize <string[]>(resources); if (array != null) { cn.justwin.BLL.Resource resource = new cn.justwin.BLL.Resource(); DataTable resource2 = resource.GetResource(array); DataColumn dataColumn = new DataColumn("sprice", typeof(decimal)); dataColumn.DefaultValue = 0.000m; DataColumn dataColumn2 = new DataColumn("number", typeof(decimal)); dataColumn2.DefaultValue = 0m; DataColumn dataColumn3 = new DataColumn("Total", typeof(decimal)); dataColumn3.DefaultValue = 0m; DataColumn dataColumn4 = new DataColumn("pscode", typeof(string)); dataColumn4.DefaultValue = string.Empty; resource2.Columns.Add(dataColumn4); DataColumn dataColumn5 = new DataColumn("ModifyStockId", typeof(string)); dataColumn5.DefaultValue = string.Empty; resource2.Columns.Add(dataColumn5); resource2.Columns.Add(dataColumn2); resource2.Columns.Add(dataColumn); resource2.Columns.Add(dataColumn3); string conPurchasePcode = this.purchase.GetConPurchasePcode(this.contractId); List <string> resourceNumber = this.GetResourceNumber(); for (int i = 0; i < resource2.Rows.Count; i++) { DataRow dataRow = resource2.Rows[i]; dataRow["pscode"] = conPurchasePcode; try { dataRow["number"] = Convert.ToDecimal(resourceNumber[i]); } catch { } } DataColumn dataColumn6 = new DataColumn("corp", typeof(string)); dataColumn6.DefaultValue = this.hfldBId.Value; resource2.Columns.Add(dataColumn6); DataColumn dataColumn7 = new DataColumn("CorpName", typeof(string)); dataColumn7.DefaultValue = this.GetCorpName(this.hfldBId.Value); resource2.Columns.Add(dataColumn7); if (this.ViewState["resource"] == null) { this.ViewState["resource"] = resource2; } else { DataTable dataTable = this.ViewState["resource"] as DataTable; for (int j = 0; j < dataTable.Rows.Count; j++) { DataRow dataRow2 = dataTable.Rows[j]; for (int k = 0; k < array.Length; k++) { if (dataRow2["ResourceId"].ToString() == array[k]) { try { dataRow2["number"] = resourceNumber[k]; } catch { } } } } dataTable = this.MergeDataTable(dataTable, resource2); } this.DataBindPurchaseplanStock(); } } }
protected void btnBindResourceZZCL_Click(object sender, System.EventArgs e) { DataTable dt = null; //["4b0ae68c-ff0b-403c-bcd5-39a0d07a7ee0|000400002|99","82eddac8-0546-447f-b96b-eacd75d7d9f1|000400001|66"] if (!string.IsNullOrEmpty(this.hfldResourceIdsZZCL.Value)) { ISerializable serializable = new cn.justwin.Serialize.JsonSerializer(); string[] array = serializable.Deserialize <string[]>(this.hfldResourceIdsZZCL.Value); //4b0ae68c - ff0b - 403c - bcd5 - 39a0d07a7ee0 | 000400002 | 99 //82eddac8 - 0546 - 447f - b96b - eacd75d7d9f1 | 000400001 | 66 string[] array2 = null; if (array != null) { string strIDS = string.Empty; foreach (string str in array) { strIDS += "'" + str.Split('|')[0].ToString() + "',"; } string strSQL = "select FID,CID,NUM from Res_ResourceRelation where FID in (" + strIDS.Substring(0, strIDS.Length - 1) + ")"; dt = publicDbOpClass.DataTableQuary(strSQL); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { foreach (string str in array) { string strID = str.Split('|')[0].ToString(); string strNUM = str.Split('|')[2].ToString(); if (dr["FID"].ToString() == strID) { try { dr["NUM"] = Convert.ToString(Convert.ToDouble(dr["NUM"].ToString()) * Convert.ToDouble(strNUM)); } catch { } } } } array2 = new string[dt.Rows.Count]; int ii = 0; foreach (DataRow dr in dt.Rows) { array2[ii] = dr["CID"].ToString(); ii++; } } } //string[] array2 = new string[dt.Rows.Count]; if (array2 != null) { this.UpdateSelectResources(); //showMaterialListForAdd DataTable dataTable = this.materialStock.showMaterialListForAdd(DBHelper.GetInParameterSql(array2), this.prjId, string.Empty, 0); DataColumn dataColumn = new DataColumn(); dataColumn.ColumnName = "TaskName"; dataColumn.DataType = System.Type.GetType("System.String"); dataTable.Columns.Add(dataColumn); foreach (DataRow dataRow in dataTable.Rows) { dataRow["TaskId"] = string.Empty; dataRow["TaskName"] = string.Empty; dataRow["number"] = 0m; dataRow["arrivalDate"] = System.DBNull.Value; } dataTable.AcceptChanges(); DataTable dataTable2 = this.ViewState["ResourcesTable"] as DataTable; if (dataTable2 != null) { dataTable2.PrimaryKey = new DataColumn[] { dataTable2.Columns["ResourceCode"], dataTable2.Columns["TaskId"] }; dataTable.PrimaryKey = new DataColumn[] { dataTable.Columns["ResourceCode"], dataTable.Columns["TaskId"] }; dataTable2.Merge(dataTable, true); dataTable = dataTable2; } if (dt != null && dt.Rows.Count > 0 && dataTable != null && dataTable.Rows.Count > 0) { foreach (DataRow drA in dataTable.Rows) { foreach (DataRow drB in dt.Rows) { string number = drA["number"].ToString(); string ResourceId = drA["ResourceId"].ToString(); string NUM = drB["NUM"].ToString(); string CID = drB["CID"].ToString(); if (ResourceId == CID) { try { double db = Convert.ToDouble(drA["number"].ToString()); db += Convert.ToDouble(NUM); drA["number"] = db.ToString(); } catch { } } } } } this.ViewState["ResourcesTable"] = dataTable; DataTable dtCopy = dataTable.Copy(); try { DataColumn dataColumn1 = new DataColumn(); dataColumn1.ColumnName = "ResourceQuantity"; dataColumn1.DataType = System.Type.GetType("System.String"); dtCopy.Columns.Add(dataColumn1); DataColumn dataColumn2 = new DataColumn(); dataColumn2.ColumnName = "numberIng"; dataColumn2.DataType = System.Type.GetType("System.String"); dtCopy.Columns.Add(dataColumn2); } catch { } //DataTable dt = dtNum(); //foreach (DataRow drc in dtCopy.Rows) //{ // foreach (DataRow dr in dtNum().Rows) // { // if (drc["ResourceCode"].ToString().Trim() == dr["scode"].ToString().Trim()) // { // drc["ResourceQuantity"] = dr["ResourceQuantity"]; // drc["numberIng"] = dr["numberIng"]; // } // } //} this.gvSmWantPlanStock.DataSource = dtCopy; //this.gvSmWantPlanStock.DataSource = dataTable; this.gvSmWantPlanStock.DataBind(); } } this.hfldResourceIdsZZCL.Value = string.Empty; }
protected void btnBindResource_Click(object sender, System.EventArgs e) { if (!string.IsNullOrEmpty(this.hfldResourceIds.Value)) { ISerializable serializable = new cn.justwin.Serialize.JsonSerializer(); string[] array = serializable.Deserialize <string[]>(this.hfldResourceIds.Value); if (array != null) { this.UpdateSelectResources(); DataTable dataTable = this.materialStock.showMaterialListForAdd(DBHelper.GetInParameterSql(array), this.prjId, string.Empty, 0); DataColumn dataColumn = new DataColumn(); dataColumn.ColumnName = "TaskName"; dataColumn.DataType = System.Type.GetType("System.String"); dataTable.Columns.Add(dataColumn); foreach (DataRow dataRow in dataTable.Rows) { dataRow["TaskId"] = string.Empty; dataRow["TaskName"] = string.Empty; dataRow["number"] = 0m; dataRow["arrivalDate"] = System.DBNull.Value; } dataTable.AcceptChanges(); DataTable dataTable2 = this.ViewState["ResourcesTable"] as DataTable; if (dataTable2 != null) { dataTable2.PrimaryKey = new DataColumn[] { dataTable2.Columns["ResourceCode"], dataTable2.Columns["TaskId"] }; dataTable.PrimaryKey = new DataColumn[] { dataTable.Columns["ResourceCode"], dataTable.Columns["TaskId"] }; dataTable2.Merge(dataTable, true); dataTable = dataTable2; } //this.ViewState["ResourcesTable"] = dataTable; DataTable dtCopy = dataTable.Copy(); try { DataColumn dataColumn1 = new DataColumn(); dataColumn1.ColumnName = "ResourceQuantity"; dataColumn1.DataType = System.Type.GetType("System.String"); dtCopy.Columns.Add(dataColumn1); DataColumn dataColumn2 = new DataColumn(); dataColumn2.ColumnName = "numberIng"; dataColumn2.DataType = System.Type.GetType("System.String"); dtCopy.Columns.Add(dataColumn2); } catch { } //DataTable dt = dtNum(); foreach (DataRow drc in dtCopy.Rows) { foreach (DataRow dr in dtNum().Rows) { if (drc["ResourceCode"].ToString().Trim() == dr["scode"].ToString().Trim()) { drc["ResourceQuantity"] = dr["ResourceQuantity"]; drc["numberIng"] = dr["numberIng"]; } } } this.gvSmWantPlanStock.DataSource = dtCopy; //this.gvSmWantPlanStock.DataSource = dataTable; this.gvSmWantPlanStock.DataBind(); } } this.hfldResourceIds.Value = string.Empty; }