public void TempDataInsert(DataTable dtTask, DataTable dtResource) { TempWbsInfoCollection tempWbsInfoCollection = new TempWbsInfoCollection(); for (int i = 0; i < dtTask.Rows.Count; i++) { tempWbsInfoCollection.Add(new TempWbsInfo { ProjectCode = this.PrjCodeValue, TaskCode = dtTask.Rows[i]["F2"].ToString().Trim(), TaskName = dtTask.Rows[i]["F3"].ToString().Trim(), Unit = dtTask.Rows[i]["F4"].ToString().Trim(), Quantity = (dtTask.Rows[i]["F5"].ToString().Trim() == "") ? "0" : dtTask.Rows[i]["F5"].ToString().Trim(), UnitPrice = (dtTask.Rows[i]["F6"].ToString().Trim() == "") ? "0" : dtTask.Rows[i]["F6"].ToString().Trim(), SumPrice = (dtTask.Rows[i]["F7"].ToString().Trim() == "") ? "0" : dtTask.Rows[i]["F7"].ToString().Trim(), Remark = dtTask.Rows[i]["F8"].ToString().Trim(), Content = 0m }); } TempResourceInfoCollection tempResourceInfoCollection = new TempResourceInfoCollection(); for (int j = 0; j < dtResource.Rows.Count; j++) { TempResourceInfo tempResourceInfo = new TempResourceInfo(); tempResourceInfo.ListCode = dtResource.Rows[j][0].ToString().Trim(); tempResourceInfo.ListName = dtResource.Rows[j][1].ToString().Trim(); tempResourceInfo.FeeStyle = ((dtResource.Rows[j][2].ToString().Trim() == "") ? "0" : dtResource.Rows[j][2].ToString().Trim()); tempResourceInfo.SourceName = dtResource.Rows[j][3].ToString().Trim(); tempResourceInfo.SourceUnit = ((dtResource.Rows[j][4].ToString().Trim() == "") ? "0" : dtResource.Rows[j][4].ToString().Trim()); tempResourceInfo.SourcePrice = ((dtResource.Rows[j][5].ToString().Trim() == "") ? "0" : dtResource.Rows[j][5].ToString().Trim()); tempResourceInfo.Quantity = ((dtResource.Rows[j][6].ToString().Trim() == "") ? "0" : dtResource.Rows[j][6].ToString().Trim()); tempResourceInfo.Fee = ((dtResource.Rows[j][7].ToString().Trim() == "") ? "0" : dtResource.Rows[j][7].ToString().Trim()); tempResourceInfo.Fee1 = ((dtResource.Rows[j][8].ToString().Trim() == "") ? "0" : dtResource.Rows[j][8].ToString().Trim()); if (this.ImportType != 1 && this.ImportType != 3) { tempResourceInfo.Content = Convert.ToDecimal((dtResource.Rows[j][9].ToString().Trim() == "") ? "0" : dtResource.Rows[j][9].ToString().Trim()); tempResourceInfo.Fee = Convert.ToString(Convert.ToDecimal(tempResourceInfo.SourcePrice) * Convert.ToDecimal(tempResourceInfo.Quantity)); } else { tempResourceInfo.Content = 0m; } tempResourceInfoCollection.Add(tempResourceInfo); } this.tw.TempTaskInsert(tempWbsInfoCollection, tempResourceInfoCollection, this.PrjCodeValue, this.ImportType.ToString()); }
public void TempDataInsert1(DataTable dtTask) { TempWbsInfoCollection tempWbsInfoCollection = new TempWbsInfoCollection(); for (int i = 0; i < dtTask.Rows.Count; i++) { tempWbsInfoCollection.Add(new TempWbsInfo { ProjectCode = this.PrjCodeValue, TaskCode = dtTask.Rows[i]["F2"].ToString().Trim(), TaskName = dtTask.Rows[i]["F3"].ToString().Trim(), Unit = dtTask.Rows[i]["F4"].ToString().Trim(), Quantity = (dtTask.Rows[i]["F5"].ToString().Trim() == "") ? "0" : dtTask.Rows[i]["F5"].ToString().Trim(), UnitPrice = (dtTask.Rows[i]["F6"].ToString().Trim() == "") ? "0" : dtTask.Rows[i]["F6"].ToString().Trim(), SumPrice = (dtTask.Rows[i]["F7"].ToString().Trim() == "") ? "0" : dtTask.Rows[i]["F7"].ToString().Trim() }); } TempResourceInfoCollection resourceList = new TempResourceInfoCollection(); this.tw.TempTaskInsert(tempWbsInfoCollection, resourceList, this.PrjCodeValue); }
public bool TempTaskInsert(TempWbsInfoCollection taskList, TempResourceInfoCollection resourceList, string projectCode) { int num = 1; int num2 = 1; int num3 = 1; string str = ""; string str2 = ""; string str3 = ""; string format = ""; format = " insert into TMP_TaskList Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}') "; string str5 = " begin "; str5 = (str5 + " delete from TMP_TaskList where ProjectCode='" + projectCode + "' ") + " delete from TMP_ListSource where ProjectCode='" + projectCode + "'"; for (int i = 0; i < taskList.Count; i++) { if (i == 0) { str = num.ToString().PadLeft(3, '0'); str5 = str5 + string.Format(format, new object[] { projectCode, str, taskList[i].TaskCode, taskList[i].TaskName, taskList[i].Unit, taskList[i].Quantity, taskList[i].UnitPrice, taskList[i].SumPrice, taskList[i].Content, taskList[i].Remark }); num++; num2 = 1; num3 = 1; } else if (taskList[i].Unit.Trim() == "") { if (VerifyHelper.IsInt32(taskList[i].TaskCode)) { str2 = str + num2.ToString().PadLeft(3, '0'); str5 = str5 + string.Format(format, new object[] { projectCode, str2, taskList[i].TaskCode, taskList[i].TaskName, taskList[i].Unit, taskList[i].Quantity, taskList[i].UnitPrice, taskList[i].SumPrice, taskList[i].Content, taskList[i].Remark }); num2++; num3 = 1; } else { str = num.ToString().PadLeft(3, '0'); str5 = str5 + string.Format(format, new object[] { projectCode, str, taskList[i].TaskCode, taskList[i].TaskName, taskList[i].Unit, taskList[i].Quantity, taskList[i].UnitPrice, taskList[i].SumPrice, taskList[i].Content, taskList[i].Remark }); num++; num2 = 1; num3 = 1; } } else { str3 = str2 + num3.ToString().PadLeft(3, '0'); str5 = str5 + string.Format(format, new object[] { projectCode, str3, taskList[i].TaskCode, taskList[i].TaskName, taskList[i].Unit, taskList[i].Quantity, taskList[i].UnitPrice, taskList[i].SumPrice, taskList[i].Content, taskList[i].Remark }); num3++; } } for (int j = 0; j < resourceList.Count; j++) { string sqlString = "select top 1 ResourceCode,ResourceStyle from EPM_Res_Resource where (ResourceName+specification) = '" + resourceList[j].SourceName.Trim() + " '"; string str7 = ""; string str8 = "0"; DataTable table = publicDbOpClass.DataTableQuary(sqlString); if (table.Rows.Count != 0) { str7 = table.Rows[0][0].ToString(); string str9 = table.Rows[0][1].ToString(); if (str9 == null) { goto Label_04C8; } if (!(str9 == "1")) { if (str9 == "2") { goto Label_04B6; } if (str9 == "3") { goto Label_04BF; } goto Label_04C8; } str8 = "人工费"; } goto Label_04CF; Label_04B6: str8 = "材料费"; goto Label_04CF; Label_04BF: str8 = "机械费"; goto Label_04CF; Label_04C8: str8 = "0"; Label_04CF: format = " insert into TMP_ListSource values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')"; str5 = str5 + string.Format(format, new object[] { projectCode, resourceList[j].ListCode, resourceList[j].ListName, str8, resourceList[j].SourceName, resourceList[j].SourceUnit, resourceList[j].SourcePrice, resourceList[j].Quantity, resourceList[j].Fee, resourceList[j].Fee1, str7, resourceList[j].Content }); } return(publicDbOpClass.NonQuerySqlString(str5 + " end ")); }