/// <summary> /// 得到一个对象实体 /// </summary> public objSpecificType DataRowToModel(DataRow row) { objSpecificType model = new objSpecificType(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["TypeID"] != null && row["TypeID"].ToString() != "") { model.TypeID = int.Parse(row["TypeID"].ToString()); } if (row["Name"] != null) { model.Name = row["Name"].ToString(); } if (row["Remake"] != null) { model.Remake = row["Remake"].ToString(); } } return(model); }
/// <summary> /// 列表页 /// </summary> /// <param name="ID"></param> /// <returns></returns> public ActionResult List(string ID) { if (ID == null) { ViewData["Title1"] = "非法登陆"; ViewData["NewMsg"] = new List <objMsg>(); ViewData["book"] = new List <objSpecificType>(); return(View()); } List <objSpecificType> ListBook = bllSpecificType.GetModelList(" TypeID=1 "); objSpecificType obj = bllSpecificType.GetModel(int.Parse(ID)); List <objMsg> listMsgs = bll.GetModelList(" 1=1 and SpecificTypeID=" + ID + ""); ViewData["Title1"] = obj.Name; ViewData["NewMsg"] = objMsgBase64ToString(listMsgs); ViewData["book"] = ListBook; return(View()); }
///// <summary> ///// 是否存在该记录 ///// </summary> //public bool Exists(int ID) //{ // int rowsAffected; // MySqlParameter[] parameters = { // new MySqlParameter("@ID", MySqlDbType.Int32) // }; // parameters[0].Value = ID; // int result = DbHelperMySQL.RunProcedure("p_objspecifictype_Exists", parameters, out rowsAffected); // if (result == 1) // { // return true; // } // else // { // return false; // } //} /// <summary> /// 增加一条数据 /// </summary> public bool Add(objSpecificType model) { string str = "insert into p_objspecifictype(TypeID,Name,Remake) value(@TypeID,@Name,@Remake);"; MySqlParameter[] parameters = { new MySqlParameter("@ID", MySqlDbType.Int32, 11), new MySqlParameter("@TypeID", MySqlDbType.Int32, 11), new MySqlParameter("@Name", MySqlDbType.VarChar, 255), new MySqlParameter("@Remake", MySqlDbType.VarChar, 255) }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.TypeID; parameters[2].Value = model.Name; parameters[3].Value = model.Remake; if (DBHelper.ExecuteSql(str, parameters) >= 0) { return(true); } return(false); }
/// <summary> /// 得到一个对象实体 /// </summary> public objSpecificType GetModel(int ID) { string str = "SELECT * FROM p_objspecifictype WHERE ID=@ID; "; MySqlParameter[] parameters = { new MySqlParameter("@ID", MySqlDbType.Int32) }; parameters[0].Value = ID; objSpecificType model = new objSpecificType(); DataSet ds = DBHelper.Query(str, parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(objSpecificType model) { string str = "UPDATE p_objspecifictype SET TypeID=@TypeID,Name=@Name,Remake=@Remake where ID=@ID;"; MySqlParameter[] parameters = { new MySqlParameter("@ID", MySqlDbType.Int32, 11), new MySqlParameter("@TypeID", MySqlDbType.Int32, 11), new MySqlParameter("@Name", MySqlDbType.VarChar, 255), new MySqlParameter("@Remake", MySqlDbType.VarChar, 255) }; parameters[0].Value = model.ID; parameters[1].Value = model.TypeID; parameters[2].Value = model.Name; parameters[3].Value = model.Remake; if (DBHelper.ExecuteSql(str, parameters) >= 0) { return(true); } return(false); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(objSpecificType model) { return(dal.Update(model)); }
///// <summary> ///// 是否存在该记录 ///// </summary> //public bool Exists(int ID) //{ // return dal.Exists(ID); //} /// <summary> /// 增加一条数据 /// </summary> public bool Add(objSpecificType model) { return(dal.Add(model)); }