Beispiel #1
0
        private void LoadCounter()
        {
            try
            {
                InstituteBLL instituteBLL = new InstituteBLL();
                DataTable    dtInstitute  = instituteBLL.GetAllActive();
                lblTotalUniversity.Text = Convert.ToString(dtInstitute.Rows.Count);

                LenderBankBLL lenderBankBLL = new LenderBankBLL();
                DataTable     dtLenderBank  = lenderBankBLL.GetAllActive();
                lblTotalBank.Text = Convert.ToString(dtLenderBank.Rows.Count);

                CourseBLL courseBLL = new CourseBLL();
                DataTable dtCourse  = courseBLL.GetAllActive();
                lblTotalCourse.Text = Convert.ToString(dtCourse.Rows.Count);

                BlogPostBLL blogPostBLL = new BlogPostBLL();
                DataTable   dtBlogPost  = blogPostBLL.GetAllActive();
                lblTotalBlogPost.Text = Convert.ToString(dtBlogPost.Rows.Count);

                UserBLL   userBLL = new UserBLL();
                DataTable dtUser  = userBLL.GetAllActiveMember();
                lblTotalMember.Text = Convert.ToString(dtUser.Rows.Count);
            }
            catch (Exception)
            {
                //throw;
            }
        }
Beispiel #2
0
 protected void btnDelete_Command(object sender, CommandEventArgs e)
 {
     try
     {
         string id = Convert.ToString(e.CommandArgument);
         if (!string.IsNullOrEmpty(id))
         {
             BlogPostBLL blogPostBLL = new BlogPostBLL();
             BlogPosts   blogPost    = new BlogPosts();
             blogPost.BlogPostId = Convert.ToInt32(QuaintSecurityManager.Decrypt(id));
             if (blogPost.BlogPostId > 0)
             {
                 if (blogPostBLL.Delete(blogPost))
                 {
                     Alert(AlertType.Success, "Deleted successfully.");
                     LoadList();
                 }
                 else
                 {
                     Alert(AlertType.Error, "Failed to delete.");
                 }
             }
         }
     }
     catch (Exception)
     {
         Alert(AlertType.Error, "Failed to delete.");
     }
 }
Beispiel #3
0
        private void LoadData(string slug)
        {
            try
            {
                BlogPostBLL blogPostBLL = new BlogPostBLL();
                DataTable   dt          = blogPostBLL.GetByBlogPostSlug(slug);

                txtTitle.InnerText           = Convert.ToString(dt.Rows[0]["Title"]);
                txtPublishedDate.Text        = Convert.ToDateTime(Convert.ToString(dt.Rows[0]["PublishedDate"])).ToString("dd MMMM yyyy");
                txtBlogPostCategoryName.Text = Convert.ToString(dt.Rows[0]["BlogPostCategoryName"]);
                txtDescription.InnerHtml     = Convert.ToString(dt.Rows[0]["Description"]);
                if (!string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["Attachment"])))
                {
                    string currentUrl  = HttpContext.Current.Request.Url.AbsoluteUri;
                    string redirectUrl = "~/Login.aspx?Ref=member&Redirect=" + QuaintSecurityManager.EncryptUrl(currentUrl);
                    lnkLogin.NavigateUrl   = redirectUrl;
                    txtAttachmentView.Text = Convert.ToString(dt.Rows[0]["Title"]);

                    txtAttachment.Text          = Convert.ToString(dt.Rows[0]["Title"]);
                    lnkDownload.CommandArgument = QuaintSAMS.Code.Global.FilePath.BlogPost + Convert.ToString(dt.Rows[0]["Attachment"]);

                    attachmentDownload.Visible = false;
                    attachmentView.Visible     = true;
                }
            }
            catch (Exception)
            {
                //throw;
            }
        }
 private void Edit(int id)
 {
     try
     {
         BlogPostBLL blogPostBLL = new BlogPostBLL();
         DataTable   dt          = blogPostBLL.GetById(id);
         if (dt != null)
         {
             if (dt.Rows.Count > 0)
             {
                 this.ModelId                      = Convert.ToInt32(Convert.ToString(dt.Rows[0]["BlogPostId"]));
                 this.ModelCode                    = Convert.ToString(dt.Rows[0]["BlogPostCode"]);
                 txtTitle.Text                     = Convert.ToString(dt.Rows[0]["Title"]);
                 this.ModelSlag                    = Convert.ToString(dt.Rows[0]["Slag"]);
                 txtDescription.Text               = Convert.ToString(dt.Rows[0]["Description"]);
                 txtPublishedDate.Text             = Convert.ToDateTime(Convert.ToString(dt.Rows[0]["PublishedDate"])).ToString("MM/dd/yyyy");
                 this.ModelAttachment              = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["Attachment"]))) ? string.Empty : Convert.ToString(dt.Rows[0]["Attachment"]);
                 ddlBlogPostCategory.SelectedValue = Convert.ToString(dt.Rows[0]["BlogPostCategoryId"]);
             }
         }
     }
     catch (Exception)
     {
         Alert(AlertType.Error, "Failed to edit.");
     }
 }
Beispiel #5
0
 private void LoadList()
 {
     try
     {
         BlogPostBLL blogPostBLL = new BlogPostBLL();
         DataTable   dt          = blogPostBLL.GetAll();
         rptrList.DataSource = dt;
         rptrList.DataBind();
     }
     catch (Exception)
     {
         //throw;
     }
 }
Beispiel #6
0
        private void LoadBlogPost()
        {
            try
            {
                BlogPostBLL blogPostBLL = new BlogPostBLL();
                DataTable   dt          = blogPostBLL.GetFromLastActive(2);

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        rptrPost.DataSource = dt;
                        rptrPost.DataBind();
                    }
                }
            }
            catch (Exception)
            {
                //throw;
            }
        }
Beispiel #7
0
        private void LoadBlogPost(string slug)
        {
            try
            {
                BlogPostBLL blogPostBLL = new BlogPostBLL();
                DataTable   dt          = blogPostBLL.GetByBlogPostCategorySlug(slug);

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        rptrPost.DataSource = dt;
                        rptrPost.DataBind();
                    }
                }
            }
            catch (Exception)
            {
                //throw;
            }
        }
 private void GenerateCode()
 {
     try
     {
         QuaintLibraryManager lib = new QuaintLibraryManager();
         this.ModelCode = CodePrefix.BlogPost + "-" + lib.GetSixDigitNumber(1);
         BlogPostBLL blogPostBLL = new BlogPostBLL();
         DataTable   dt          = blogPostBLL.GetAll();
         if (dt != null)
         {
             if (dt.Rows.Count > 0)
             {
                 string[] lastCode       = dt.Rows[dt.Rows.Count - 1]["BlogPostCode"].ToString().Split('-');
                 int      lastCodeNumber = Convert.ToInt32(lastCode[1]);
                 this.ModelCode = CodePrefix.BlogPost + "-" + lib.GetSixDigitNumber(lastCodeNumber + 1);
             }
         }
     }
     catch (Exception)
     {
         Alert(AlertType.Error, "Failed to load.");
     }
 }
Beispiel #9
0
        private void LoadDashboardInfo()
        {
            try
            {
                //Total Member
                UserBLL   userBLL = new UserBLL();
                DataTable dtUser  = userBLL.GetAllActive();
                lblTotalMember.Text = (dtUser == null) ? "0" : Convert.ToString(Convert.ToInt32(dtUser.Rows.Count));

                //Total University
                //InstituteBLL instituteBLL = new InstituteBLL();
                //DataTable dtInstitute = instituteBLL.GetAllActive();
                RankingBLL rankingBLL = new RankingBLL();
                DataTable  dtRanking  = rankingBLL.GetAllActive();
                lblTotalUniversity.Text = (dtRanking == null) ? "0" : Convert.ToString(dtRanking.Rows.Count);

                //Total Course
                CourseBLL courseBLL = new CourseBLL();
                DataTable dtCourse  = courseBLL.GetAllActive();
                lblTotalCourse.Text = (dtCourse == null) ? "0" : Convert.ToString(dtCourse.Rows.Count);

                //Total Bank
                LenderBankBLL lenderBankBLL = new LenderBankBLL();
                DataTable     dtLenderBank  = lenderBankBLL.GetAllActive();
                lblTotalBank.Text = (dtLenderBank == null) ? "0" : Convert.ToString(dtLenderBank.Rows.Count);

                //Total Blog Post
                BlogPostBLL blogPostBLL = new BlogPostBLL();
                DataTable   dtBlogPost  = blogPostBLL.GetAllActive();
                lblTotalBlogPost.Text = (dtBlogPost == null) ? "0" : Convert.ToString(dtBlogPost.Rows.Count);
            }
            catch (Exception)
            {
                //throw;
            }
        }
Beispiel #10
0
        protected void btnActiveOrDeactive_Command(object sender, CommandEventArgs e)
        {
            try
            {
                string id = Convert.ToString(e.CommandArgument);
                if (!string.IsNullOrEmpty(id))
                {
                    BlogPostBLL blogPostBLL = new BlogPostBLL();
                    DataTable   dt          = blogPostBLL.GetById(Convert.ToInt32(QuaintSecurityManager.Decrypt(id)));
                    if (dt != null)
                    {
                        if (dt.Rows.Count > 0)
                        {
                            string    actionStatus = "Updated";
                            BlogPosts blogPost     = new BlogPosts();
                            blogPost.BlogPostId         = Convert.ToInt32(Convert.ToString(dt.Rows[0]["BlogPostId"]));
                            blogPost.BlogPostCode       = Convert.ToString(dt.Rows[0]["BlogPostCode"]);
                            blogPost.Title              = Convert.ToString(dt.Rows[0]["Title"]);
                            blogPost.Slag               = Convert.ToString(dt.Rows[0]["Slag"]);
                            blogPost.Description        = Convert.ToString(dt.Rows[0]["Description"]);
                            blogPost.PublishedDate      = Convert.ToDateTime(Convert.ToString(dt.Rows[0]["PublishedDate"]));
                            blogPost.Attachment         = Convert.ToString(dt.Rows[0]["Attachment"]);
                            blogPost.IsActive           = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"]));
                            blogPost.BlogPostCategoryId = Convert.ToInt32(Convert.ToString(dt.Rows[0]["BlogPostCategoryId"]));
                            blogPost.CreatedDate        = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"]));
                            blogPost.CreatedBy          = Convert.ToString(dt.Rows[0]["CreatedBy"]);
                            blogPost.CreatedFrom        = Convert.ToString(dt.Rows[0]["CreatedFrom"]);

                            blogPost.UpdatedDate = DateTime.Now;
                            blogPost.UpdatedBy   = UserInfo;
                            blogPost.UpdatedFrom = StationInfo;

                            if (blogPost.IsActive)
                            {
                                blogPost.IsActive = false;
                                actionStatus      = "Deactivated";
                            }
                            else
                            {
                                blogPost.IsActive = true;
                                actionStatus      = "Activated";
                            }

                            if (blogPostBLL.Update(blogPost))
                            {
                                Alert(AlertType.Success, actionStatus + " successfully.");
                                LoadList();
                            }
                            else
                            {
                                Alert(AlertType.Error, "Failed to update.");
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                Alert(AlertType.Error, "Failed to process.");
            }
        }
        private void SaveAndUpdate()
        {
            try
            {
                if (string.IsNullOrEmpty(txtTitle.Text))
                {
                    Alert(AlertType.Warning, "Enter title.");
                    txtTitle.Focus();
                }
                else if (ddlBlogPostCategory.SelectedIndex < 1)
                {
                    Alert(AlertType.Warning, "Select blog post category.");
                    ddlBlogPostCategory.Focus();
                }
                else if (string.IsNullOrEmpty(txtPublishedDate.Text))
                {
                    Alert(AlertType.Warning, "Select published date.");
                    txtPublishedDate.Focus();
                }
                else
                {
                    QuaintLibraryManager lib    = new QuaintLibraryManager();
                    string   title              = Convert.ToString(txtTitle.Text);
                    string   slag               = lib.ConvertToSlug(title);
                    int      blogPostCategoryId = Convert.ToInt32(ddlBlogPostCategory.SelectedValue);
                    DateTime publishedDate      = Convert.ToDateTime(txtPublishedDate.Text);
                    string   description        = Convert.ToString(txtDescription.Text);
                    string   attachment         = string.Empty;
                    if (fuAttachment.HasFile)
                    {
                        attachment = UploadAttachment();
                    }
                    else
                    {
                        attachment = this.ModelAttachment;
                    }

                    BlogPostBLL blogPostBLL = new BlogPostBLL();
                    if (this.ModelId > 0)
                    {
                        DataTable dt       = blogPostBLL.GetById(this.ModelId);
                        BlogPosts blogPost = new BlogPosts();
                        blogPost.BlogPostId         = Convert.ToInt32(Convert.ToString(dt.Rows[0]["BlogPostId"]));
                        blogPost.BlogPostCode       = Convert.ToString(dt.Rows[0]["BlogPostCode"]);
                        blogPost.Title              = Convert.ToString(dt.Rows[0]["Title"]);
                        blogPost.Slag               = Convert.ToString(dt.Rows[0]["Slag"]);
                        blogPost.Description        = Convert.ToString(dt.Rows[0]["Description"]);
                        blogPost.PublishedDate      = Convert.ToDateTime(Convert.ToString(dt.Rows[0]["PublishedDate"]));
                        blogPost.Attachment         = Convert.ToString(dt.Rows[0]["Attachment"]);
                        blogPost.IsActive           = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"]));
                        blogPost.BlogPostCategoryId = Convert.ToInt32(Convert.ToString(dt.Rows[0]["BlogPostCategoryId"]));
                        blogPost.CreatedDate        = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"]));
                        blogPost.CreatedBy          = Convert.ToString(dt.Rows[0]["CreatedBy"]);
                        blogPost.CreatedFrom        = Convert.ToString(dt.Rows[0]["CreatedFrom"]);

                        blogPost.Title              = title.Trim();
                        blogPost.Slag               = slag;
                        blogPost.Description        = description;
                        blogPost.PublishedDate      = publishedDate;
                        blogPost.Attachment         = attachment;
                        blogPost.BlogPostCategoryId = blogPostCategoryId;

                        blogPost.UpdatedDate = DateTime.Now;
                        blogPost.UpdatedBy   = this.UserInfo;
                        blogPost.UpdatedFrom = this.StationInfo;

                        if (blogPostBLL.Update(blogPost))
                        {
                            this.MultiEntryDisallow = true;
                            Alert(AlertType.Success, "Updated successfully.");
                            ClearFields();
                        }
                        else
                        {
                            Alert(AlertType.Error, "Failed to update.");
                        }
                    }
                    else
                    {
                        BlogPosts blogPost = new BlogPosts();
                        blogPost.BlogPostCode       = this.ModelCode;
                        blogPost.Title              = title;
                        blogPost.Slag               = slag;
                        blogPost.BlogPostCategoryId = blogPostCategoryId;
                        blogPost.Attachment         = attachment;
                        blogPost.PublishedDate      = publishedDate;
                        blogPost.Description        = description;
                        blogPost.IsActive           = true;
                        blogPost.CreatedDate        = DateTime.Now;
                        blogPost.CreatedBy          = this.UserInfo;
                        blogPost.CreatedFrom        = this.StationInfo;

                        if (blogPostBLL.Save(blogPost))
                        {
                            Alert(AlertType.Success, "Saved successfully.");
                            ClearFields();
                            GenerateCode();
                        }
                        else
                        {
                            Alert(AlertType.Error, "Failed to save.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Alert(AlertType.Error, ex.Message.ToString());
            }
        }