protected void btnSubmit_Click(object sender, EventArgs e) { DbHelper.GetInstance().DeleteWorkflow_NodeMainFieldControl(DNTRequest.GetString("id")); Workflow_NodeMainFieldControlEntity _NodeMainFieldControlEntity = new Workflow_NodeMainFieldControlEntity(); _NodeMainFieldControlEntity.NodeID = DNTRequest.GetInt("id", 0); for (int i = 0; i < GridView1.Rows.Count; i++) { string Prefix = "GridView1$ctl" + (i + 2).ToString().PadLeft(2, '0') + "$"; _NodeMainFieldControlEntity.FieldID = Convert.ToInt32(GridView1.DataKeys[i][0]); _NodeMainFieldControlEntity.IsView = DNTRequest.GetString(Prefix + "IsView") == "on" ? 1 : 0; _NodeMainFieldControlEntity.IsEdit = DNTRequest.GetString(Prefix + "IsEdit") == "on" ? 1 : 0; _NodeMainFieldControlEntity.IsMandatory = DNTRequest.GetString(Prefix + "IsMandatory") == "on" ? 1 : 0; _NodeMainFieldControlEntity.BasicValidType = DNTRequest.GetInt("txtBasicValidTypeID" + (i+2).ToString().PadLeft(2, '0'), 0); _NodeMainFieldControlEntity.ValidTimeType = DNTRequest.GetInt(Prefix + "ValidTimeType", 0); DbHelper.GetInstance().AddWorkflow_NodeMainFieldControl(_NodeMainFieldControlEntity); } ScriptManager.RegisterStartupScript(btnSubmit, this.GetType(), "btnSubmit", "alert('设定成功');", true); BindGridView(); }
/// <summary> /// 返回实体内容 /// </summary> /// <param name="NodeID"></param> /// <param name="FieldID"></param> /// <returns></returns> public Workflow_NodeMainFieldControlEntity GetWorkflow_NodeMainFieldControlEntityByKeyCol(string NodeID, string FieldID) { string sql = "select * from [dbo].[Workflow_NodeMainFieldControl] Where NodeID=@NodeID and FieldID=@FieldID"; DbParameter[] pramsGet = { MakeInParam("@NodeID",(DbType)SqlDbType.VarChar,50,NodeID ), MakeInParam("@FieldID",(DbType)SqlDbType.VarChar,50,FieldID ), }; Workflow_FlowNodeEntity _FlowNodeEntity = GetWorkflow_FlowNodeEntityByKeyCol(NodeID); Workflow_NodeMainFieldControlEntity dt = new Workflow_NodeMainFieldControlEntity(); dt.NodeID = Int32.Parse(NodeID); dt.FieldID = Int32.Parse(FieldID); DbDataReader dr = null; try { dr = ExecuteReader(CommandType.Text, sql, pramsGet); if (dr.Read()) { if (dr["IsView"].ToString() != "" || dr["IsView"] != null) dt.IsView = Int32.Parse(dr["IsView"].ToString()); if (dr["IsEdit"].ToString() != "" || dr["IsEdit"] != null) dt.IsEdit = Int32.Parse(dr["IsEdit"].ToString()); if (dr["IsMandatory"].ToString() != "" || dr["IsMandatory"] != null) dt.IsMandatory = Int32.Parse(dr["IsMandatory"].ToString()); if (dr["BasicValidType"].ToString() != "" || dr["BasicValidType"] != null) dt.BasicValidType = Int32.Parse(dr["BasicValidType"].ToString()); if (dr["ValidTimeType"].ToString() != "" || dr["ValidTimeType"] != null) dt.ValidTimeType = Int32.Parse(dr["ValidTimeType"].ToString()); dr.Close(); } else { dt.IsView = 1; dt.IsEdit = _FlowNodeEntity.NodeTypeID == 1 ? 1 : 0; dt.IsMandatory = 0; dt.BasicValidType = 0; dt.ValidTimeType = 0; } return dt; } catch (Exception exp) { throw exp; } finally { if (dr != null) dr.Close(); } }
/// <summary> /// 新增信息 /// </summary> /// <param name="_Workflow_NodeMainFieldControlEntity"></param> /// <returns></returns> public string AddWorkflow_NodeMainFieldControl(Workflow_NodeMainFieldControlEntity _Workflow_NodeMainFieldControlEntity) { DbParameter[] pramsInsert = { MakeInParam("@NodeID",(DbType)SqlDbType.Int,4,_Workflow_NodeMainFieldControlEntity.NodeID ), MakeInParam("@FieldID",(DbType)SqlDbType.Int,4,_Workflow_NodeMainFieldControlEntity.FieldID ), MakeInParam("@IsView",(DbType)SqlDbType.Int,4,_Workflow_NodeMainFieldControlEntity.IsView ), MakeInParam("@IsEdit",(DbType)SqlDbType.Int,4,_Workflow_NodeMainFieldControlEntity.IsEdit ), MakeInParam("@IsMandatory",(DbType)SqlDbType.Int,4,_Workflow_NodeMainFieldControlEntity.IsMandatory ), MakeInParam("@BasicValidType",(DbType)SqlDbType.Int,4,_Workflow_NodeMainFieldControlEntity.BasicValidType ), MakeInParam("@ValidTimeType",(DbType)SqlDbType.Int,4,_Workflow_NodeMainFieldControlEntity.ValidTimeType ), }; StringBuilder sb = new StringBuilder(); sb.Append("INSERT INTO [dbo].[Workflow_NodeMainFieldControl]"); sb.Append("("); sb.Append(" [NodeID]"); sb.Append(",[FieldID]"); sb.Append(",[IsView]"); sb.Append(",[IsEdit]"); sb.Append(",[IsMandatory]"); sb.Append(",[BasicValidType]"); sb.Append(",[ValidTimeType]"); sb.Append(") "); sb.Append(" VALUES ("); sb.Append("@NodeID,"); sb.Append("@FieldID,"); sb.Append("@IsView,"); sb.Append("@IsEdit,"); sb.Append("@IsMandatory,"); sb.Append("@BasicValidType,"); sb.Append("@ValidTimeType )"); sb.Append("select @@identity;"); return ExecuteScalar(CommandType.Text, sb.ToString(), pramsInsert).ToString(); }