public string UpdateFlow(Model.flow_master oaFlowMasterInfo, List <Model.flow_node> insertList, List <Model.flow_node> updateList, List <Model.flow_node> delList) { try { if (dal.Exists_where(" where flow_name='" + oaFlowMasterInfo.flow_name + "' and sid!=" + oaFlowMasterInfo.sid)) { return("<" + oaFlowMasterInfo.flow_name + ">流程名称已存在"); } else { if (dal.UpdateFlow(oaFlowMasterInfo, insertList, updateList, delList)) { return("success"); } else { return("保存失败!"); } } } catch (Exception exc) { return(exc.Message); } }
/// <summary> /// 分页获取数据列表 /// </summary> //public DataSet GetList(int PageSize,int PageIndex,string strWhere) //{ //return dal.GetList(PageSize,PageIndex,strWhere); //} #endregion BasicMethod #region ExtensionMethod public string InsertFlow(Model.flow_master oaFlowMasterInfo, List <Model.flow_node> insertList) { try { if (dal.Exists_where(" where flow_name='" + oaFlowMasterInfo.flow_name + "'")) { return("<" + oaFlowMasterInfo.flow_name + ">流程名称已存在"); } else { if (dal.InsertFlow(oaFlowMasterInfo, insertList)) { return("success"); } else { return("保存失败!"); } } } catch (Exception exc) { return(exc.Message); } }
public string Add(HttpContext context) { string Name = context.Request["Name"].Trim(); string chkStatus = context.Request["chkStatus"].Trim(); string ApplyForm = context.Request["ApplyForm"].Trim(); string ApplyBanding = context.Request["ApplyBanding"].Trim(); string ApplyDept = context.Request["ApplyDept"].Trim(); string Description = context.Request["Description"].Trim(); string dept = context.Request["dept"].Trim(); string post = context.Request["post"].Trim(); string form = context.Request["form"].Trim(); string addstr = context.Request["addstr"].Trim(); string updatestr = context.Request["updatestr"].Trim(); string delstr = context.Request["delstr"].Trim(); Model.flow_master flowMasterModel = new Model.flow_master(); flowMasterModel.flow_name = Name; flowMasterModel.flow_status = Convert.ToInt32(chkStatus); flowMasterModel.remark = Description; flowMasterModel.dept = dept; flowMasterModel.post = post; flowMasterModel.form = form; flowMasterModel.create_person = "";//context.Session["UserID"].ToString(); flowMasterModel.rf_sid = Convert.ToInt32(ApplyForm); if (ApplyBanding.Length > 0) { if (ApplyBanding.Substring(0, 1) == ",") { ApplyBanding = ApplyBanding + ","; } else { ApplyBanding = "," + ApplyBanding + ","; } } flowMasterModel.post_sid = ApplyBanding; if (ApplyDept.Length > 0) { if (ApplyDept.Substring(0, 1) == ",") { ApplyDept = ApplyDept + ","; } else { ApplyDept = "," + ApplyDept + ","; } } flowMasterModel.dept_sid = ApplyDept; List <Model.flow_node> details = new List <Model.flow_node>(); details = JsonSerializerHelper.JSONStringToList <Model.flow_node>(addstr); //return BllOAProcess.InsertFlow(oaFlowMasterInfo, details); return(new BLL.flow_master().InsertFlow(flowMasterModel, details)); }
public bool UpdateFlow(Model.flow_master oaFlowMasterInfo, List <Model.flow_node> insertList, List <Model.flow_node> updateList, List <Model.flow_node> delList) { try { ArrayList al = new ArrayList(); //主表 StringBuilder sbSql = new StringBuilder(); sbSql.Append("update flow_master set "); sbSql.Append("flow_name='" + oaFlowMasterInfo.flow_name + "',"); sbSql.Append("rf_sid=" + oaFlowMasterInfo.rf_sid + ","); sbSql.Append("dept_sid='" + oaFlowMasterInfo.dept_sid + "',"); sbSql.Append("post_sid='" + oaFlowMasterInfo.post_sid + "',"); sbSql.Append("dept='" + oaFlowMasterInfo.dept + "',"); sbSql.Append("post='" + oaFlowMasterInfo.post + "',"); sbSql.Append("form='" + oaFlowMasterInfo.form + "',"); sbSql.Append("flow_status=" + oaFlowMasterInfo.flow_status + ","); sbSql.Append("remark='" + oaFlowMasterInfo.remark + "',"); sbSql.Append("update_person = '',"); sbSql.Append("update_date = getdate()"); sbSql.Append(" where sid = '" + oaFlowMasterInfo.sid + "'"); al.Add(sbSql.ToString()); //从表 //删除 for (int i = 0; i < delList.Count; i++) { sbSql = new StringBuilder(); Model.flow_node model = delList[i]; sbSql.Append("delete from flow_node where sid=" + model.sid); al.Add(sbSql.ToString()); } //修改 for (int i = 0; i < updateList.Count; i++) { sbSql = new StringBuilder(); //DataRow dr = dtDetail.Rows[i]; //if (dr.RowState == DataRowState.Deleted) continue; Model.flow_node model = updateList[i]; sbSql.Append("update flow_node set node_no = '" + model.node_no.ToString() + "',"); sbSql.Append("flow_sid = " + model.flow_sid.ToString() + ","); sbSql.Append("node_type = '" + model.node_type + "',"); sbSql.Append("node_name = '" + model.node_name + "',"); sbSql.Append("appr_dept = '" + model.appr_dept.ToString() + "',"); sbSql.Append("appr_dept_type = '" + model.appr_dept_type.ToString() + "',"); sbSql.Append("appr_role = '" + model.appr_role.ToString() + "',"); sbSql.Append("dept = '" + model.dept.ToString() + "',"); sbSql.Append("role = '" + model.role.ToString() + "',"); sbSql.Append("appr_count = '" + model.appr_count.ToString() + "',"); sbSql.Append("appr_time = '" + model.appr_time.ToString() + "',"); sbSql.Append("update_person = '',"); sbSql.Append("update_date = getdate()"); sbSql.Append(" where sid = '" + model.sid.ToString() + "'"); al.Add(sbSql.ToString()); } //添加 for (int i = 0; i < insertList.Count; i++) { sbSql = new StringBuilder(); //DataRow dr = dtDetail.Rows[i]; //if (dr.RowState == DataRowState.Deleted) continue; Model.flow_node model = insertList[i]; sbSql.Append("insert into flow_node(flow_sid, node_no, node_type, node_name, appr_dept,"); sbSql.Append("dept,role,"); sbSql.Append("appr_dept_type,appr_role,appr_count,appr_time,create_person, create_date"); sbSql.Append(")values("); sbSql.Append("'" + oaFlowMasterInfo.sid + "'," + model.node_no.ToString() + ","); sbSql.Append("" + model.node_type.ToString() + ",'" + model.node_name.ToString() + "',"); sbSql.Append("'" + model.appr_dept.ToString() + "',"); sbSql.Append("'" + model.dept.ToString() + "',"); sbSql.Append("'" + model.role.ToString() + "',"); sbSql.Append("" + model.appr_dept_type.ToString() + ",'" + model.appr_role.ToString() + "',"); sbSql.Append("" + model.appr_count.ToString() + ",'" + model.appr_time.ToString() + "',"); sbSql.Append("'" + oaFlowMasterInfo.create_person + "',getdate()"); sbSql.Append(")"); al.Add(sbSql.ToString()); } DbHelperSQL.ExecuteSqlTran(al); return(true); } catch (Exception exc) { throw new Exception(exc.Message); } }
/* * /// <summary> * /// 分页获取数据列表 * /// </summary> * public DataSet GetList(int PageSize,int PageIndex,string strWhere) * { * SqlParameter[] parameters = { * new SqlParameter("@tblName", SqlDbType.VarChar, 255), * new SqlParameter("@fldName", SqlDbType.VarChar, 255), * new SqlParameter("@PageSize", SqlDbType.Int), * new SqlParameter("@PageIndex", SqlDbType.Int), * new SqlParameter("@IsReCount", SqlDbType.Bit), * new SqlParameter("@OrderType", SqlDbType.Bit), * new SqlParameter("@strWhere", SqlDbType.VarChar,1000), * }; * parameters[0].Value = "flow_master"; * parameters[1].Value = "sid"; * parameters[2].Value = PageSize; * parameters[3].Value = PageIndex; * parameters[4].Value = 0; * parameters[5].Value = 0; * parameters[6].Value = strWhere; * return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds"); * }*/ #endregion BasicMethod #region ExtensionMethod public bool InsertFlow(Model.flow_master oaFlowMasterInfo, List <Model.flow_node> insertList) { StringBuilder sbSql = new StringBuilder(); sbSql.Append("insert into flow_master(flow_name,rf_sid,dept_sid,post_sid,flow_status,remark,"); sbSql.Append("create_person, create_date,dept,post,form"); sbSql.Append(")values("); sbSql.Append("'" + oaFlowMasterInfo.flow_name + "'," + oaFlowMasterInfo.rf_sid + ","); sbSql.Append("'" + oaFlowMasterInfo.dept_sid + "','" + oaFlowMasterInfo.post_sid + "',"); sbSql.Append("" + oaFlowMasterInfo.flow_status + ",'" + oaFlowMasterInfo.remark + "',"); sbSql.Append("'" + oaFlowMasterInfo.create_person + "',getdate(),"); sbSql.Append("'" + oaFlowMasterInfo.dept + "','" + oaFlowMasterInfo.post + "','" + oaFlowMasterInfo.form + "'"); sbSql.Append(")"); using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; SqlTransaction tx = conn.BeginTransaction(); cmd.Transaction = tx; try { //主表 cmd.CommandText = sbSql.ToString(); cmd.ExecuteNonQuery(); //获取ID cmd.CommandText = "select SCOPE_IDENTITY()"; string strMID = cmd.ExecuteScalar().ToString(); //从表 //添加 for (int i = 0; i < insertList.Count; i++) { sbSql = new StringBuilder(); //DataRow dr = dtDetail.Rows[i]; //if (dr.RowState == DataRowState.Deleted) continue; Model.flow_node model = insertList[i]; sbSql.Append("insert into flow_node(flow_sid, node_no, node_type, node_name, appr_dept,"); sbSql.Append("dept,role,"); sbSql.Append("appr_dept_type,appr_role,appr_count,appr_time,create_person, create_date"); sbSql.Append(")values("); sbSql.Append("'" + strMID + "'," + model.node_no.ToString() + ","); sbSql.Append("" + model.node_type.ToString() + ",'" + model.node_name.ToString() + "',"); sbSql.Append("'" + model.appr_dept.ToString() + "',"); sbSql.Append("'" + model.dept.ToString() + "',"); sbSql.Append("'" + model.role.ToString() + "',"); sbSql.Append("" + model.appr_dept_type.ToString() + ",'" + model.appr_role.ToString() + "',"); sbSql.Append("" + model.appr_count.ToString() + ",'" + model.appr_time.ToString() + "',"); sbSql.Append("'" + oaFlowMasterInfo.create_person + "',getdate()"); sbSql.Append(")"); cmd.CommandText = sbSql.ToString(); cmd.ExecuteNonQuery(); } tx.Commit(); } catch (System.Data.SqlClient.SqlException E) { tx.Rollback(); throw new Exception(E.Message); } } return(true); }