/// <summary> /// 增加一条数据 /// </summary> public int Add(LPWeb.Model.Template_Workflow model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Template_Workflow("); strSql.Append("Name,Enabled,[Desc])"); strSql.Append(" values ("); strSql.Append("@Name,@Enabled,@Desc)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Name", SqlDbType.NVarChar, 50), new SqlParameter("@Enabled", SqlDbType.Bit, 1), new SqlParameter("@Desc", SqlDbType.NVarChar, 500) }; parameters[0].Value = model.Name; parameters[1].Value = model.Enabled; parameters[2].Value = model.Desc; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 增加一条数据 /// </summary> public int WorkflowTemplateAdd(LPWeb.Model.Template_Workflow model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@WflTemplId", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.NVarChar, 50), new SqlParameter("@Enabled", SqlDbType.Bit, 1), new SqlParameter("@Desc", SqlDbType.NVarChar, 500), new SqlParameter("@DaysFromEstClose", SqlDbType.Int, 4), new SqlParameter("@StageID", SqlDbType.Int, 4) }; if (model.WflTemplId == 0) { parameters[0].Direction = ParameterDirection.Output; } else { parameters[0].Value = model.WflTemplId; } parameters[1].Value = model.Name; parameters[2].Value = model.Enabled; parameters[3].Value = model.Desc; parameters[4].Value = model.DaysFromEstClose; parameters[5].Value = model.StageId; DbHelperSQL.RunProcedure("lpsp_Template_Workflow_ADD", parameters, out rowsAffected); return((int)parameters[0].Value); }
protected void btnSave_Click(object sender, EventArgs e) { if (!CheckInput()) { return; } LPWeb.Model.Template_Workflow model = FillModel(); try { hdnTmpID.Value = template.WorkflowTemplateAdd(model).ToString(); } catch { } }
public LPWeb.Model.Template_Workflow FillModel() { LPWeb.Model.Template_Workflow model = new LPWeb.Model.Template_Workflow(); model.Name = txbTemplateName.Text.Trim(); model.Enabled = cbEnabled.Checked; model.Desc = txbEescription.Text.Trim(); model.DaysFromEstClose = int.Parse(txbEstClose.Text.Trim()); model.WflTemplId = int.Parse(hdnTmpID.Value); try { model.StageId = int.Parse(StageID); } catch { model.StageId = 0; } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(LPWeb.Model.Template_Workflow model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Template_Workflow set "); strSql.Append("WflTemplId=@WflTemplId,"); strSql.Append("Name=@Name,"); strSql.Append("Enabled=@Enabled,"); strSql.Append("Desc=@Desc"); strSql.Append(" where WflTemplId=@WflTemplId "); SqlParameter[] parameters = { new SqlParameter("@WflTemplId", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.NVarChar, 50), new SqlParameter("@Enabled", SqlDbType.Bit, 1), new SqlParameter("@Desc", SqlDbType.NVarChar, 500) }; parameters[0].Value = model.WflTemplId; parameters[1].Value = model.Name; parameters[2].Value = model.Enabled; parameters[3].Value = model.Desc; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public LPWeb.Model.Template_Workflow GetModel(int WflTemplId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 WflTemplId,Name,Enabled,[Desc],[Default],WorkflowType,Custom,CalculationMethod from Template_Workflow "); strSql.Append(" where WflTemplId=@WflTemplId "); SqlParameter[] parameters = { new SqlParameter("@WflTemplId", SqlDbType.Int, 4) }; parameters[0].Value = WflTemplId; LPWeb.Model.Template_Workflow model = new LPWeb.Model.Template_Workflow(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["WflTemplId"].ToString() != "") { model.WflTemplId = int.Parse(ds.Tables[0].Rows[0]["WflTemplId"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); if (ds.Tables[0].Rows[0]["Enabled"].ToString() != "") { if ((ds.Tables[0].Rows[0]["Enabled"].ToString() == "1") || (ds.Tables[0].Rows[0]["Enabled"].ToString().ToLower() == "true")) { model.Enabled = true; } else { model.Enabled = false; } } if (ds.Tables[0].Rows[0]["Default"].ToString() != "") { if ((ds.Tables[0].Rows[0]["Default"].ToString() == "1") || (ds.Tables[0].Rows[0]["Default"].ToString().ToLower() == "true")) { model.Default = true; } else { model.Default = false; } } if (ds.Tables[0].Rows[0]["Custom"].ToString() != "") { if ((ds.Tables[0].Rows[0]["Custom"].ToString() == "1") || (ds.Tables[0].Rows[0]["Custom"].ToString().ToLower() == "true")) { model.Custom = true; } else { model.Custom = false; } } model.WorkflowType = ds.Tables[0].Rows[0]["WorkflowType"].ToString(); model.Desc = ds.Tables[0].Rows[0]["Desc"].ToString(); if (ds.Tables[0].Rows[0]["CalculationMethod"].ToString() != "") { model.CalculationMethod = int.Parse(ds.Tables[0].Rows[0]["CalculationMethod"].ToString()); } return(model); } else { return(null); } }