Esempio n. 1
0
        protected void btn_add_Click(object sender, EventArgs e)
        {
            ETO.Admin admin = ReceiveHtml();
            try
            {
                AdminBSO adminBSO = new AdminBSO();
                if (adminBSO.CheckExist(admin.AdminName))
                {
                    error.Text = String.Format(Resources.StringAdmin.CheckExist, admin.AdminName);
                }
                else
                    if (adminBSO.CheckExistEmail(admin.AdminEmail))
                    {
                        error.Text = "<font color = 'red'>Địa chỉ Email đã được đăng ký. Vui lòng đăng ký lại</font>";
                    }
                    else
                    {
                        if (CheckedList().Equals(""))
                        {
                            error.Text = "Loi : Xin hay lua chon it nhat 1 quyen";
                        }
                        else
                        {
                            adminBSO.CreateAdmin(admin);

                            RolesBSO rolesBSO = new RolesBSO();
                            IRoles roles = rolesBSO.GetRolesByName("Guest");
                            AdminRolesBSO adminRolesBSO = new AdminRolesBSO();
                            AdminRoles adminRoles = new AdminRoles();

                            adminRoles.AdminUserName = admin.AdminName;
                            adminRoles.RolesID = roles.RolesID;
                            adminRoles.UserName = Session["Admin_UserName"].ToString();
                            adminRoles.Permission = "";
                            adminRoles.Created = DateTime.Now;
                            adminRolesBSO.CreateAdminRoles(adminRoles);

                            error.Text = String.Format(Resources.StringAdmin.AddNewsSuccessful);
                        }
                    }
            }
            catch (Exception ex)
            {
                error.Text = ex.Message.ToString();
            }
        }
        private void bindingContentQuestion(int parentID, string RolesName_)
        {
            ListQuestionBSO listQuestionBSO = new ListQuestionBSO();
            DataTable dt = new DataTable();
            dt = listQuestionBSO.listParentQuestionByID(parentID);

            DataView view1 = new DataView(dt);

            string strCate = GetCateParentIDArrayByID();
            ////-------------------Lay nhom Role
            AdminBSO adminBSO = new AdminBSO();
            if (RolesName_ == "Guest")
            {
                view1.RowFilter = "CreateUserName ='******'";
            }
            else
                if (!string.IsNullOrEmpty(strCate))
                {
                    string restr = strCate.Remove(strCate.LastIndexOf(",")).Replace(",", "','");
                    //view1.RowFilter = "CateNewsID in('" + restr + "')";
                    view1.RowFilter = "CateNewsID in('" + restr + "') or CreateUserName ='******'";
                }

            ETO.Admin userPostQuestion = new ETO.Admin();
            if (adminBSO.CheckExist(view1[0]["CreateUserName"].ToString()))
            {
                userPostQuestion = adminBSO.GetAdminById(view1[0]["CreateUserName"].ToString());
                lbContentQuestion.Text = view1[0]["Question_Content"].ToString();
                lbDatePostQuestion.Text = " gửi ngày: " + view1[0]["CreateDate"].ToString();
                lbQuestionTitle.Text = "Tiêu đề: <b>" + view1[0]["Question_Title"].ToString() + "</b>";
                lbUserPost.Text = "Người gửi: <b>" + userPostQuestion.AdminFullName.ToString() + "</b>, ";
                if (!string.IsNullOrEmpty(view1[0]["Question_Image"].ToString()))
                {
                    string strImgName = view1[0]["Question_Image"].ToString();
                    Literal_images.Text = "<span style='display: block;'>Hình đính kèm:</span>";
                    Literal_images.Text = "<a href='" + ResolveUrl("~/") + "Upload/Question/Images/" + strImgName + "' rel='lightbox' ><img src='" + ResolveUrl("~/") + "Upload/Question/Images/" + strImgName + "' class='image_album' width='120' align='left'  hspace='1' /></a>";
                }
                if (!string.IsNullOrEmpty(view1[0]["Question_fileAttach"].ToString()))
                {
                    string strFileAttch = view1[0]["Question_fileAttach"].ToString();
                    Literal_file.Text = "<span style='display: block;'>Tệp tin đính kèm:</span>";
                    Literal_file.Text += "<a href='" + ResolveUrl("~/") + "Upload/Question/Files/" + strFileAttch + "'  ><img src='" + ResolveUrl("~/") + "Images/icon_file.png' class='icon' width='30' hspace='1' /> Tải tệp tin đính kèm </a>";
                }
            }
            else
            {
                lbContentQuestion.Text = "";
                lbDatePostQuestion.Text = "";
                lbQuestionTitle.Text = "";
                lbUserPost.Text = "Người gửi câu hỏi không tồn tại!";

            }


        }