public static bool UpdResource(SLTaskResource res) { string sqlString = ""; sqlString = " select UnitPrice,Quantity*UnitPrice as sumPrice from EPM_Task_Resource where NoteId = " + res.NoteID.ToString(); DataTable table = publicDbOpClass.DataTableQuary(sqlString); string str2 = string.Format("{0:F2}", Convert.ToDecimal(table.Rows[0][0].ToString())); string str3 = string.Format("{0:F2}", Convert.ToDecimal(table.Rows[0][1].ToString())); string str4 = string.Format("{0:F2}", Convert.ToDecimal(res.UnitPrice)); string str5 = string.Format("{0:F2}", Convert.ToDecimal((decimal)(res.Quantity * res.UnitPrice))); if (str2 != str4) { DataTable table2 = publicDbOpClass.DataTableQuary(string.Concat(new object[] { "select TaskCode from EPM_Task_Resource where ResourceCode = '", res.ResourceCode, "' and projectcode = '", res.ProjectCode, "' and WbsType='", res.WbsType, "'" })); sqlString = " begin "; string str7 = sqlString; object obj2 = (str7 + " update EPM_Task_Resource set Quantity=" + res.Quantity.ToString() + ",UnitPrice=" + res.UnitPrice.ToString() + ",Fee1=" + res.Fee1.ToString() + ",Fee=" + res.Fee.ToString()) + " where NoteId = " + res.NoteID.ToString(); sqlString = string.Concat(new object[] { obj2, " update EPM_Task_Resource set UnitPrice = ", res.UnitPrice.ToString(), " where ResourceCode = '", res.ResourceCode, "' and projectcode = '", res.ProjectCode, "' and WbsType='", res.WbsType, "'" }); for (int i = 0; i < table2.Rows.Count; i++) { sqlString = sqlString + GetSQL(res.ProjectCode, table2.Rows[i][0].ToString(), res.WbsType); } sqlString = sqlString + " end "; } if ((str2 == str4) && (str3 != str5)) { sqlString = " begin "; string str8 = sqlString; sqlString = ((str8 + " update EPM_Task_Resource set Quantity=" + res.Quantity.ToString() + ",UnitPrice=" + res.UnitPrice.ToString() + ",Fee1=" + res.Fee1.ToString() + ",Fee=" + res.Fee.ToString()) + " where NoteId = " + res.NoteID.ToString()) + GetSQL(res.ProjectCode, res.TaskCode, res.WbsType) + " end "; } return(publicDbOpClass.NonQuerySqlString(sqlString)); }
protected void BtnDel_Click(object sender, EventArgs e) { SLTaskResource data = this.GetData(); if (TaskResourceAction.DelResource(data)) { this.JS.Text = "alert('删除成功!');"; this.DataGrid_Bind("1,2,3", this.WbsType); return; } this.JS.Text = "alert('删除失败!');"; }
private SLTaskResource GetData() { SLTaskResource sLTaskResource = new SLTaskResource(); sLTaskResource.NoteID = Convert.ToInt32(this.hdnNoteId.Value); sLTaskResource.ProjectCode = this.ProjectCode.ToString(); sLTaskResource.TaskCode = this.TaskCode; sLTaskResource.WbsType = this.WbsType; sLTaskResource.ResourceCode = this.TxtResourceCode.Text.Trim(); try { sLTaskResource.Quantity = Convert.ToDecimal(this.TxtQuantity.Text.Trim()); } catch { sLTaskResource.Quantity = 0m; } try { sLTaskResource.UnitPrice = Convert.ToDecimal(this.TxtPrice.Text.Trim()); } catch { sLTaskResource.UnitPrice = 0m; } try { sLTaskResource.Fee = Convert.ToDecimal(sLTaskResource.Quantity * sLTaskResource.UnitPrice); } catch { sLTaskResource.Fee = 0m; } try { sLTaskResource.Fee1 = Convert.ToDecimal(this.TxtFee1.Text.Trim()); } catch { sLTaskResource.Fee1 = 0m; } return(sLTaskResource); }
public static bool DelResource(SLTaskResource res) { string str = ""; return(publicDbOpClass.NonQuerySqlString(((str + " begin ") + " delete from EPM_Task_Resource where NoteId = " + res.NoteID) + GetSQL(res.ProjectCode, res.TaskCode, res.WbsType) + " end ")); }