/// <summary> /// 根据Id编号修改流程步骤 /// </summary> /// <param name="mp"></param> /// <returns></returns> //public bool ModifyProcessById(M_Process mp) //{ // //string strSql = "update ZL_Process set PName=@PName,PDepcit=@PDepcit,PRole=@PRole,PCode=@PCode,PPassName=@PPassName,PPassCode=@PPassCode,PNoPassName=@PNoPassName,PNoPassCode=@PNoPassCode,PFlowId=@PFlowId where id=@Id"; // //SqlParameter[] sp = new SqlParameter[] { // // new SqlParameter("@PName", mp.PName), // // new SqlParameter("@PDepcit", mp.PDepcit), // // new SqlParameter("@PRole", mp.PRole), // // new SqlParameter("@PCode", mp.PCode), // // new SqlParameter("@PPassName", mp.PPassName), // // new SqlParameter("@PPassCode", mp.PPassCode), // // new SqlParameter("@PNoPassName", mp.PNoPassName), // // new SqlParameter("@PNoPassCode", mp.PNoPassCode), // // new SqlParameter("@PFlowId", mp.PFlowId), // // new SqlParameter("@Id",mp.Id)}; // //int result = SqlHelper.ExecuteNonQuery(CommandType.Text, strSql, sp); // //if (result > 0) // //{ // // return true; // //} // //else // //{ // // return false; // //} //} #endregion #endregion /// <summary> /// 增加流程步骤 /// </summary> /// <param name="mp"></param> /// <returns></returns> public int Add_Process(M_Process mp) { string strSql = null; SqlParameter[] sp = null; if (mp.PDepcit == null || "".Equals(mp.PDepcit)) { strSql = "insert into ZL_Process(PName,PRole,PCode,PPassName,PPassCode,PNoPassName,PNoPassCode,PFlowId,NeedCode) values(@PName,@PRole,@PCode,@PPassName,@PPassCode,@PNoPassName,@PNoPassCode,@PFlowId,@NeedCode)"; sp = new SqlParameter[] { new SqlParameter("@PName", mp.PName), new SqlParameter("@PRole", mp.PRole), new SqlParameter("@PCode", mp.PCode), new SqlParameter("@PPassName", mp.PPassName), new SqlParameter("@PPassCode", mp.PPassCode), new SqlParameter("@PNoPassName", mp.PNoPassName), new SqlParameter("@PNoPassCode", mp.PNoPassCode), new SqlParameter("@PFlowId", mp.PFlowId), new SqlParameter("@NeedCode", mp.NeedCode) }; } else { strSql = "insert into ZL_Process(PName,PDepcit,PRole,PCode,PPassName,PPassCode,PNoPassName,PNoPassCode,PFlowId,NeedCode) values(@PName,@PDepcit,@PRole,@PCode,@PPassName,@PPassCode,@PNoPassName,@PNoPassCode,@PFlowId,@NeedCode)"; sp = new SqlParameter[] { new SqlParameter("@PName", mp.PName), new SqlParameter("@PDepcit", mp.PDepcit), new SqlParameter("@PRole", mp.PRole), new SqlParameter("@PCode", mp.PCode), new SqlParameter("@PPassName", mp.PPassName), new SqlParameter("@PPassCode", mp.PPassCode), new SqlParameter("@PNoPassName", mp.PNoPassName), new SqlParameter("@PNoPassCode", mp.PNoPassCode), new SqlParameter("@PFlowId", mp.PFlowId), new SqlParameter("@NeedCode", mp.NeedCode) }; } return(SqlHelper.ExecuteNonQuery(CommandType.Text, strSql, sp)); }
public async Task <ResultObject> DeleteProcess(M_Process process) { var resultObj = new ResultObject { RowAffected = -1, ObjectValue = process }; using (var context = new MasterDbContext(contextOptions)) { using (var transaction = context.Database.BeginTransaction()) { try { MySqlParameter[] sqlParams = new MySqlParameter[] { new MySqlParameter("strId", process.Id), new MySqlParameter("strDelete_By", process.Updated_By) }; //Output Parameter no need to define. @`strId` resultObj.RowAffected = await context.Database.ExecuteSqlCommandAsync("call sp_process_delete( ?, ?)", parameters : sqlParams); transaction.Commit(); return(resultObj); } catch (Exception ex) { transaction.Rollback(); throw ex; } } } }
public async Task <IActionResult> Edit([Bind("ProcessCode,ProcessName,ProcessDesc,ProcessSeq,CompanyCode,Id,Is_Active,Created_Date,Created_By,Updated_Date,Updated_By")] M_Process m_Process) { if (ModelState.IsValid) { m_Process.Updated_By = await base.CurrentUserId(); ResultObject resultObj; try { using (var processBll = new ProcessBLL()) { resultObj = await processBll.UpdateProcess(m_Process); _cache.Remove("CACHE_MASTER_PROCESS"); } return(Json(new { success = true, data = (M_Process)resultObj.ObjectValue, message = "Process Update." })); } catch (Exception ex) { return(Json(new { success = false, data = m_Process, message = ex.Message })); } } var err = ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage).ToList(); return(Json(new { success = false, errors = err, data = m_Process, message = "Update Failed" })); }
/// <summary> /// 增加流程步骤 /// </summary> /// <param name="mp"></param> /// <returns></returns> public bool AddProcess(M_Process mp) { if (Add_Process(mp) > 0) { return(true); } else { return(false); } }
private void BindDatas(int id) { M_Process mp = bp.SelReturnModel(Convert.ToInt32(id)); this.txtPName.Text = mp.PName; this.FlowPrcess.Value = mp.PDepcit; this.txtPassCode.Text = mp.PPassName; this.ddlPassCode.SelectedValue = mp.PPassCode.ToString(); this.txtNoPassCode.Text = mp.PNoPassName; this.ddlNoPassCode.SelectedValue = mp.PNoPassCode.ToString(); stateCode = mp.PCode; this.txtPCode.Value = mp.PCode.ToString(); this.txtNoPassCode.Text = mp.PNoPassName; this.needCode_Text.Text = mp.NeedCode.ToString(); BindCheckBoxList(mp.PRole); }
public async Task <ResultObject> UpdateProcess(M_Process process) { var resultObj = new ResultObject { RowAffected = -1, ObjectValue = process }; using (var context = new MasterDbContext(contextOptions)) { using (var transaction = context.Database.BeginTransaction()) { try { context.Entry(process).State = EntityState.Modified; MySqlParameter[] sqlParams = new MySqlParameter[] { new MySqlParameter("strId", process.Id), new MySqlParameter("strProcessCode", process.ProcessCode), new MySqlParameter("strProcessName", process.ProcessName), new MySqlParameter("strProcessDesc", process.ProcessDesc), new MySqlParameter("strProcessSeq", process.ProcessSeq), new MySqlParameter("strCompanyCode", process.CompanyCode), new MySqlParameter("strIs_Active", process.Is_Active), new MySqlParameter("strCreated_By", process.Updated_By) }; //Output Parameter no need to define. @`strId` resultObj.RowAffected = await context.Database.ExecuteSqlCommandAsync("call sp_process_update(?, ?, ?, ?, ?, ?, ?, ?)", parameters : sqlParams); transaction.Commit(); return(resultObj); } catch (Exception ex) { transaction.Rollback(); throw ex; } } } }
public async Task <ResultObject> InsertProcess(M_Process process) { var resultObj = new ResultObject { RowAffected = -1, ObjectValue = process }; using (var context = new MasterDbContext(contextOptions)) { using (var transaction = context.Database.BeginTransaction()) { try { MySqlParameter[] sqlParams = new MySqlParameter[] { new MySqlParameter("strProcessCode", process.ProcessCode), new MySqlParameter("strProcessName", process.ProcessName), new MySqlParameter("strProcessDesc", process.ProcessDesc), new MySqlParameter("strProcessSeq", process.ProcessSeq), new MySqlParameter("strCompanyCode", process.CompanyCode), new MySqlParameter("strIs_Active", process.Is_Active), new MySqlParameter("strCreated_By", process.Created_By) }; resultObj.RowAffected = await context.Database.ExecuteSqlCommandAsync("call sp_process_insert(@`strId`, ?, ?, ?, ?, ?, ?, ?)", parameters : sqlParams); //new department after insert. var newDept = context.Process.FromSql("SELECT * FROM m_process WHERE Id = @`strId`;").ToListAsync(); resultObj.ObjectValue = newDept.Result[0]; transaction.Commit(); return(resultObj); } catch (Exception ex) { transaction.Rollback(); throw ex; } } } }
/// <summary> /// 根据id查询 /// </summary> /// <param name="id"></param> /// <returns></returns> public M_Process GetProcessById(int id) { string strSql = "select * from ZL_Process where id=" + id; using (DataTable dt = SqlHelper.ExecuteTable(CommandType.Text, strSql, null)) { M_Process mp = new M_Process(); foreach (DataRow row in dt.Rows) { mp.Id = Convert.ToInt32(row["Id"]); mp.PName = row["PName"].ToString(); mp.PDepcit = row["PDepcit"].ToString(); mp.PCode = Convert.ToInt32(row["PCode"]); mp.PNoPassCode = Convert.ToInt32(row["PNoPassCode"]); mp.PNoPassName = row["PNoPassName"].ToString(); mp.PPassCode = Convert.ToInt32(row["PPassCode"]); mp.PPassName = row["PPassName"].ToString(); mp.PRole = row["PRole"].ToString(); mp.PFlowId = Convert.ToInt32(row["PFlowId"]); } return(mp); } }
public bool UpdateByID(M_Process model) { return(DBCenter.UpdateByID(model, model.Id)); }
public int insert(M_Process model) { return(DBCenter.Insert(model)); }
protected void btnModify_Click(object sender, EventArgs e) { string id = Request.QueryString["id"]; string name = this.txtPName.Text.Trim(); string flowPrcess = this.FlowPrcess.Value.Trim(); List <string> list = new List <string>(); foreach (ListItem item in this.cblRole.Items) { if (item.Selected) { list.Add(item.Value); } } if (this.txtPCode.Value.Trim() != null && !"".Equals(this.txtPCode.Value.Trim())) { stateCode = Convert.ToInt32(this.txtPCode.Value.Trim()); } string passName = this.txtPassCode.Text.Trim(); string passCode = this.ddlPassCode.SelectedValue.Trim(); string NoPassName = this.txtNoPassCode.Text.Trim(); string NoPassCode = this.ddlNoPassCode.SelectedValue.Trim(); string roleId = null; foreach (string str in list) { roleId += str + ","; } M_Process mp = bp.GetProcessById(Convert.ToInt32(id)); mp.PName = name; mp.PDepcit = flowPrcess; if (roleId != null && !"".Equals(roleId)) { mp.PRole = roleId; } else { mp.PRole = string.Empty; } DataTable dt = bp.GetPCodeByPCode(stateCode, mp.PFlowId); if (dt.Rows.Count < 1 || (dt.Rows.Count == 1 && Convert.ToInt32(dt.Rows[0]["PCode"]) == mp.PCode)) { mp.PCode = stateCode; mp.PPassName = passName; mp.PPassCode = Convert.ToInt32(passCode); mp.PNoPassName = NoPassName; mp.PNoPassCode = Convert.ToInt32(NoPassCode); mp.NeedCode = Convert.ToInt32(needCode_Text.Text.Trim()); if (bp.UpdateByID(mp)) { function.WriteSuccessMsg("流程步骤修改成功!", customPath2 + "Content/FlowManager.aspx"); } else { function.WriteErrMsg("流程步骤修改失败!", customPath2 + "Content/FlowManager.aspx"); } } else { function.WriteErrMsg("序列号重复请重新输入!"); } }
protected void btnSave_Click(object sender, EventArgs e) { string name = this.txtPName.Text.Trim(); string flowPrcess = this.FlowPrcess.Value.Trim(); List <string> list = new List <string>(); foreach (ListItem item in this.CheckBoxList1.Items) { if (item.Selected) { list.Add(item.Value); } } int stateCode = 0; if (this.txtPCode.Value.Trim() != null && !"".Equals(this.txtPCode.Value.Trim())) { stateCode = Convert.ToInt32(this.txtPCode.Value.Trim()); } ; string passName = this.txtPassCode.Text.Trim(); string passCode = this.ddlPassCode.SelectedValue.Trim(); string NoPassName = this.txtNoPassCode.Text.Trim(); string NoPassCode = this.ddlNoPassCode.SelectedValue.Trim(); string roleId = null; foreach (string str in list) { roleId += str + ","; } M_Process mp = new M_Process(); mp.PName = name; mp.PDepcit = flowPrcess; if (roleId != null && !"".Equals(roleId)) { mp.PRole = roleId; } else { mp.PRole = string.Empty; } if (bp.GetPCodeByPCode(stateCode, Convert.ToInt32(Request.QueryString["id"])).Rows.Count > 0) { function.WriteErrMsg("序列号重复请重新输入!"); } else { mp.PCode = Convert.ToInt32(stateCode); mp.PPassName = passName; mp.PPassCode = Convert.ToInt32(passCode); mp.PNoPassName = NoPassName; mp.PNoPassCode = Convert.ToInt32(NoPassCode); mp.PFlowId = Convert.ToInt32(Request.QueryString["id"]); mp.NeedCode = DataConverter.CLng(needCode_Text.Text.Trim()); if (bp.AddProcess(mp)) { function.WriteSuccessMsg("流程步骤添加成功!", customPath2 + "Content/FlowManager.aspx"); } else { function.WriteErrMsg("添加流程步骤失败!", customPath2 + "Content/AddFlow.aspx.aspx"); } } }
public bool UpdateByID(M_Process model) { return(Sql.UpdateByIDs(strTableName, PK, model.Id.ToString(), BLLCommon.GetFieldAndPara(model), model.GetParameters(model))); }
public int insert(M_Process model) { return(Sql.insert(strTableName, model.GetParameters(model), BLLCommon.GetParas(model), BLLCommon.GetFields(model))); }