protected void btnAdd_Click(object sender, EventArgs e) { string[] RuleDetail = GetRuleDetail(); try { DbHelper.GetInstance().ExecSqlText(string.Format(" select {0} from Workflow_Form{1} where RequestID=0", RuleDetail[0], rblFieldType.SelectedValue == "1" ? "" : "Detail")); } catch { ScriptManager.RegisterStartupScript(btnAdd, this.GetType(), "add", "alert('赋值表达式不正确,无法添加');", true); return; } DataTable dtComputeRoute = (DataTable)ViewState["dtComputeRoute"]; Workflow_NodeAddInOperation_Type1_SpParameterEntity _Type1_SpParameterEntity = new Workflow_NodeAddInOperation_Type1_SpParameterEntity(); _Type1_SpParameterEntity.AddInOPID = DNTRequest.GetInt("opid", 0); _Type1_SpParameterEntity.SpParameter = ddlParameterList.SelectedValue; _Type1_SpParameterEntity.TartgetValue = GetRuleDetail()[0]; _Type1_SpParameterEntity.FieldTypeID = Int32.Parse(rblFieldType.SelectedValue); DbHelper.GetInstance().UpdateWorkflow_NodeAddInOperation_Type1_SpParameter(_Type1_SpParameterEntity, dtComputeRoute); dtComputeRoute.Rows.Clear(); lblExpression.Text = ""; BindGridView(); System.Web.UI.ScriptManager.RegisterStartupScript(btnAdd, this.GetType(), "ButtonHideScript", strButtonHideScript, false); }
protected void btnAdd_Click(object sender, EventArgs e) { Workflow_NodeAddInOperation_Type1Entity _Type1Entity = new Workflow_NodeAddInOperation_Type1Entity(); _Type1Entity.NodeID = DNTRequest.GetInt("id", 0); _Type1Entity.CaculateType = Convert.ToInt32(ddlCaculateType.SelectedValue); _Type1Entity.DataSourceID = Convert.ToInt32(txtDataSourceID.Value); _Type1Entity.DataSourceTable = ddlDataSourceTable.SelectedValue; _Type1Entity.GroupID = Convert.ToInt32(ddlGroupID.SelectedValue); _Type1Entity.SelectRange = "(1=1)"; _Type1Entity.OPCycleType = Convert.ToInt32(ddlOPCycleType.SelectedValue); _Type1Entity.OPTime = DNTRequest.GetInt("t", 0); _Type1Entity.OPCondition = "(1=1)"; _Type1Entity.CreateSID = userEntity.UserSerialID; _Type1Entity.CreateDate = DateTime.Now; string AddInOPID = DbHelper.GetInstance().AddWorkflow_NodeAddInOperation_Type1(_Type1Entity); if (ddlCaculateType.SelectedValue == "3") { DataTable dtSpParameter = DbHelper.GetInstance().GetAllStoredProcedureParameters(_Type1Entity.DataSourceID, _Type1Entity.DataSourceTable); for (int i = 0; i < dtSpParameter.Rows.Count; i++) { if ("ReturnValue" == dtSpParameter.Rows[i]["ParameterDirection"].ToString()) { continue; } Workflow_NodeAddInOperation_Type1_SpParameterEntity _Type1_SpParameterEntity = new Workflow_NodeAddInOperation_Type1_SpParameterEntity(); _Type1_SpParameterEntity.AddInOPID = Int32.Parse(AddInOPID); _Type1_SpParameterEntity.SpParameter = dtSpParameter.Rows[i]["ParameterName"].ToString(); _Type1_SpParameterEntity.ParameterType = dtSpParameter.Rows[i]["ParameterType"].ToString(); _Type1_SpParameterEntity.ParameterSize = Convert.ToInt32(dtSpParameter.Rows[i]["ParameterSize"]); _Type1_SpParameterEntity.ParameterDirection = dtSpParameter.Rows[i]["ParameterDirection"].ToString(); _Type1_SpParameterEntity.TartgetValue = ""; _Type1_SpParameterEntity.FieldTypeID = 0; DbHelper.GetInstance().AddWorkflow_NodeAddInOperation_Type1_SpParameter(_Type1_SpParameterEntity); } } BindGridView(); System.Web.UI.ScriptManager.RegisterStartupScript(btnAdd, this.GetType(), "ButtonHideScript", strButtonHideScript, false); }
protected void btnDel_Click(object sender, EventArgs e) { for (int i = 0; i < GridView1.Rows.Count; i++) { CheckBox cb = this.GridView1.Rows[i].FindControl("Item") as CheckBox; if (cb.Checked) { string SpParameter = GridView1.DataKeys[i][0].ToString().Trim(); Workflow_NodeAddInOperation_Type1_SpParameterEntity _Type1_SpParameterEntity = new Workflow_NodeAddInOperation_Type1_SpParameterEntity(); _Type1_SpParameterEntity.AddInOPID = DNTRequest.GetInt("opid", 0); _Type1_SpParameterEntity.SpParameter = SpParameter; _Type1_SpParameterEntity.TartgetValue = ""; _Type1_SpParameterEntity.FieldTypeID = 0; DataTable dtComputeRoute = (DataTable)ViewState["dtComputeRoute"]; DataTable dtComputeRoute2 = dtComputeRoute.Clone(); DbHelper.GetInstance().UpdateWorkflow_NodeAddInOperation_Type1_SpParameter(_Type1_SpParameterEntity, dtComputeRoute2); } } BindGridView(); System.Web.UI.ScriptManager.RegisterStartupScript(btnAdd, this.GetType(), "ButtonHideScript", strButtonHideScript, false); }
/// <summary> /// 更新信息 /// </summary> /// <param name="_Type1_SpParameterEntity"></param> /// <param name="dtComputeRoute"></param> /// <returns></returns> public string UpdateWorkflow_NodeAddInOperation_Type1_SpParameter(Workflow_NodeAddInOperation_Type1_SpParameterEntity _Type1_SpParameterEntity, DataTable dtComputeRoute) { DbParameter[] pramsUpdate = { MakeInParam("@AddInOPID",(DbType)SqlDbType.Int,4,_Type1_SpParameterEntity.AddInOPID ), MakeInParam("@SpParameter",(DbType)SqlDbType.VarChar,50,_Type1_SpParameterEntity.SpParameter ), MakeInParam("@TartgetValue",(DbType)SqlDbType.VarChar,2000,_Type1_SpParameterEntity.TartgetValue ), MakeInParam("@FieldTypeID",(DbType)SqlDbType.Int,4,_Type1_SpParameterEntity.FieldTypeID ), }; StringBuilder sb = new StringBuilder(); sb.Append("Update [dbo].[Workflow_NodeAddInOperation_Type1_SpParameter]"); sb.Append(" set "); sb.Append(" [TartgetValue]=@TartgetValue,"); sb.Append(" [FieldTypeID]=@FieldTypeID "); sb.Append(" where [AddInOPID]=@AddInOPID and [SpParameter]=@SpParameter "); ExecuteNonQuery(CommandType.Text, sb.ToString(), pramsUpdate).ToString(); DbParameter[] pramsDelete = { MakeInParam("@AddInOPID",(DbType)SqlDbType.Int,4,_Type1_SpParameterEntity.AddInOPID ), MakeInParam("@SpParameter",(DbType)SqlDbType.VarChar,50,_Type1_SpParameterEntity.SpParameter ), }; string sql = @" delete from [dbo].[Workflow_ComputeRouteSpParameter] where AddInOPID=@AddInOPID and SpParameter=@SpParameter; "; ExecuteNonQuery(CommandType.Text, sql, pramsDelete).ToString(); for (int i = 0; i < dtComputeRoute.Rows.Count; i++) { DbParameter[] pramsRouteInsert = { MakeInParam("@AddInOPID",(DbType)SqlDbType.Int,4,_Type1_SpParameterEntity.AddInOPID ), MakeInParam("@SpParameter",(DbType)SqlDbType.VarChar,50,_Type1_SpParameterEntity.SpParameter ), MakeInParam("@ComputeType",(DbType)SqlDbType.Int,4,dtComputeRoute.Rows[i]["ComputeType"] ), MakeInParam("@RouteValue",(DbType)SqlDbType.VarChar,50,dtComputeRoute.Rows[i]["RouteValue"] ), MakeInParam("@RouteOrder",(DbType)SqlDbType.Int,4,dtComputeRoute.Rows[i]["RouteOrder"] ), }; string sqlInsert = @" insert into Workflow_ComputeRouteSpParameter(AddInOPID,SpParameter,ComputeType,RouteValue,RouteOrder)values(@AddInOPID,@SpParameter,@ComputeType,@RouteValue,@RouteOrder) "; ExecuteScalar(CommandType.Text, sqlInsert, pramsRouteInsert); } return "1"; }
/// <summary> /// 新增信息 /// </summary> /// <param name="_Type1_SpParameterEntity"></param> /// <returns></returns> public string AddWorkflow_NodeAddInOperation_Type1_SpParameter(Workflow_NodeAddInOperation_Type1_SpParameterEntity _Type1_SpParameterEntity) { //判断该记录是否已经存在 DbParameter[] prams = { MakeInParam("@AddInOPID",(DbType)SqlDbType.Int,4,_Type1_SpParameterEntity.AddInOPID ), MakeInParam("@SpParameter",(DbType)SqlDbType.VarChar,100,_Type1_SpParameterEntity.SpParameter ), }; string sql = " SELECT * from [dbo].[Workflow_NodeAddInOperation_Type1_SpParameter] where AddInOPID=@AddInOPID and SpParameter=@SpParameter"; if (ExecuteDataset(CommandType.Text, sql, prams).Tables[0].Rows.Count > 0) { return "-1";//该记录已经存在 } else { DbParameter[] pramsInsert = { MakeInParam("@AddInOPID",(DbType)SqlDbType.Int,4,_Type1_SpParameterEntity.AddInOPID ), MakeInParam("@SpParameter",(DbType)SqlDbType.VarChar,100,_Type1_SpParameterEntity.SpParameter ), MakeInParam("@ParameterType",(DbType)SqlDbType.VarChar,50,_Type1_SpParameterEntity.ParameterType ), MakeInParam("@ParameterDirection",(DbType)SqlDbType.VarChar,50,_Type1_SpParameterEntity.ParameterDirection ), MakeInParam("@ParameterSize",(DbType)SqlDbType.Int,4,_Type1_SpParameterEntity.ParameterSize ), MakeInParam("@TartgetValue",(DbType)SqlDbType.VarChar,2000,_Type1_SpParameterEntity.TartgetValue ), MakeInParam("@FieldTypeID",(DbType)SqlDbType.Int,4,_Type1_SpParameterEntity.FieldTypeID ), }; StringBuilder sb = new StringBuilder(); sb.Append("INSERT INTO [dbo].[Workflow_NodeAddInOperation_Type1_SpParameter]"); sb.Append("("); sb.Append(" [AddInOPID]"); sb.Append(",[SpParameter]"); sb.Append(",[ParameterType]"); sb.Append(",[ParameterDirection]"); sb.Append(",[ParameterSize]"); sb.Append(",[TartgetValue]"); ; sb.Append(",[FieldTypeID]"); sb.Append(") "); sb.Append(" VALUES ("); sb.Append("@AddInOPID,"); sb.Append("@SpParameter,"); sb.Append("@ParameterType,"); sb.Append("@ParameterDirection,"); sb.Append("@ParameterSize,"); sb.Append("@TartgetValue,"); sb.Append("@FieldTypeID )"); sb.Append("select @@identity;"); return ExecuteScalar(CommandType.Text, sb.ToString(), pramsInsert).ToString(); } }