/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.standard_value model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into td_standard_value("); strSql.Append("standard_id,value,add_time"); strSql.Append(") values ("); strSql.Append("@standard_id,@value,@add_time"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@standard_id", SqlDbType.Int, 4), new SqlParameter("@value", SqlDbType.NVarChar, 200), new SqlParameter("@add_time", SqlDbType.DateTime) }; parameters[0].Value = model.standard_id; parameters[1].Value = model.value; parameters[2].Value = model.add_time; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.standard_value model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update td_standard_value set "); strSql.Append(" standard_id = @standard_id , "); strSql.Append(" value = @value , "); strSql.Append(" add_time = @add_time "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@standard_id", SqlDbType.Int, 4), new SqlParameter("@value", SqlDbType.NVarChar, 200), new SqlParameter("@add_time", SqlDbType.DateTime) }; parameters[0].Value = model.id; parameters[1].Value = model.standard_id; parameters[2].Value = model.value; parameters[3].Value = model.add_time; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public string get_standrad(string strandrad) { string[] strandrads = strandrad.Split(','); string str_standard = ""; BLL.standard_value blls = new standard_value(); BLL.standard bll1 = new standard(); for (int i = 0; i < strandrads.Length; i++) { if (!string.IsNullOrEmpty(strandrads[i])) { Model.standard_value model = blls.GetModel(Convert.ToInt32(strandrads[i].Split(':')[1])); str_standard += strandrads[i].Split(':')[0] + ":" + model.value + ","; } else { return(""); } } return(str_standard); }
private bool DoEdit(int _id) { bool result = false; string standard_values = DTRequest.GetFormString("ck_standard_value"); BLL.standard bll = new BLL.standard(); Model.standard model = bll.GetModel(_id); model.title = txt_standard_title.Text.Trim(); model.category_id = Convert.ToInt32(ddlCategoryId.SelectedValue); List <Model.standard_value> lst = new List <Model.standard_value>(); string[] standard_value_arr = standard_values.Split(','); Model.standard_value model_value; foreach (string str in standard_value_arr) { model_value = new Model.standard_value(); model_value.value = str.Split('|')[1]; model_value.add_time = DateTime.Now; lst.Add(model_value); } model.standard_values = lst; if (bll.Update(model)) { //AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改用户信息:" + model.user_name); //记录日志 result = true; } return(result); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.standard_value GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id, standard_id, value, add_time "); strSql.Append(" from td_standard_value "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.standard_value model = new Model.standard_value(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["standard_id"].ToString() != "") { model.standard_id = int.Parse(ds.Tables[0].Rows[0]["standard_id"].ToString()); } model.value = ds.Tables[0].Rows[0]["value"].ToString(); if (ds.Tables[0].Rows[0]["add_time"].ToString() != "") { model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } return(model); } else { return(null); } }
private bool DoAdd() { bool result = false; string standard_values = DTRequest.GetFormString("ck_standard_value"); if (string.IsNullOrEmpty(standard_values)) { JscriptMsg("保存过程中发生错误!", "", "Error"); return(false); } BLL.standard bll = new BLL.standard(); Model.standard model = new Model.standard(); model.title = txt_standard_title.Text.Trim(); model.category_id = Convert.ToInt32(ddlCategoryId.SelectedValue); model.add_time = DateTime.Now; List <Model.standard_value> lst = new List <Model.standard_value>(); string[] standard_value_arr = standard_values.Split(','); Model.standard_value model_value; foreach (string str in standard_value_arr) { model_value = new Model.standard_value(); model_value.value = str.Split('|')[1]; model_value.add_time = DateTime.Now; lst.Add(model_value); } model.standard_values = lst; if (bll.Add(model) > 0) { //AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加用户:" + model.user_name); //记录日志 result = true; } return(result); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.standard GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id, category_id, title, add_time "); strSql.Append(" from td_standard "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4) }; parameters[0].Value = id; Model.standard model = new Model.standard(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["category_id"].ToString() != "") { model.category_id = int.Parse(ds.Tables[0].Rows[0]["category_id"].ToString()); } model.title = ds.Tables[0].Rows[0]["title"].ToString(); if (ds.Tables[0].Rows[0]["add_time"].ToString() != "") { model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } DataSet ds1 = new DAL.standard_value().GetList("standard_id=" + id); List<Model.standard_value> lst = new List<Model.standard_value>(); if (ds1.Tables[0] != null && ds1.Tables[0].Rows.Count > 0) { Model.standard_value model_value; foreach (DataRow dr in ds1.Tables[0].Rows) { model_value = new Model.standard_value(); if (dr["id"] != null && dr["id"].ToString() != "") { model_value.id = int.Parse(dr["id"].ToString()); } if (dr["standard_id"] != null && dr["standard_id"].ToString() != "") { model_value.standard_id = int.Parse(dr["standard_id"].ToString()); } if (dr["value"] != null && dr["value"].ToString() != "") { model_value.value = dr["value"].ToString(); } if (dr["add_time"] != null && dr["add_time"].ToString() != "") { model_value.add_time = DateTime.Parse(dr["add_time"].ToString()); } lst.Add(model_value); } } if (lst.Count > 0) { model.standard_values = lst; } else { model.standard_values = null; } return model; } else { return null; } }
private bool DoAdd() { bool result = false; string standard_values = DTRequest.GetFormString("ck_standard_value"); if (string.IsNullOrEmpty(standard_values)) { JscriptMsg("保存过程中发生错误!", "", "Error"); return false; } BLL.standard bll = new BLL.standard(); Model.standard model = new Model.standard(); model.title = txt_standard_title.Text.Trim(); model.category_id = Convert.ToInt32(ddlCategoryId.SelectedValue); model.add_time = DateTime.Now; List<Model.standard_value> lst = new List<Model.standard_value>(); string[] standard_value_arr = standard_values.Split(','); Model.standard_value model_value; foreach (string str in standard_value_arr) { model_value = new Model.standard_value(); model_value.value = str.Split('|')[1]; model_value.add_time = DateTime.Now; lst.Add(model_value); } model.standard_values = lst; if (bll.Add(model) > 0) { //AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加用户:" + model.user_name); //记录日志 result = true; } return result; }
private bool DoEdit(int _id) { bool result = false; string standard_values = DTRequest.GetFormString("ck_standard_value"); BLL.standard bll = new BLL.standard(); Model.standard model = bll.GetModel(_id); model.title = txt_standard_title.Text.Trim(); model.category_id = Convert.ToInt32(ddlCategoryId.SelectedValue); List<Model.standard_value> lst = new List<Model.standard_value>(); string[] standard_value_arr = standard_values.Split(','); Model.standard_value model_value; foreach (string str in standard_value_arr) { model_value = new Model.standard_value(); model_value.value = str.Split('|')[1]; model_value.add_time = DateTime.Now; lst.Add(model_value); } model.standard_values = lst; if (bll.Update(model)) { //AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改用户信息:" + model.user_name); //记录日志 result = true; } return result; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.standard GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id, category_id, title, add_time "); strSql.Append(" from td_standard "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.standard model = new Model.standard(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["category_id"].ToString() != "") { model.category_id = int.Parse(ds.Tables[0].Rows[0]["category_id"].ToString()); } model.title = ds.Tables[0].Rows[0]["title"].ToString(); if (ds.Tables[0].Rows[0]["add_time"].ToString() != "") { model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } DataSet ds1 = new DAL.standard_value().GetList("standard_id=" + id); List <Model.standard_value> lst = new List <Model.standard_value>(); if (ds1.Tables[0] != null && ds1.Tables[0].Rows.Count > 0) { Model.standard_value model_value; foreach (DataRow dr in ds1.Tables[0].Rows) { model_value = new Model.standard_value(); if (dr["id"] != null && dr["id"].ToString() != "") { model_value.id = int.Parse(dr["id"].ToString()); } if (dr["standard_id"] != null && dr["standard_id"].ToString() != "") { model_value.standard_id = int.Parse(dr["standard_id"].ToString()); } if (dr["value"] != null && dr["value"].ToString() != "") { model_value.value = dr["value"].ToString(); } if (dr["add_time"] != null && dr["add_time"].ToString() != "") { model_value.add_time = DateTime.Parse(dr["add_time"].ToString()); } lst.Add(model_value); } } if (lst.Count > 0) { model.standard_values = lst; } else { model.standard_values = null; } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.standard_value GetModel(int id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select id, standard_id, value, add_time "); strSql.Append(" from td_standard_value "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4) }; parameters[0].Value = id; Model.standard_value model=new Model.standard_value(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["id"].ToString()!="") { model.id=int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if(ds.Tables[0].Rows[0]["standard_id"].ToString()!="") { model.standard_id=int.Parse(ds.Tables[0].Rows[0]["standard_id"].ToString()); } model.value= ds.Tables[0].Rows[0]["value"].ToString(); if(ds.Tables[0].Rows[0]["add_time"].ToString()!="") { model.add_time=DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } return model; } else { return null; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.standard_value model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.standard_value model) { return(dal.Add(model)); }