protected void btnAdd_Click(object sender, EventArgs e) { if (txtGroupName.Text != string.Empty && txtGroupDesc.Text != string.Empty) { Workflow_FormFieldGroupEntity _Workflow_FormFieldGroupEntity = new Workflow_FormFieldGroupEntity(); _Workflow_FormFieldGroupEntity.FormID = Convert.ToInt32(DNTRequest.GetString("fmid")); _Workflow_FormFieldGroupEntity.GroupName = txtGroupName.Text; _Workflow_FormFieldGroupEntity.GroupDesc = txtGroupDesc.Text; _Workflow_FormFieldGroupEntity.DisplayOrder = Int32.Parse(txtDisplayOrder.Text); string sResult = DbHelper.GetInstance().AddWorkflow_FormFieldGroup(_Workflow_FormFieldGroupEntity); if (sResult == "-1") { lblMsg.Text = ResourceManager.GetString("Operation_RECORD"); } } BindGridView(); RefreshDetailGroup(); }
/// <summary> /// 新增信息 /// </summary> /// <param name="_Workflow_FormFieldGroupEntity"></param> /// <returns>返回string "-1"表示该已经存在,否则成功 </returns> public string AddWorkflow_FormFieldGroup(Workflow_FormFieldGroupEntity _Workflow_FormFieldGroupEntity) { //判断该记录是否已经存在 DbParameter[] prams = { MakeInParam("@GroupName",(DbType)SqlDbType.VarChar,200,_Workflow_FormFieldGroupEntity.GroupName ), MakeInParam("@FormID",(DbType)SqlDbType.Int,4,_Workflow_FormFieldGroupEntity.FormID ), }; string sql = " select * from [dbo].[Workflow_FormFieldGroup] where FormID=@FormID and GroupName=@GroupName "; if (ExecuteDataset(CommandType.Text, sql, prams).Tables[0].Rows.Count > 0) { return "-1";//该记录已经存在 } else { DbParameter[] pramsInsert = { MakeInParam("@GroupName",(DbType)SqlDbType.VarChar,200,_Workflow_FormFieldGroupEntity.GroupName ), MakeInParam("@GroupDesc",(DbType)SqlDbType.VarChar,200,_Workflow_FormFieldGroupEntity.GroupDesc ), MakeInParam("@FormID",(DbType)SqlDbType.Int,4,_Workflow_FormFieldGroupEntity.FormID ), MakeInParam("@DisplayOrder",(DbType)SqlDbType.Int,4,_Workflow_FormFieldGroupEntity.DisplayOrder ), }; StringBuilder sb = new StringBuilder(); sb.Append("INSERT INTO [dbo].[Workflow_FormFieldGroup]"); sb.Append("("); sb.Append(" [GroupName]"); sb.Append(",[GroupDesc]"); sb.Append(",[FormID]"); sb.Append(",[DisplayOrder]"); sb.Append(") "); sb.Append(" VALUES ("); sb.Append("@GroupName,"); sb.Append("@GroupDesc,"); sb.Append("@FormID,"); sb.Append("@DisplayOrder )"); sb.Append("select @@identity;"); int GroupID =Convert.ToInt32(ExecuteScalar(CommandType.Text, sb.ToString(), pramsInsert)); _Workflow_FormFieldGroupEntity.GroupID = GroupID; //返回groupID ArrayList arlst = new ArrayList(); arlst.Add("Workflow_FormFieldGroup"); arlst.Add(_Workflow_FormFieldGroupEntity.FormID); arlst.Add(""); return sp_ReDisplayOrder(arlst); } }
private Workflow_FormFieldGroupEntity GetWorkflow_FormFieldGroupFromIDataReader(DbDataReader dr) { Workflow_FormFieldGroupEntity dt = new Workflow_FormFieldGroupEntity(); if (dr.FieldCount > 0) { if (dr["GroupID"].ToString() != "" || dr["GroupID"] != null) dt.GroupID = Int32.Parse(dr["GroupID"].ToString()); dt.GroupName = dr["GroupName"].ToString(); dt.GroupDesc = dr["GroupDesc"].ToString(); if (dr["FormID"].ToString() != "" || dr["FormID"] != null) dt.FormID = Int32.Parse(dr["FormID"].ToString()); if (dr["DisplayOrder"].ToString() != "" || dr["DisplayOrder"] != null) dt.DisplayOrder = Int32.Parse(dr["DisplayOrder"].ToString()); dr.Close(); return dt; } dr.Close(); return null; }
/// <summary> /// 修改信息 /// </summary> /// <param name="_Workflow_FormFieldGroupEntity"></param> /// <returns>返回string "-1"表示该已经存在,否则成功 </returns> public string UpdateWorkflow_FormFieldGroup(Workflow_FormFieldGroupEntity _Workflow_FormFieldGroupEntity) { DbParameter[] pramsUpdate = { MakeInParam("@GroupID",(DbType)SqlDbType.Int,4,_Workflow_FormFieldGroupEntity.GroupID ), MakeInParam("@GroupName",(DbType)SqlDbType.VarChar,200,_Workflow_FormFieldGroupEntity.GroupName ), MakeInParam("@GroupDesc",(DbType)SqlDbType.VarChar,200,_Workflow_FormFieldGroupEntity.GroupDesc ), MakeInParam("@FormID",(DbType)SqlDbType.Int,4,_Workflow_FormFieldGroupEntity.FormID ), MakeInParam("@DisplayOrder",(DbType)SqlDbType.Int,4,_Workflow_FormFieldGroupEntity.DisplayOrder ), }; StringBuilder sb = new StringBuilder(); sb.Append("Update [dbo].[Workflow_FormFieldGroup]"); sb.Append(" set "); sb.Append(" [GroupName]=@GroupName,"); sb.Append(" [GroupDesc]=@GroupDesc,"); sb.Append(" [FormID]=@FormID,"); sb.Append(" [DisplayOrder]=@DisplayOrder "); sb.Append(" where [GroupID]=@GroupID "); return ExecuteNonQuery(CommandType.Text, sb.ToString(), pramsUpdate).ToString(); }
protected void btnSubmit_Click(object sender, EventArgs e) { for (int i = 0; i < GridView1.Rows.Count; i++) { string Prefix = "TabContainer1$TabPanel3$GridView1$ctl" + (i + 2).ToString().PadLeft(2, '0') + "$"; Workflow_FormFieldGroupEntity _Workflow_FormFieldGroupEntity = new Workflow_FormFieldGroupEntity(); _Workflow_FormFieldGroupEntity.GroupID = Convert.ToInt32(GridView1.DataKeys[i][0]); _Workflow_FormFieldGroupEntity.FormID = Convert.ToInt32(DNTRequest.GetString("fmid")); _Workflow_FormFieldGroupEntity.GroupName = DNTRequest.GetString(Prefix + "GroupName"); _Workflow_FormFieldGroupEntity.GroupDesc = DNTRequest.GetString(Prefix + "GroupDesc"); _Workflow_FormFieldGroupEntity.DisplayOrder = DNTRequest.GetInt(Prefix + "DisplayOrder", 9990); DbHelper.GetInstance().UpdateWorkflow_FormFieldGroup(_Workflow_FormFieldGroupEntity); } ArrayList arlst = new ArrayList(); arlst.Add("Workflow_FormFieldGroup"); arlst.Add(DNTRequest.GetString("fmid")); arlst.Add(""); DbHelper.GetInstance().sp_ReDisplayOrder(arlst); BindGridView(); RefreshDetailGroup(); }
/// <summary> /// 增加明细组 /// </summary> /// <param name="GroupID"></param> /// <param name="group"></param> /// <param name="formID"></param> /// <returns></returns> private static string addGroup(out Dictionary<string, int> groups, XmlNodeList group, int formID) { // GroupID = new List<int>(); groups = new Dictionary<string, int>(); string sResult=""; int i = 10; foreach (XmlNode fNode in group) { XmlNode FormName = fNode.SelectSingleNode("FormName"); XmlNode GroupName = fNode.SelectSingleNode("groupName"); XmlNode GroupDesc = fNode.SelectSingleNode("groupDesc"); Workflow_FormFieldGroupEntity _Workflow_FormFieldGroupEntity = new Workflow_FormFieldGroupEntity(); _Workflow_FormFieldGroupEntity.FormID = formID; _Workflow_FormFieldGroupEntity.GroupName = GroupName.InnerText; _Workflow_FormFieldGroupEntity.GroupDesc = GroupDesc.InnerText; _Workflow_FormFieldGroupEntity.DisplayOrder = i; i += 10; sResult = DbHelper.GetInstance().AddWorkflow_FormFieldGroup(_Workflow_FormFieldGroupEntity); //增加明细组 if (sResult != "-1") { //增加明细组内元素 groups.Add(_Workflow_FormFieldGroupEntity.GroupName, _Workflow_FormFieldGroupEntity.GroupID); // GroupID.Add(_Workflow_FormFieldGroupEntity.GroupID); XmlNodeList groupsItem = fNode.SelectNodes("groups/item"); List<int> FieldID = new List<int>(); List<string> FieldDesc = new List<string>(); foreach (XmlNode items in groupsItem) { XmlNode fieldID = items.SelectSingleNode("fieldID"); //元素ID XmlNode fieldDesc = items.SelectSingleNode("fieldDesc"); //元素描述 FieldID.Add(Convert.ToInt32(fieldID.InnerText)); FieldDesc.Add(fieldDesc.InnerText); } addFormField(FieldID, FieldDesc, null, formID, _Workflow_FormFieldGroupEntity.GroupID, 1); //将元素添加到明细组 } } return sResult; }