/// <summary> /// 增加一条数据 /// </summary> public static Hashtable Insert(Model.Sys_SecurityQuestion model, Hashtable MyHs) { string guid = Guid.NewGuid().ToString(); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Sys_SecurityQuestion("); strSql.Append("Code,Question,CreatedBy,CreatedTime,LastUpdateBy,LastUpdateTime,IsDeleted,Status"); strSql.Append(") values ("); strSql.Append("@Code,@Question,@CreatedBy,@CreatedTime,@LastUpdateBy,@LastUpdateTime,@IsDeleted,@Status"); strSql.Append(") "); strSql.AppendFormat(";select '{0}'", guid); SqlParameter[] parameters = { new SqlParameter("@Code", SqlDbType.VarChar, 40), new SqlParameter("@Question", SqlDbType.NVarChar, 500), new SqlParameter("@CreatedBy", SqlDbType.NVarChar, 40), new SqlParameter("@CreatedTime", SqlDbType.DateTime), new SqlParameter("@LastUpdateBy", SqlDbType.NVarChar, 40), new SqlParameter("@LastUpdateTime", SqlDbType.DateTime), new SqlParameter("@IsDeleted", SqlDbType.Bit, 1), new SqlParameter("@Status", SqlDbType.Int, 4) }; parameters[0].Value = model.Code; parameters[1].Value = model.Question; parameters[2].Value = model.CreatedBy; parameters[3].Value = model.CreatedTime; parameters[4].Value = model.LastUpdateBy; parameters[5].Value = model.LastUpdateTime; parameters[6].Value = model.IsDeleted; parameters[7].Value = model.Status; MyHs.Add(strSql.ToString(), parameters); return(MyHs); }
protected IList <Model.Sys_SecurityQuestion> AddToTotalModel(IList <Model.Sys_SecurityQuestion> toAdd, IList <Model.Sys_SecurityQuestion> origin) { foreach (Model.Sys_SecurityQuestion obj in origin) { Model.Sys_SecurityQuestion newObj = obj; toAdd.Add(newObj); } return(toAdd); }
private Model.Sys_SecurityQuestion NewEntity(object id, string question) { Model.Sys_SecurityQuestion obj = null; if (!string.IsNullOrEmpty(question)) { obj = new Model.Sys_SecurityQuestion { ID = ToNullLong(id), Question = question }; } return(obj); }
protected override string btnAdd_Click() { Model.Sys_SecurityQuestion obj = null; IList <Model.Sys_SecurityQuestion> list = GetDetailModelList(); IList <Model.Sys_SecurityQuestion> listNew = new List <Model.Sys_SecurityQuestion>(); foreach (Model.Sys_SecurityQuestion objNew in list) { Model.Sys_SecurityQuestion sq = objNew; if (objNew.ID == 0) { sq.CreatedBy = TModel.MID; sq.CreatedTime = DateTime.Now; sq.Status = 1; } else { sq = new BLL.Sys_SecurityQuestion().GetModel(objNew.ID); sq.Question = objNew.Question; sq.LastUpdateBy = TModel.MID; sq.LastUpdateTime = DateTime.Now; } listNew.Add(sq); } //删除需要删除的 string deleteId = Request.Form["hidDelIds"]; if (!string.IsNullOrEmpty(deleteId)) { string[] arr = deleteId.Split(','); foreach (string str in arr) { if (!string.IsNullOrEmpty(str)) { Sys_SecurityQuestion sq = new BLL.Sys_SecurityQuestion().GetModel(str); sq.IsDeleted = true;//执行逻辑删除 sq.LastUpdateBy = TModel.MID; sq.LastUpdateTime = DateTime.Now; // new BLL.Sys_SecurityQuestion().Delete(str);//不执行物理删除, listNew.Add(sq); } } } //更新或新增 if (new BLL.Sys_SecurityQuestion().SaveOrUpdate(listNew)) { return("操作成功"); } else { return("操作失败"); } }
/// <summary> /// 更新一条数据 /// </summary> public static Hashtable Update(Model.Sys_SecurityQuestion model, Hashtable MyHs) { string guid = Guid.NewGuid().ToString(); StringBuilder strSql = new StringBuilder(); strSql.Append("update Sys_SecurityQuestion set "); strSql.Append(" Code = @Code , "); strSql.Append(" Question = @Question , "); strSql.Append(" CreatedBy = @CreatedBy , "); strSql.Append(" CreatedTime = @CreatedTime , "); strSql.Append(" LastUpdateBy = @LastUpdateBy , "); strSql.Append(" LastUpdateTime = @LastUpdateTime , "); strSql.Append(" IsDeleted = @IsDeleted , "); strSql.Append(" Status = @Status "); strSql.Append(" where ID=@ID "); strSql.AppendFormat(" ;select '{0}'", guid); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.BigInt, 8), new SqlParameter("@Code", SqlDbType.VarChar, 40), new SqlParameter("@Question", SqlDbType.NVarChar, 500), new SqlParameter("@CreatedBy", SqlDbType.NVarChar, 40), new SqlParameter("@CreatedTime", SqlDbType.DateTime), new SqlParameter("@LastUpdateBy", SqlDbType.NVarChar, 40), new SqlParameter("@LastUpdateTime", SqlDbType.DateTime), new SqlParameter("@IsDeleted", SqlDbType.Bit, 1), new SqlParameter("@Status", SqlDbType.Int, 4) }; parameters[0].Value = model.ID; parameters[1].Value = model.Code; parameters[2].Value = model.Question; parameters[3].Value = model.CreatedBy; parameters[4].Value = model.CreatedTime; parameters[5].Value = model.LastUpdateBy; parameters[6].Value = model.LastUpdateTime; parameters[7].Value = model.IsDeleted; parameters[8].Value = model.Status; MyHs.Add(strSql.ToString(), parameters); return(MyHs); }
public bool SaveOrUpdate(IList <Model.Sys_SecurityQuestion> list) { Hashtable MyHs = new Hashtable();//以事务方式 foreach (Model.Sys_SecurityQuestion obj in list) { if (obj.ID == 0) //需要插入的 { DAL.Sys_SecurityQuestion.Insert(obj); } else { //需要更新的 Model.Sys_SecurityQuestion objUpdate = obj; DAL.Sys_SecurityQuestion.Update(obj); } } return(CommonBase.RunHashtable(MyHs)); }
/// <summary> /// 实体转换 /// <summary> private static Model.Sys_SecurityQuestion TranEntity(DataRow dr) { if (dr != null) { Model.Sys_SecurityQuestion model = new Model.Sys_SecurityQuestion(); if (!string.IsNullOrEmpty(dr["ID"].ToString())) { model.ID = long.Parse(dr["ID"].ToString()); } model.Code = dr["Code"].ToString(); model.Question = dr["Question"].ToString(); model.CreatedBy = dr["CreatedBy"].ToString(); if (!string.IsNullOrEmpty(dr["CreatedTime"].ToString())) { model.CreatedTime = DateTime.Parse(dr["CreatedTime"].ToString()); } model.LastUpdateBy = dr["LastUpdateBy"].ToString(); if (!string.IsNullOrEmpty(dr["LastUpdateTime"].ToString())) { model.LastUpdateTime = DateTime.Parse(dr["LastUpdateTime"].ToString()); } if (!string.IsNullOrEmpty(dr["IsDeleted"].ToString())) { model.IsDeleted = bool.Parse(dr["IsDeleted"].ToString()); } if (!string.IsNullOrEmpty(dr["Status"].ToString())) { model.Status = int.Parse(dr["Status"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public static bool Insert(Model.Sys_SecurityQuestion model) { return(DAL.CommonBase.RunHashtable(Insert(model, new Hashtable()))); }
public bool Update(Model.Sys_SecurityQuestion model) { return(DAL.Sys_SecurityQuestion.Update(model)); }
public Hashtable Update(Model.Sys_SecurityQuestion model, Hashtable MyHs) { return(DAL.Sys_SecurityQuestion.Update(model, MyHs)); }
public bool Insert(Model.Sys_SecurityQuestion model) { return(DAL.Sys_SecurityQuestion.Insert(model)); }
public Hashtable Insert(Model.Sys_SecurityQuestion model, Hashtable MyHs) { return(DAL.Sys_SecurityQuestion.Insert(model, MyHs)); }