private void attach_tblInformatics(tblInformatic entity) { this.SendPropertyChanging(); entity.tblUser = this; }
private void detach_tblInformatics1(tblInformatic entity) { this.SendPropertyChanging(); entity.tblUser1 = null; }
partial void UpdatetblInformatic(tblInformatic instance);
partial void DeletetblInformatic(tblInformatic instance);
partial void InserttblInformatic(tblInformatic instance);
/// <summary> /// Thêm một bài giảng/bài tập/đề thi tin học /// </summary> /// <param name="_title"></param> /// <param name="_type"></param> /// <param name="_content"></param> /// <param name="_author"></param> /// <param name="_posted"></param> /// <param name="_location"></param> /// <returns></returns> public Boolean insertInformatic(string _title, int _type, string _content, string _author, DateTime _posted, int _leitmotif, string _location, string _tag, string _folderID) { LTDHDataContext DB = new LTDHDataContext(@strPathDB); try { using (TransactionScope ts = new TransactionScope()) { tblInformatic record = new tblInformatic(); record.Title = _title; record.Type = _type; record.Contents = _content; record.Leitmotif = _leitmotif; record.Author = _author; record.Posted = _posted; record.Point = 0; record.State = CommonConstants.STATE_UNCHECK; record.Location = _location; record.Tag = _tag; record.StickyFlg = false; record.Score = 0; record.DeleteFlg = false; record.FolderID = _folderID; DB.tblInformatics.InsertOnSubmit(record); DB.SubmitChanges(); ts.Complete(); ltktDAO.Statistics statisticDAO = new ltktDAO.Statistics(); statisticDAO.add(CommonConstants.SF_NUM_UPLOAD, CommonConstants.CONST_ONE); log.writeLog(DBHelper.strPathLogFile, record.Author, BaseServices.createMsgByTemplate(CommonConstants.SQL_INSERT_SUCCESSFUL_TEMPLATE, _title, CommonConstants.SQL_TABLE_INFORMATICS)); } } catch (Exception e) { log.writeLog(DBHelper.strPathLogFile, _author, e.Message + CommonConstants.NEWLINE + e.Source + CommonConstants.NEWLINE + e.StackTrace + CommonConstants.NEWLINE + e.HelpLink); return false; } return true; }
/// <summary> /// Thêm bài mới /// </summary> /// <param name="record"></param> /// <returns></returns> public Boolean insertInformatic(tblInformatic record) { LTDHDataContext DB = new LTDHDataContext(@strPathDB); try { using (TransactionScope ts = new TransactionScope()) { DB.tblInformatics.InsertOnSubmit(record); DB.SubmitChanges(); ts.Complete(); log.writeLog(DBHelper.strPathLogFile, record.Author, BaseServices.createMsgByTemplate(CommonConstants.SQL_INSERT_SUCCESSFUL_TEMPLATE, record.ID.ToString(), CommonConstants.SQL_TABLE_INFORMATICS)); } } catch (Exception e) { log.writeLog(DBHelper.strPathLogFile, record.Author, e.Message + CommonConstants.NEWLINE + e.Source + CommonConstants.NEWLINE + e.StackTrace + CommonConstants.NEWLINE + e.HelpLink); return false; } return true; }
//public Boolean insertInformatic(string _title, int _type, string _content, // string _author, DateTime _posted, string _location, string _tag) //{ // return false; //} /// <summary> /// Cập nhật bài viết /// </summary> /// <param name="update"></param> /// <returns></returns> public Boolean updateInformatic(int _id, tblInformatic update, string currentUsername) { LTDHDataContext DB = new LTDHDataContext(@strPathDB); try { using (TransactionScope ts = new TransactionScope()) { var informatic = DB.tblInformatics.Single(info => info.ID == _id); if (informatic != null) { informatic.Title = update.Title; informatic.Type = update.Type; informatic.Chapeau = update.Chapeau; informatic.Contents = update.Contents; informatic.Author = update.Author; informatic.Posted = update.Posted; ltktDAO.Users userDao = new ltktDAO.Users(); if (informatic.State == CommonConstants.STATE_UNCHECK && update.State == CommonConstants.STATE_CHECKED) { userDao.addNumberOfArticle(informatic.Author.Trim()); } else if (informatic.State == CommonConstants.STATE_CHECKED && update.State == CommonConstants.STATE_UNCHECK) { userDao.subNumberOfArticle(informatic.Author.Trim()); } informatic.State = update.State; informatic.Tag = update.Tag; informatic.HtmlEmbedLink = update.HtmlEmbedLink; informatic.HtmlPreview = update.HtmlPreview; //informatic.DeleteFlg = false; informatic.Checker = update.Checker; informatic.Leitmotif = update.Leitmotif; informatic.StickyFlg = update.StickyFlg; informatic.Comment = update.Comment; informatic.Thumbnail = update.Thumbnail; informatic.Location = update.Location; DB.SubmitChanges(); } ts.Complete(); //write log log.writeLog(DBHelper.strPathLogFile, currentUsername, BaseServices.createMsgByTemplate(CommonConstants.SQL_UPDATE_SUCCESSFUL_TEMPLATE, _id.ToString(), CommonConstants.SQL_TABLE_INFORMATICS)); } } catch (Exception e) { log.writeLog(DBHelper.strPathLogFile, currentUsername, e.Message + CommonConstants.NEWLINE + e.Source + CommonConstants.NEWLINE + e.StackTrace + CommonConstants.NEWLINE + e.HelpLink); return false; } return true; }
/// <summary> /// build article for informatics /// </summary> /// <param name="item"></param> /// <returns></returns> private string buildArticleForInformatics(tblInformatic item) { string data = CommonConstants.BLANK; try { BaseServices bs = new BaseServices(); data += " <div class='block_details'>\n" + " <div class='block_details_img'>\n" + " <span title='" + item.Title + "'>" + BaseServices.createMsgByTemplate(CommonConstants.TEMP_IMG_THUMBNAIL, bs.getThumbnail(item.Thumbnail, item.Location), item.Title.Trim()) + "</span>\n" + " </div>\n" + " <div class='block_details_title'>\n" + " <span title='" + item.Title + "'>" + BaseServices.createMsgByTemplate(CommonConstants.TEMP_ARTICLE_DETAILS_LINK, CommonConstants.SEC_INFORMATICS_CODE, item.ID.ToString(), bs.subString(item.Title)) + "</span>\n" + " </div>\n" + " </div>\n"; } catch (Exception ex) { log.writeLog(Server.MapPath(CommonConstants.PATH_LOG_FILE), ex.Message + CommonConstants.NEWLINE + ex.Source + CommonConstants.NEWLINE + ex.StackTrace + CommonConstants.NEWLINE + ex.HelpLink); Session[CommonConstants.SES_ERROR] = CommonConstants.MSG_E_COMMON_ERROR_TEXT; Response.Redirect(CommonConstants.PAGE_ERROR); } return data; }