public bool insertStory(String user_id, String password, String title, String content) { int count = 0; Model.StoryModel sm = new Model.StoryModel(); if (dbOperation.queryExistUser(user_id, password)) { count = dbOperation.countStory(user_id); if (count != -1) { string id = count.ToString(); while (id.Length < 5) { id = "0" + id; } id = "S" + user_id.Substring(1) + id; sm.user_id = user_id; sm.story_id = id; sm.title = title; sm.content = content; if (dbOperation.insertStory(sm)) { return(true); } } } return(false); }
public bool insertStory(String user_id, String photo, String content) { int count = 0; Model.StoryModel sm = new Model.StoryModel(); count = dbOperation.countStory(user_id); if (count != -1) { string id = count.ToString(); while (id.Length < 5) { id = "0" + id; } id = "S" + user_id.Substring(1) + id; Byte[] buffer = Convert.FromBase64String(photo); sm.user_id = user_id; sm.story_id = id; sm.photo = buffer; sm.content = content; if (dbOperation.insertStory(sm)) { return(true); } } return(false); }
public bool updateStoryState(String user_id, String password, String story_id, String state, String mshow) { if (dbOperation.queryExistUserStory(user_id, story_id, password)) { Model.StoryModel sm = new Model.StoryModel(); sm.user_id = user_id; sm.story_id = story_id; sm.state = state.ElementAt(0); sm.mshow = mshow.ElementAt(0); return(dbOperation.updateStoryState(sm)); } return(false); }
public bool updateStory(String user_id, String password, String story_id, String title, String content) { if (dbOperation.queryExistUserStory(user_id, story_id, password)) { Model.StoryModel sm = new Model.StoryModel(); sm.user_id = user_id; sm.story_id = story_id; sm.title = title; sm.content = content; return(dbOperation.updateStory(sm)); } return(false); }
public List <Model.StoryModel> queryOneStory(String story_id) { List <Model.StoryModel> list = new List <Model.StoryModel>(); try { string sql = "select story_id,user_id,title,content,state,mshow,edittime from story where story_id = '" + story_id + "'"; MySqlCommand cmd = new MySqlCommand(sql, sqlCon); MySqlDataReader reader = cmd.ExecuteReader(); Model.StoryModel sm = null; if (reader.HasRows) { while (reader.Read()) { sm = new StoryModel(); sm.story_id = reader[0].ToString(); sm.user_id = reader[1].ToString(); sm.title = reader[2].ToString(); sm.content = reader[3].ToString(); sm.state = reader[4].ToString().ElementAt(0); sm.mshow = reader[5].ToString().ElementAt(0); string date = reader[6].ToString(); if (date != "") { sm.editTime = DateTime.Parse(date); } list.Add(sm); } } reader.Close(); cmd.Dispose(); } catch (Exception e) { } return(list); }