private void pageLoad(object sender, EventArgs e, tblUser user)
        {
            bool isDeleted = false;
            bool isEditError = false;
            bool isDeletedSuccessful = false;
            bool isSearchFreeNOK = false;
            tblUser savedUser = null;
            try
            {
                int page = 1;
                string action = Request.QueryString[CommonConstants.REQ_ACTION];
                string sPage = Request.QueryString[CommonConstants.REQ_PAGE];
                string state = Request.QueryString[CommonConstants.REQ_STATE];
                if (BaseServices.isNullOrBlank(action))
                {
                    action = CommonConstants.ACT_SEARCH;
                }
                if (BaseServices.isNullOrBlank(sPage))
                {
                    sPage = CommonConstants.PAGE_NUMBER_FIRST;
                }
                if (BaseServices.isNullOrBlank(state))
                {
                    state = CommonConstants.ALL;
                }
                page = Convert.ToInt32(sPage);
                 //action is Search
                if (action == CommonConstants.ACT_SEARCH)
                {
                    if (Page.IsPostBack)
                    {
                        return;
                    }
                    viewPanel.Visible = true;
                    detailPanel.Visible = false;
                    messagePanel.Visible = false;
                    IEnumerable<tblEnglish> lst = null;
                    string key = Request.QueryString[CommonConstants.REQ_KEY];
                    int totalRecord = 0;

                    showCountingArticle();

                    if (BaseServices.isNullOrBlank(key))
                    {
                        key = CommonConstants.ALL;
                    }
                    else
                    {
                        key = BaseServices.nullToBlank(key);
                    }
                    key = key.ToLower();
                    changeViewState(key);
                    if (key == CommonConstants.ALL)
                    {
                        if (state == CommonConstants.ALL)// key = ALL and state = ALL
                        {
                            lst = englishDAO.fetchEnglishList(((page - 1) * NoOfEnglishPerPage), NoOfEnglishPerPage);
                            totalRecord = englishDAO.count();
                            hpkShowAllState.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowAllState.Text+ "(" + totalRecord + ")");
                            hpkShowBad.Text += "(" + englishDAO.countEnglishList(CommonConstants.STATE_BAD) + ")";
                            hpkShowChecked.Text += "(" + englishDAO.countEnglishList(CommonConstants.STATE_CHECKED) + ")";
                            hpkShowUncheck.Text += "(" + englishDAO.countEnglishList(CommonConstants.STATE_UNCHECK) + ")";
                            statDAO.setValue(CommonConstants.SF_NUM_ARTICLE_ON_EL, totalRecord.ToString());
                        }
                        else if (state == CommonConstants.STATE_UNCHECK.ToString())// key = ALL and state = UNCHECk
                        {
                            lst = englishDAO.fetchEnglishList(CommonConstants.STATE_UNCHECK, ((page - 1) * NoOfEnglishPerPage), NoOfEnglishPerPage);
                            totalRecord = englishDAO.countEnglishList(CommonConstants.STATE_UNCHECK);
                            hpkShowAllState.Text += "(" + englishDAO.count() +")";
                            hpkShowUncheck.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowUncheck.Text + "(" + totalRecord + ")");
                            hpkShowChecked.Text += "(" + englishDAO.countEnglishList(CommonConstants.STATE_CHECKED) + ")";
                            hpkShowBad.Text += "(" + englishDAO.countEnglishList(CommonConstants.STATE_BAD) + ")";
                        }
                        else if (state == CommonConstants.STATE_CHECKED.ToString())// key = ALL and state = CHECKED
                        {
                            lst = englishDAO.fetchEnglishList(CommonConstants.STATE_CHECKED, ((page - 1) * NoOfEnglishPerPage), NoOfEnglishPerPage);
                            totalRecord = englishDAO.countEnglishList(CommonConstants.STATE_CHECKED);
                            hpkShowAllState.Text += "(" + englishDAO.count() + ")";
                            hpkShowBad.Text += "(" + englishDAO.countEnglishList(CommonConstants.STATE_BAD) + ")";
                            hpkShowChecked.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowChecked.Text + "(" + totalRecord + ")");
                            hpkShowUncheck.Text += "(" + englishDAO.countEnglishList(CommonConstants.STATE_UNCHECK) + ")";

                        }
                        else if (state == CommonConstants.STATE_BAD.ToString())// key = ALL and state = BAD
                        {
                            lst = englishDAO.fetchEnglishList(CommonConstants.STATE_BAD, ((page - 1) * NoOfEnglishPerPage), NoOfEnglishPerPage);
                            totalRecord = englishDAO.countEnglishList(CommonConstants.STATE_BAD);
                            hpkShowAllState.Text += "(" + englishDAO.count() + ")";
                            hpkShowUncheck.Text += "(" + englishDAO.countEnglishList(CommonConstants.STATE_UNCHECK) + ")";
                            hpkShowChecked.Text += "(" + englishDAO.countEnglishList(CommonConstants.STATE_CHECKED) + ")";
                            hpkShowBad.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowBad.Text + "(" + totalRecord + ")");

                        }
                    }
                    else if (key == CommonConstants.TXT_STICKY.ToLower())
                    {
                        //change state link
                        changeStateLink(key);
                        if (state == CommonConstants.ALL)// key == sticky and state = ALL
                        {
                            lst = englishDAO.fetchStickyEnglishList(((page - 1) * NoOfEnglishPerPage), NoOfEnglishPerPage);
                            totalRecord = englishDAO.countStickyArticle();
                            hpkShowAllState.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowAllState.Text + "(" + totalRecord + ")");
                            hpkShowBad.Text += "(" + englishDAO.countStickyEnglishList(CommonConstants.STATE_BAD) + ")";
                            hpkShowChecked.Text += "(" + englishDAO.countStickyEnglishList(CommonConstants.STATE_CHECKED) + ")";
                            hpkShowUncheck.Text += "(" + englishDAO.countStickyEnglishList(CommonConstants.STATE_UNCHECK) + ")";

                        }
                        else if (state == CommonConstants.STATE_UNCHECK.ToString())// key == sticky and state = UNCHECk
                        {
                            lst = englishDAO.fetchStickyEnglishList(CommonConstants.STATE_UNCHECK, ((page - 1) * NoOfEnglishPerPage), NoOfEnglishPerPage);
                            totalRecord = englishDAO.countStickyEnglishList(CommonConstants.STATE_UNCHECK);
                            hpkShowAllState.Text += "(" + englishDAO.countStickyArticle() + ")";
                            hpkShowUncheck.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowUncheck.Text + "(" + totalRecord + ")");
                            hpkShowChecked.Text += "(" + englishDAO.countStickyEnglishList(CommonConstants.STATE_CHECKED) + ")";
                            hpkShowBad.Text += "(" + englishDAO.countStickyEnglishList(CommonConstants.STATE_BAD) + ")";
                        }
                        else if (state == CommonConstants.STATE_CHECKED.ToString())// key = sticky and state = CHECKED
                        {
                            lst = englishDAO.fetchStickyEnglishList(CommonConstants.STATE_CHECKED, ((page - 1) * NoOfEnglishPerPage), NoOfEnglishPerPage);
                            totalRecord = englishDAO.countStickyEnglishList(CommonConstants.STATE_CHECKED);
                            hpkShowAllState.Text += "(" + englishDAO.countStickyArticle() + ")";
                            hpkShowBad.Text += "(" + englishDAO.countStickyEnglishList( CommonConstants.STATE_BAD) + ")";
                            hpkShowChecked.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowChecked.Text + "(" + totalRecord + ")");
                            hpkShowUncheck.Text += "(" + englishDAO.countStickyEnglishList( CommonConstants.STATE_UNCHECK) + ")";

                        }
                        else if (state == CommonConstants.STATE_BAD.ToString())// key = sticky and state = BAD
                        {
                            lst = englishDAO.fetchStickyEnglishList(CommonConstants.STATE_BAD, ((page - 1) * NoOfEnglishPerPage), NoOfEnglishPerPage);
                            totalRecord = englishDAO.countStickyEnglishList(CommonConstants.STATE_BAD);
                            hpkShowAllState.Text += "(" + englishDAO.countStickyArticle() + ")";
                            hpkShowUncheck.Text += "(" + englishDAO.countStickyEnglishList(CommonConstants.STATE_UNCHECK) + ")";
                            hpkShowChecked.Text += "(" + englishDAO.countStickyEnglishList(CommonConstants.STATE_CHECKED) + ")";
                            hpkShowBad.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowBad.Text + "(" + totalRecord + ")");

                        }
                    }
                    else
                    {
                        //change state link
                        changeStateLink(key);

                        if (state == CommonConstants.ALL)// key != ALL and state = ALL
                        {
                            lst = englishDAO.fetchEnglishListWithClass(key, ((page - 1) * NoOfEnglishPerPage), NoOfEnglishPerPage);
                            totalRecord = englishDAO.countEnglishListWithClass(key);
                            hpkShowAllState.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowAllState.Text + "(" + totalRecord + ")");
                            hpkShowBad.Text += "(" + englishDAO.countEnglishList(key, CommonConstants.STATE_BAD) + ")";
                            hpkShowChecked.Text += "(" + englishDAO.countEnglishList(key, CommonConstants.STATE_CHECKED) + ")";
                            hpkShowUncheck.Text += "(" + englishDAO.countEnglishList(key, CommonConstants.STATE_UNCHECK) + ")";

                        }
                        else if (state == CommonConstants.STATE_UNCHECK.ToString())// key = ALL and state = UNCHECk
                        {
                            lst = englishDAO.fetchEnglishList(key, CommonConstants.STATE_UNCHECK, ((page - 1) * NoOfEnglishPerPage), NoOfEnglishPerPage);
                            totalRecord = englishDAO.countEnglishList(key, CommonConstants.STATE_UNCHECK);
                            hpkShowAllState.Text += "(" + englishDAO.countEnglishListWithClass(key) + ")";
                            hpkShowUncheck.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowUncheck.Text + "(" + totalRecord + ")");
                            hpkShowChecked.Text += "(" + englishDAO.countEnglishList(key, CommonConstants.STATE_CHECKED) + ")";
                            hpkShowBad.Text += "(" + englishDAO.countEnglishList(key, CommonConstants.STATE_BAD) + ")";
                        }
                        else if (state == CommonConstants.STATE_CHECKED.ToString())// key = ALL and state = CHECKED
                        {
                            lst = englishDAO.fetchEnglishList(key, CommonConstants.STATE_CHECKED, ((page - 1) * NoOfEnglishPerPage), NoOfEnglishPerPage);
                            totalRecord = englishDAO.countEnglishList(key, CommonConstants.STATE_CHECKED);
                            hpkShowAllState.Text += "(" + englishDAO.countEnglishListWithClass(key) + ")";
                            hpkShowBad.Text += "(" + englishDAO.countEnglishList(key, CommonConstants.STATE_BAD) + ")";
                            hpkShowChecked.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowChecked.Text + "(" + totalRecord + ")");
                            hpkShowUncheck.Text += "(" + englishDAO.countEnglishList(key, CommonConstants.STATE_UNCHECK) + ")";

                        }
                        else if (state == CommonConstants.STATE_BAD.ToString())// key = ALL and state = BAD
                        {
                            lst = englishDAO.fetchEnglishList(key, CommonConstants.STATE_BAD, ((page - 1) * NoOfEnglishPerPage), NoOfEnglishPerPage);
                            totalRecord = englishDAO.countEnglishList(key, CommonConstants.STATE_BAD);
                            hpkShowAllState.Text += "(" + englishDAO.countEnglishListWithClass(key) + ")";
                            hpkShowUncheck.Text += "(" + englishDAO.countEnglishList(key, CommonConstants.STATE_UNCHECK) + ")";
                            hpkShowChecked.Text += "(" + englishDAO.countEnglishList(key, CommonConstants.STATE_CHECKED) + ")";
                            hpkShowBad.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowBad.Text + "(" + totalRecord + ")");

                        }
                    }
                    // show data
                    bool isOK = false;
                    if (lst != null)
                    {
                        if (lst.Count() > 0)
                        {
                            showEnglishs(lst, totalRecord, page, action, key, state);
                            isOK = true;
                        }

                    }
                    if (!isOK)
                    {
                        showInfoMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND);
                        EnglishTable.Visible = false;
                        return;
                    }
                }
                else if (action == CommonConstants.ACT_SEARCH_FREE)
                {
                    if (Page.IsPostBack)
                    {
                        return;
                    }

                    showCountingArticle();
                    showCountingState();

                    string keyword = Request.QueryString[CommonConstants.REQ_KEY];
                    if (!BaseServices.isNullOrBlank(keyword))
                    {
                        int totalRecord = englishDAO.countArticles(keyword);
                        IEnumerable<tblEnglish> lst = englishDAO.searchArticles(keyword, ((page - 1) * NoOfEnglishPerPage), NoOfEnglishPerPage);
                        showEnglishs(lst, totalRecord, page, CommonConstants.ACT_SEARCH_FREE, keyword, CommonConstants.ALL);
                        txtKeyword.Text = keyword;
                    }
                    else
                    {
                        isSearchFreeNOK = true;
                    }
                }
                else if (action == CommonConstants.ACT_VIEW || action == CommonConstants.ACT_EDIT)
                {
                    if (Page.IsPostBack)
                    {
                        return;
                    }
                    Session[CommonConstants.SES_OLD_PAGE] = Request.UrlReferrer.ToString();
                    detailPanel.Visible = true;
                    viewPanel.Visible = false;
                    if (Request.QueryString[CommonConstants.REQ_ID] != null)
                    {
                        int id = BaseServices.convertStringToInt(Request.QueryString[CommonConstants.REQ_ID].ToString());
                        Session[CommonConstants.SES_ID] = id;
                        tblEnglish article = englishDAO.getArticle(id);
                        if (article != null)
                        {
                            initial();

                            txtTitle.Text = BaseServices.nullToBlank(article.Title);
                            txtChapeau.Text = BaseServices.nullToBlank(article.Contents);
                            txtAuthor.Text = BaseServices.nullToBlank(article.Author);
                            txtPosted.Text = BaseServices.formatDateTimeString(article.Posted);
                            txtTag.Text = BaseServices.nullToBlank(article.Tag);
                            txtPoint.Text = article.Point.ToString();
                            txtChecker.Text = BaseServices.nullToBlank(article.Checker);
                            txtHtmlEmbbed.Text = BaseServices.nullToBlank(article.HtmlPreview);
                            txtHtmlPreviewLink.Text = BaseServices.nullToBlank(article.HtmlEmbedLink);
                            txtLocation.Text = BaseServices.nullToBlank(article.Location);
                            txtChecker.Text = BaseServices.nullToBlank(article.Checker);
                            txtThumbnail.Text = BaseServices.nullToBlank(article.Thumbnail);
                            txtComment.Text = BaseServices.nullToBlank(article.Comment);
                            txtFolderId.Text = BaseServices.nullToBlank(article.FolderID);
                            showFileContent(article.Location);
                            showThumbnail(article.Thumbnail);
                            ddlState.SelectedValue = article.State.ToString();
                            if (article.StickyFlg)
                            {
                                ddlSticky.SelectedValue = CommonConstants.CONST_ONE;
                            }
                            ddlType.SelectedValue = article.Type.ToString();
                            ddlClass.SelectedValue = article.Class.ToString();
                            ddlScore.SelectedValue = article.Score.ToString();

                            if (action == CommonConstants.ACT_VIEW)
                            {
                                btnEdit.Visible = false;
                                changeState(false);
                                liContent.Text += "&nbsp;&nbsp;<input type=\"button\" value=\"Tải tập tin nội dung\" class=\"formbutton\" onclick=\"uploadContent()\" />";
                                liThumbnail.Text += "&nbsp;&nbsp;<input type=\"button\" value=\"Tải hình thu nhỏ\" class=\"formbutton\" onclick=\"uploadThumbnail()\" />";
                            }
                            else
                            {
                                changeState(true);
                                liContent.Text += "&nbsp;&nbsp;<input type=\"button\" value=\"Tải tập tin nội dung\" class=\"formbutton\" onclick=\"uploadContent()\" />";
                                liThumbnail.Text += "&nbsp;&nbsp;<input type=\"button\" value=\"Tải hình thu nhỏ\" class=\"formbutton\" onclick=\"uploadThumbnail()\" />";
                            }
                        }
                        else
                        {
                            isEditError = true;
                        }

                    }
                    else
                    {
                        isEditError = true;
                    }

                }
                else if (action == CommonConstants.ACT_DELETE)
                {
                    if (Request.QueryString[CommonConstants.REQ_ID] != null)
                    {
                        savedUser = (tblUser)Session[CommonConstants.SES_USER];
                        int id = BaseServices.convertStringToInt((string)Request.QueryString[CommonConstants.REQ_ID]);

                        isDeletedSuccessful = englishDAO.setDeleteFlagArticle(id);

                        isDeleted = true;
                    }
                }
            }
            catch (Exception ex)
            {
                log.writeLog(DBHelper.strPathLogFile, user.Username, CommonConstants.MSG_E_LINK_INVALID);
                log.writeLog(DBHelper.strPathLogFile, user.Username, ex.Message
                                                        + CommonConstants.NEWLINE
                                                        + ex.Source
                                                        + CommonConstants.NEWLINE
                                                        + ex.StackTrace
                                                        + CommonConstants.NEWLINE
                                                        + ex.HelpLink);

                Response.Redirect(CommonConstants.PAGE_ADMIN_INFORMATICS
                                              + CommonConstants.ADD_PARAMETER
                                              + CommonConstants.REQ_PAGE
                                              + CommonConstants.EQUAL
                                              + CommonConstants.PAGE_NUMBER_FIRST);
            }
            if (isDeleted)
            {

                if (isDeletedSuccessful)
                {
                    Session[CommonConstants.SES_INFORM] = BaseServices.createMsgByTemplate(CommonConstants.MSG_I_ACTION_SUCCESSFUL, CommonConstants.ACT_DELETE);
                    statDAO.add(CommonConstants.SF_NUM_ARTICLE_ON_EL, CommonConstants.CONST_ONE_NEGATIVE);
                    Session[CommonConstants.SES_USER] = savedUser;
                }
                else
                {
                    Session[CommonConstants.SES_INFORM] = BaseServices.createMsgByTemplate(CommonConstants.MSG_E_ACTION_FAILED, CommonConstants.ACT_DELETE);
                }
                //Response.Redirect(Request.UrlReferrer.ToString());
                Response.Redirect(CommonConstants.PAGE_ADMIN_ENGLISH);
            }
            if (isSearchFreeNOK)
            {
                Session[CommonConstants.SES_INFORM] = CommonConstants.MSG_E_RESOURCE_NOT_FOUND;
                Response.Redirect(CommonConstants.PAGE_ADMIN_ENGLISH);
            }
            if (isEditError)
            {
                detailPanel.Visible = false;
                viewPanel.Visible = false;
                showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND);

            }
        }
        private void pageLoad(object sender, EventArgs e, tblUser userAdmin)
        {
            if (Page.IsPostBack)
            {
                return;
            }
            try
            {
                if (Request.QueryString[CommonConstants.REQ_ACTION] != null)
                {
                    searchPanel.Visible = false;
                    detailPanel.Visible = true;

                    string action = Request.QueryString[CommonConstants.REQ_ACTION];
                    int id = Convert.ToInt32(Request.QueryString[CommonConstants.REQ_ID]);

                    //string[] result = { txtSearch.Text.Trim(), lblResult.Text };
                    Session[CommonConstants.SES_PERMISSION_SEARCH] = Session["temp"];

                    showDetail(id, action);

                    //switch (action)
                    //{
                    //    case CommonConstants.ACT_VIEW:
                    //    case CommonConstants.ACT_EDIT:
                    //        showDetail(id, action);
                    //        break;
                    //    default:
                    //        break;
                    //}
                }
                else
                {
                    searchPanel.Visible = true;
                    detailPanel.Visible = false;

                    if (Session[CommonConstants.SES_PERMISSION_SEARCH] != null)
                    {
                        string[] session = (string[])Session[CommonConstants.SES_PERMISSION_SEARCH];
                        txtSearch.Text = session[0];
                        lblResult.Text = session[1];
                        lblResult.Visible = true;

                        Session[CommonConstants.SES_PERMISSION_SEARCH] = null;
                    }

                }
            }
            catch (Exception ex)
            {
                log.writeLog(DBHelper.strPathLogFile, userAdmin.Username, CommonConstants.MSG_E_LINK_INVALID);
                log.writeLog(DBHelper.strPathLogFile, userAdmin.Username, ex.Message);

                Response.Redirect(CommonConstants.PAGE_ADMIN_PERMISSION);
            }
        }
        private void pageLoad(object sender, EventArgs e, tblUser user)
        {
            bool isDeleted = false;
            try
            {
                int page = 1;
                string action = Request.QueryString[CommonConstants.REQ_ACTION];
                string sPage = Request.QueryString[CommonConstants.REQ_PAGE];
                if (BaseServices.isNullOrBlank(action))
                {
                    action = CommonConstants.ACT_SEARCH;
                }
                if (BaseServices.isNullOrBlank(sPage))
                {
                    sPage = CommonConstants.PAGE_NUMBER_FIRST;
                }

                page = Convert.ToInt32(sPage);

                //action is Search
                if (action == CommonConstants.ACT_SEARCH)
                {
                    viewPanel.Visible = true;
                    detailsPanel.Visible = false;
                    messagePanel.Visible = false;
                    IEnumerable<tblAdvertisement> lst = null;
                    //page = Convert.ToInt32(Request.QueryString[CommonConstants.REQ_PAGE]);
                    string key = Request.QueryString[CommonConstants.REQ_KEY];
                    if (BaseServices.isNullOrBlank(key))
                    {
                        key = CommonConstants.ALL;
                    }
                    else
                    {
                        key = BaseServices.nullToBlank(key);
                    }
                    if (key == CommonConstants.ALL)
                    {
                       lst = adsDAO.fetchAdsList(((page - 1) * NoOfAdsPerPage), NoOfAdsPerPage);
                    }
                    else if (key == CommonConstants.STATE_UNCHECK.ToString()
                        || key == CommonConstants.STATE_STICKY.ToString()
                        || key == CommonConstants.STATE_PENDING.ToString()
                        || key == CommonConstants.STATE_BLOCK.ToString()
                        || key == CommonConstants.STATE_CHECKED.ToString())
                    {
                        lst = adsDAO.fetchAdsList(Convert.ToInt32(key), ((page - 1) * NoOfAdsPerPage), NoOfAdsPerPage);
                    }
                    else if (key == CommonConstants.PARAM_LOCATION)
                    {
                        lst = adsDAO.fetchAdsListByLocation(((page - 1) * NoOfAdsPerPage), NoOfAdsPerPage);
                    }

                    // show data
                    bool isOK = false;
                    if (lst != null)
                    {
                        if (lst.Count() > 0)
                        {
                            showAds(lst, page, action, key);
                            isOK = true;
                        }

                    }
                    if(!isOK)
                    {
                        showInfoMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND);
                        NewsTable.Visible = false;
                        return;
                    }
                }
                //else if (Request.QueryString[CommonConstants.REQ_ACTION] != null)
                //{
                //string action = Request.QueryString[CommonConstants.REQ_ACTION];
                //

                else if (action == CommonConstants.ACT_VIEW || action == CommonConstants.ACT_EDIT)
                {
                    if (Request.QueryString[CommonConstants.REQ_ID] == null)
                    {
                        showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND);
                        return;
                    }
                    if (!BaseServices.isNumeric(Request.QueryString[CommonConstants.REQ_ID]))
                    {
                        showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND);
                        return;
                    }
                    int _id = Convert.ToInt32(Request.QueryString[CommonConstants.REQ_ID]);
                    viewPanel.Visible = false;
                    detailsPanel.Visible = true;
                    messagePanel.Visible = false;

                    if (ddlState.Items.Count == 0)
                    {
                        //ddlState.Items.Insert(0, new ListItem(CommonConstants.STATE_STICKY_NAME, CommonConstants.STATE_STICKY.ToString()));
                        //ddlState.Items.Insert(0, new ListItem(CommonConstants.STATE_PENDING_NAME, CommonConstants.STATE_PENDING.ToString()));
                        //ddlState.Items.Insert(0, new ListItem(CommonConstants.STATE_CHECKED_NAME, CommonConstants.STATE_CHECKED.ToString()));
                        //ddlState.Items.Insert(0, new ListItem(CommonConstants.STATE_UNCHECK_NAME, CommonConstants.STATE_UNCHECK.ToString()));

                        showAdsDetails(_id, action);
                    }
                    if (action == CommonConstants.ACT_VIEW)
                    {
                        btnEdit.Visible = false;
                        btnClone.Visible = false;
                    }

                    //showAdsDetails(_id, action);
                }
                else if (action == CommonConstants.ACT_DELETE)
                {
                    if (Request.QueryString[CommonConstants.REQ_ID] == null)
                    {
                        showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND);
                        return;
                    }
                    if (!BaseServices.isNumeric(Request.QueryString[CommonConstants.REQ_ID]))
                    {
                        showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND);
                        return;
                    }
                    int _id = Convert.ToInt32(Request.QueryString[CommonConstants.REQ_ID]);
                    //tblUser user = (tblUser)Session[CommonConstants.SES_USER];
                    //Boolean completeDelete = adsDAO.deleteAds(_id, user.Username);

                    //if (completeDelete)
                    //{
                    //Response.Write(CommonConstants.ALERT_DELETE_SUCCESSFUL);

                    //Response.Redirect(CommonConstants.PAGE_ADMIN_ADS
                    //                  + CommonConstants.ADD_PARAMETER
                    //                  + CommonConstants.REQ_PAGE
                    //                  + CommonConstants.EQUAL
                    //                  + "1");
                    //}
                    //else
                    //{
                    //    Response.Write(CommonConstants.ALERT_DELETE_FAIL);
                    //}
                    bool isMatch = adsDAO.isState(_id, CommonConstants.STATE_UNCHECK);
                    if (adsDAO.deleteAds(_id, user.Username))
                    {
                        if (isMatch)
                        {
                            ltktDAO.Statistics statDAO = new ltktDAO.Statistics();
                            statDAO.add(CommonConstants.SF_NUM_NEW_ADV_CONTACT, CommonConstants.CONST_ONE_NEGATIVE);
                        }
                        string mess = BaseServices.createMsgByTemplate(CommonConstants.MSG_I_ACTION_SUCCESSFUL, CommonConstants.ACT_DELETE);
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + mess + "');", true);
                        //MessageBox.Show(mess);
                        //Response.End();
                        ltktDAO.Alert.Show(mess);
                        isDeleted = true;
                        //showErrorMessage(BaseServices.createMsgByTemplate(CommonConstants.MSG_I_ACTION_SUCCESSFUL, CommonConstants.ACT_DELETE));

                    }
                }
                //}
                //else
                //{
                //   Response.Redirect(CommonConstants.PAGE_ADMIN_ADS
                //                              + CommonConstants.ADD_PARAMETER
                //                              + CommonConstants.REQ_PAGE
                //                              + CommonConstants.EQUAL
                //                              + "1");
                //}
            }
            catch (Exception ex)
            {
                log.writeLog(DBHelper.strPathLogFile, user.Username, CommonConstants.MSG_E_LINK_INVALID);
                log.writeLog(DBHelper.strPathLogFile, user.Username, ex.Message
                                                        + CommonConstants.NEWLINE
                                                        + ex.Source
                                                        + CommonConstants.NEWLINE
                                                        + ex.StackTrace
                                                        + CommonConstants.NEWLINE
                                                        + ex.HelpLink);
                //Session[CommonConstants.SES_ERROR] = CommonConstants.MSG_LINK_ERROR;
                Response.Redirect(CommonConstants.PAGE_ADMIN_ADS
                                              + CommonConstants.ADD_PARAMETER
                                              + CommonConstants.REQ_PAGE
                                              + CommonConstants.EQUAL
                                              + "1");
            }
            if (isDeleted)
            {
                Response.Redirect(CommonConstants.PAGE_ADMIN_ADS);
            }
        }
 partial void UpdatetblUser(tblUser instance);
 partial void DeletetblUser(tblUser instance);
        private void pageLoad(object sender, EventArgs e, tblUser user)
        {
            string action = Request.QueryString[CommonConstants.REQ_ACTION];
            string sPage = Request.QueryString[CommonConstants.REQ_PAGE];
            bool isDeleted = false;
            try
            {
                //bool isDeleted = false;
                if (BaseServices.isNullOrBlank(action))
                {
                    action = CommonConstants.ACT_SEARCH;
                }
                if (BaseServices.isNullOrBlank(sPage))
                {
                    sPage = CommonConstants.PAGE_NUMBER_FIRST;
                }

                int page = Convert.ToInt32(sPage);
                if (action == CommonConstants.ACT_SEARCH)
                {
                    if (Page.IsPostBack)
                    {
                        return;
                    }
                    showCountingArticle();

                    string key = Request.QueryString[CommonConstants.REQ_KEY];
                    string state = Request.QueryString[CommonConstants.REQ_STATE];
                    int totalRecord = 0;
                    viewPanel.Visible = true;
                    detailPanel.Visible = false;
                    messagePanel.Visible = false;
                    IEnumerable<tblContestForUniversity> lst = null;

                    if (BaseServices.isNullOrBlank(key))
                    {
                        key = CommonConstants.ALL;
                    }
                    else
                    {
                        key = BaseServices.nullToBlank(key);
                    }
                    if (BaseServices.isNullOrBlank(state))
                    {
                        state = CommonConstants.ALL;
                    }
                    changeViewState(key);
                    if (key == CommonConstants.ALL)
                    {
                        if (state == CommonConstants.ALL)// key = ALL and state = ALL
                        {
                            lst = contestDAO.fetchArticleList((page - 1) * NoOfContestPerPage, NoOfContestPerPage);
                            totalRecord = contestDAO.count();
                            string txt = hpkShowAllState.Text;
                            txt += "(" + totalRecord + ")";
                            hpkShowAllState.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt);
                            hpkShowUncheck.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_UNCHECK) + ")";
                            hpkShowChecked.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_CHECKED) + ")";
                            hpkShowBad.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_BAD) + ")";
                        }
                        else if (state == CommonConstants.STATE_UNCHECK.ToString())// key = ALL and state = UNCHECk
                        {
                            lst = contestDAO.fetchArticleList(CommonConstants.STATE_UNCHECK, (page - 1) * NoOfContestPerPage, NoOfContestPerPage);
                            totalRecord = contestDAO.countArticleByState(CommonConstants.STATE_UNCHECK);

                            hpkShowAllState.Text += "(" + contestDAO.count() + ")";
                            string txt = hpkShowUncheck.Text;
                            txt += "(" + totalRecord + ")";
                            hpkShowUncheck.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt);
                            hpkShowChecked.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_CHECKED) + ")";
                            hpkShowBad.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_BAD) + ")";
                        }
                        else if (state == CommonConstants.STATE_CHECKED.ToString())// key = ALL and state = CHECKED
                        {
                            lst = contestDAO.fetchArticleList(CommonConstants.STATE_CHECKED, (page - 1) * NoOfContestPerPage, NoOfContestPerPage);
                            totalRecord = contestDAO.countArticleByState(CommonConstants.STATE_CHECKED);

                            hpkShowAllState.Text += "(" + contestDAO.count() + ")";
                            hpkShowUncheck.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_UNCHECK) + ")";
                            string txt = hpkShowChecked.Text;
                            txt += "(" + totalRecord + ")";
                            hpkShowChecked.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt);
                            hpkShowBad.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_BAD) + ")";
                        }
                        else if (state == CommonConstants.STATE_BAD.ToString())// key = ALL and state = BAD
                        {
                            lst = contestDAO.fetchArticleList(CommonConstants.STATE_BAD, (page - 1) * NoOfContestPerPage, NoOfContestPerPage);
                            totalRecord = contestDAO.countArticleByState(CommonConstants.STATE_BAD);

                            hpkShowAllState.Text += "(" + contestDAO.count() + ")";
                            hpkShowUncheck.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_UNCHECK) + ")";
                            hpkShowChecked.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_CHECKED) + ")";
                            string txt = hpkShowBad.Text;
                            txt += "(" + totalRecord + ")";
                            hpkShowBad.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt);
                        }

                    }
                    else if (key == CommonConstants.TXT_STICKY.ToLower())
                    {
                        changeStateLink(key);
                        if (state == CommonConstants.ALL)// key == sticky and state = ALL
                        {
                            lst = contestDAO.fetchStickyContestList(((page - 1) * NoOfContestPerPage), NoOfContestPerPage);
                            totalRecord = contestDAO.countStickyArticle();
                            hpkShowAllState.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowAllState.Text + "(" + totalRecord + ")");
                            hpkShowBad.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_BAD) + ")";
                            hpkShowChecked.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_CHECKED) + ")";
                            hpkShowUncheck.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_UNCHECK) + ")";

                        }
                        else if (state == CommonConstants.STATE_UNCHECK.ToString())// key == sticky and state = UNCHECk
                        {
                            lst = contestDAO.fetchStickyContestList(CommonConstants.STATE_UNCHECK, ((page - 1) * NoOfContestPerPage), NoOfContestPerPage);
                            totalRecord = contestDAO.countStickyContestList(CommonConstants.STATE_UNCHECK);
                            hpkShowAllState.Text += "(" + contestDAO.countStickyArticle() + ")";
                            hpkShowUncheck.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowUncheck.Text + "(" + totalRecord + ")");
                            hpkShowChecked.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_CHECKED) + ")";
                            hpkShowBad.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_BAD) + ")";
                        }
                        else if (state == CommonConstants.STATE_CHECKED.ToString())// key = sticky and state = CHECKED
                        {
                            lst = contestDAO.fetchStickyContestList(CommonConstants.STATE_CHECKED, ((page - 1) * NoOfContestPerPage), NoOfContestPerPage);
                            totalRecord = contestDAO.countStickyContestList(CommonConstants.STATE_CHECKED);
                            hpkShowAllState.Text += "(" + contestDAO.countStickyArticle() + ")";
                            hpkShowBad.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_BAD) + ")";
                            hpkShowChecked.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowChecked.Text + "(" + totalRecord + ")");
                            hpkShowUncheck.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_UNCHECK) + ")";

                        }
                        else if (state == CommonConstants.STATE_BAD.ToString())// key = sticky and state = BAD
                        {
                            lst = contestDAO.fetchStickyContestList(CommonConstants.STATE_BAD, ((page - 1) * NoOfContestPerPage), NoOfContestPerPage);
                            totalRecord = contestDAO.countStickyContestList(CommonConstants.STATE_BAD);
                            hpkShowAllState.Text += "(" + contestDAO.countStickyArticle() + ")";
                            hpkShowUncheck.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_UNCHECK) + ")";
                            hpkShowChecked.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_CHECKED) + ")";
                            hpkShowBad.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowBad.Text + "(" + totalRecord + ")");

                        }
                    }
                    else //key != ALL
                    {
                        changeStateLink(key);
                        string sub = key;
                        if (BaseServices.isNullOrBlank(sub))
                        {
                            sub = CommonConstants.SUB_MATHEMATICS_CODE;
                        }

                        if (state == CommonConstants.ALL)//key != ALL and state = ALL
                        {
                            lst = contestDAO.fetchArticleList(sub.Trim(), (page - 1) * NoOfContestPerPage, NoOfContestPerPage);
                            totalRecord = contestDAO.countArticleBySubject(sub.Trim());

                            hpkShowUncheck.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_UNCHECK) + ")";
                            hpkShowChecked.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_CHECKED) + ")";
                            hpkShowBad.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_BAD) + ")";
                            string txt = hpkShowAllState.Text;
                            txt += "(" + totalRecord + ")";
                            hpkShowAllState.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt);
                        }
                        else if (state == CommonConstants.STATE_UNCHECK.ToString())//key != ALL and state = UNCHECK
                        {
                            lst = contestDAO.fetchArticleList(sub.Trim(), CommonConstants.STATE_UNCHECK, (page - 1) * NoOfContestPerPage, NoOfContestPerPage);
                            totalRecord = contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_UNCHECK);
                            hpkShowAllState.Text += "(" + contestDAO.countArticleBySubject(sub.Trim()) + ")";

                            hpkShowChecked.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_CHECKED) + ")";
                            hpkShowBad.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_BAD) + ")";
                            string txt = hpkShowUncheck.Text;
                            txt += "(" + totalRecord + ")";
                            hpkShowUncheck.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt);
                        }
                        else if (state == CommonConstants.STATE_CHECKED.ToString())//key != ALL and state = CHECKED
                        {
                            lst = contestDAO.fetchArticleList(sub.Trim(), CommonConstants.STATE_CHECKED, (page - 1) * NoOfContestPerPage, NoOfContestPerPage);
                            totalRecord = contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_CHECKED);
                            hpkShowAllState.Text += "(" + contestDAO.countArticleBySubject(sub.Trim()) + ")";
                            hpkShowUncheck.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_UNCHECK) + ")";
                            string txt = hpkShowChecked.Text;
                            txt += "(" + totalRecord + ")";
                            hpkShowChecked.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt);
                            hpkShowBad.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_BAD) + ")";
                        }
                        else if (state == CommonConstants.STATE_BAD.ToString())//key != ALL and state = BAD
                        {
                            lst = contestDAO.fetchArticleList(sub.Trim(), CommonConstants.STATE_BAD, (page - 1) * NoOfContestPerPage, NoOfContestPerPage);
                            totalRecord = contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_BAD);

                            hpkShowAllState.Text += "(" + contestDAO.countArticleBySubject(sub.Trim()) + ")";
                            hpkShowUncheck.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_UNCHECK) + ")";
                            hpkShowChecked.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_CHECKED) + ")";
                            string txt = hpkShowBad.Text;
                            txt += "(" + totalRecord + ")";
                            hpkShowBad.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt);
                        }
                        else
                        {

                        }

                    }
                    //show data
                    bool isOK = false;
                    if (lst != null)
                    {
                        if (lst.Count() > 0)
                        {
                            showContest(lst, totalRecord, page, action, key, state);
                            isOK = true;
                        }
                    }
                    if (!isOK)
                    {
                        showInfoMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND);
                        ContestTable.Visible = false;
                        return;
                    }
                }
                else if (action == CommonConstants.ACT_EDIT || action == CommonConstants.ACT_VIEW)
                {
                    if (Page.IsPostBack)
                    {
                        return;
                    }
                    initial();
                    viewPanel.Visible = false;
                    detailPanel.Visible = true;
                    messagePanel.Visible = false;
                    Session[CommonConstants.SES_OLD_PAGE] = Request.UrlReferrer.ToString();
                    int id = BaseServices.convertStringToInt(Request.QueryString[CommonConstants.REQ_ID]);
                    if (Request.QueryString[CommonConstants.REQ_ID] == null)
                    {
                        showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND);
                        return;
                    }
                    if (!BaseServices.isNumeric(Request.QueryString[CommonConstants.REQ_ID]))
                    {
                        showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND);
                        return;
                    }
                    int _id = Convert.ToInt32(Request.QueryString[CommonConstants.REQ_ID]);

                    viewPanel.Visible = false;
                    detailPanel.Visible = true;
                    messagePanel.Visible = false;

                    if (ddlState.Items.Count == 0)
                    {
                        showContestDetails(_id, action);
                    }

                    if (action == CommonConstants.ACT_VIEW)
                    {
                        btnEdit.Visible = false;
                    }

                }
                else if (action == CommonConstants.ACT_DELETE)
                {
                    if (Request.QueryString[CommonConstants.REQ_ID] == null)
                    {
                        showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND);
                        return;
                    }
                    if (!BaseServices.isNumeric(Request.QueryString[CommonConstants.REQ_ID]))
                    {
                        showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND);
                        return;
                    }

                    int id = BaseServices.convertStringToInt(Request.QueryString[CommonConstants.REQ_ID]);
                    bool isMatch = contestDAO.isState(id, CommonConstants.STATE_UNCHECK);
                    if (contestDAO.setDeleteFlag(id, user.Username))
                    {
                        if (isMatch)
                        {
                            ltktDAO.Statistics statDAO = new ltktDAO.Statistics();
                            statDAO.add(CommonConstants.SF_NUM_ARTICLE_ON_UNI, CommonConstants.CONST_ONE_NEGATIVE);
                        }
                        string mess = BaseServices.createMsgByTemplate(CommonConstants.MSG_I_ACTION_SUCCESSFUL, CommonConstants.ACT_DELETE);

                        //ltktDAO.Alert.Show(mess);
                        isDeleted = true;
                        Session[CommonConstants.SES_INFORM] = BaseServices.createMsgByTemplate(CommonConstants.MSG_I_ACTION_SUCCESSFUL, CommonConstants.ACT_DELETE);
                    }
                    else
                    {
                        Session[CommonConstants.SES_INFORM] = BaseServices.createMsgByTemplate(CommonConstants.MSG_E_ACTION_FAILED, CommonConstants.ACT_DELETE);
                    }

                }
            }
            catch (Exception ex)
            {
                log.writeLog(DBHelper.strPathLogFile, user.Username, CommonConstants.MSG_E_LINK_INVALID);
                log.writeLog(DBHelper.strPathLogFile, user.Username, ex.Message
                                                        + CommonConstants.NEWLINE
                                                        + ex.Source
                                                        + CommonConstants.NEWLINE
                                                        + ex.StackTrace
                                                        + CommonConstants.NEWLINE
                                                        + ex.HelpLink);

                Response.Redirect(CommonConstants.PAGE_ADMIN_INFORMATICS
                                              + CommonConstants.ADD_PARAMETER
                                              + CommonConstants.REQ_PAGE
                                              + CommonConstants.EQUAL
                                              + CommonConstants.PAGE_NUMBER_FIRST);
            }
            if (isDeleted)
            {
                Response.Redirect(CommonConstants.PAGE_ADMIN_UNIVERSITY);
            }
        }
 partial void InserttblUser(tblUser instance);
Exemple #8
0
        /// <summary>
        /// Đăng ký user mới
        /// </summary>
        /// <param name="_username"></param>
        /// <param name="_displayName"></param>
        /// <param name="_email"></param>
        /// <param name="_sex"></param>
        /// <param name="_password"></param>
        /// <returns></returns>
        public Boolean register(string _username,
            string _displayName,
            string _email,
            Boolean _sex,
            string _password)
        {
            LTDHDataContext DB = new LTDHDataContext(@strPathDB);

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    tblUser user = new tblUser();
                    Permission permitDAO = new Permission();

                    user.Username = _username;
                    user.DisplayName = _displayName;
                    user.Sex = _sex;
                    user.Email = _email;
                    user.Password = encryptPassword(_password);
                    user.Note = "Password: " + _password;

                    user.Type = true;
                    user.Permission = permitDAO.getValue(CommonConstants.P_N_GENERAL).ToString();
                    user.RegisterDate = DateTime.Today;
                    user.NumberOfArticles = 0;
                    user.State = CommonConstants.STATE_NON_ACTIVE;

                    DB.tblUsers.InsertOnSubmit(user);
                    DB.SubmitChanges();
                    ts.Complete();

                    log.writeLog(DBHelper.strPathLogFile, CommonConstants.USER_GUEST,
                                  BaseServices.createMsgByTemplate(CommonConstants.SQL_INSERT_SUCCESSFUL_TEMPLATE,
                                                                    _username,
                                                                    CommonConstants.SQL_TABLE_USER));
                }
            }
            catch (Exception e)
            {
                log.writeLog(DBHelper.strPathLogFile, CommonConstants.USER_GUEST,
                                  BaseServices.createMsgByTemplate(CommonConstants.SQL_INSERT_FAILED_TEMPLATE,
                                                                    _username,
                                                                    CommonConstants.SQL_TABLE_USER));

                log.writeLog(DBHelper.strPathLogFile, CommonConstants.USER_GUEST, e.Message);

                return false;
            }

            return true;
        }
Exemple #9
0
        /// <summary>
        /// Thêm một user mới
        /// </summary>
        /// <param name="record"></param>
        /// <returns></returns>
        public Boolean insertUser(tblUser record)
        {
            LTDHDataContext DB = new LTDHDataContext(strPathDB);

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    DB.tblUsers.InsertOnSubmit(record);

                    DB.SubmitChanges();

                    ts.Complete();
                }
            }
            catch (Exception e)
            {
                return false;
            }
            return true;
        }
Exemple #10
0
        /// <summary>
        /// Cập nhật user
        /// </summary>
        /// <param name="_username"></param>
        /// <param name="update"></param>
        /// <returns></returns>
        public Boolean updateUser(string _username, tblUser update)
        {
            //LTDHDataContext DB = new LTDHDataContext(@strPathDB);
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    var user = DB.tblUsers.Single(u => u.Username == _username);

                    user.Password = update.Password;
                    user.DisplayName = update.DisplayName;
                    user.Email = update.Email;
                    user.Type = update.Type;
                    user.Role = update.Role;
                    user.Permission = update.Permission;
                    user.State = update.State;
                    user.RegisterDate = update.RegisterDate;
                    user.NumberOfArticles = update.NumberOfArticles;
                    user.Note = update.Note;

                    DB.SubmitChanges();
                    ts.Complete();
                }
            }
            catch (Exception e)
            {
                return false;
            }
            return true;
        }
 public void updateAccount(tblUser _user)
 {
     Session[CommonConstants.SES_USER] = _user;
     loginUser.Text = _user.DisplayName;
     userStateTitle.Text = CommonConstants.TXT_ACCOUNT_INFOR;
     loginPanel.Visible = false;
     HpkUpload.Visible = true;
     userPanel.Visible = true;
     if (_user.Type == false)
     {
         HpkAdmin.Visible = true;
         HpkContact.Visible = false;
     }
     statisticDAO.addLatestLoginUser(_user.Username);
 }
        private void checkUserState(tblUser user)
        {
            switch (user.State)
            {
                case CommonConstants.STATE_NON_ACTIVE: //Tài khoản chưa kích hoạt
                    {
                        // Thông báo là tài khoản chưa kích hoạt.

                        //Response.Redirect("~/Login.aspx?state=non-active");

                        break;
                    }
                case CommonConstants.STATE_ACTIVE: // Tài khoản đã kích hoạt, đăng nhập ok
                case CommonConstants.STATE_WARNING: // Bị báo xấu, đăng nhập ok
                    {
                        updateAccount(user);
                        break;
                    }
                case CommonConstants.STATE_KIA_3D: // KIA 3 ngày
                case CommonConstants.STATE_KIA_1W: // KIA 1 tuần
                case CommonConstants.STATE_KIA_2W: // KIA 2 tuần
                case CommonConstants.STATE_KIA_3W: // KIA 3 tuần
                case CommonConstants.STATE_KIA_1M: // KIA 1 tháng
                    {
                        // Kiểm tra ngày KIA

                        // Kiểm tra xem hết chưa. nếu hết thì mở khóa

                        break;
                    }

            }
        }