private ListQuestion ReceiveHtml_()
        {
            ConfigBSO configBSO = new ConfigBSO();
            Config config = configBSO.GetAllConfig(Language.language);
            int thumb_w = Convert.ToInt32(config.New_large_w);
            int thumb_h = Convert.ToInt32(config.New_large_h);

            commonBSO commonBSO = new commonBSO();
            string path_thumb = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/Question/Images/";
            string image_thumb = commonBSO.UploadImage(image_Attach, path_thumb, thumb_w, thumb_h);

            string path = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/Question/Files/";
            string file_upload = commonBSO.UploadFile(file_Attach, path, 18000000000);

            ListQuestion listQuestion = new ListQuestion();

            //Cau hoi moi
            listQuestion.CateNewsID = Convert.ToInt32(ddlCateNews.SelectedValue);
            listQuestion.Question_Title = txtTitle.Text.Trim();
            listQuestion.Question_Content = txtRadShort.Html;
            listQuestion.CreateUserName = Session["Admin_UserName"].ToString();
            listQuestion.Question_FileAttach = (file_upload != "") ? file_upload : HiddenField_FileAttach.Value;
            listQuestion.Question_Image = (image_thumb != "") ? image_thumb : HiddenField_ImageAttach.Value;
            listQuestion.CreateDate = DateTime.Now;
            listQuestion.IsApproval = false; //Chua duoc duyet
            listQuestion.ApprovalUserName = "";
            listQuestion.QuestionStatus = 0;
            listQuestion.ApprovalDate = DateTime.Now;

            if (Page.RouteData.Values["Id"] != null)
            {
                listQuestion.Question_ID = Convert.ToInt32(HiddenField_QuestionID.Value);
                listQuestion.QuestionStatus = int.Parse(HiddenField_QuestionStatus.Value);
                listQuestion.CreateDate = DateTime.Parse(HiddenField_CreateDate.Value);
                listQuestion.CreateUserName = HiddenField_CreateUserName.Value;
            }

            return listQuestion;
        }
        private NewsGroup ReceiveHtml()
        {
            ConfigBSO configBSO = new ConfigBSO();
            Config config = configBSO.GetAllConfig(Language.language);
            int thumb_w = Convert.ToInt32(config.New_thumb_w);
            int thumb_h = Convert.ToInt32(config.New_thumb_h);

            commonBSO commonBSO = new commonBSO();
            string path_thumb = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/NewsGroup/NewsGroupThumb/";
            string image_thumb = commonBSO.UploadImage(file_image_thumb, path_thumb, thumb_w, thumb_h);

            int large_w = Convert.ToInt32(config.New_large_w);
            int large_h = Convert.ToInt32(config.New_large_h);
            string path_large = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/NewsGroup/NewsGroupLarge/";
            string image_large = commonBSO.UploadImage(file_image_thumb, path_large, large_w, large_h);

            string path = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/NewsGroup/Files/";
            string file_upload = commonBSO.UploadFile(file_attached, path, 1800000000000);

            NewsGroup newsgroup = new NewsGroup();
            newsgroup.NewsGroupID = (hddNewsGroupID.Value != "") ? Convert.ToInt32(hddNewsGroupID.Value) : 0;
            newsgroup.CateNewsID = Convert.ToInt32(ddlCateNews.SelectedValue);
            newsgroup.ParentNewsID = (hddParentNewsID.Value != "") ? Convert.ToInt32(hddParentNewsID.Value) : 0;
            //newsgroup.GroupCate = Convert.ToInt32(hddGroup.Value);
            newsgroup.GroupCate = Convert.ToInt32(ddlCateNewsGroup.SelectedValue);

            newsgroup.Title = txtTitle.Text;
            newsgroup.ShortDescribe = txtRadShort.Html;
            newsgroup.FullDescribe = txtRadFull.Html;
            newsgroup.ImageThumb = (image_thumb != "") ? image_thumb : hddImageThumb.Value;
            newsgroup.ImageLarge = (image_large != "") ? image_large : hddImageLarge.Value;
            newsgroup.FileName = (file_upload != "") ? file_upload : hddFileName.Value;

            newsgroup.Author = txtAuthor.Text;
            newsgroup.PostDate = txtRadDate.SelectedDate.Value;
            newsgroup.RelationTotal = (hddRelationTotal.Value != "") ? Convert.ToInt32(hddRelationTotal.Value) : 0;
            newsgroup.Status = Convert.ToBoolean(rdbStatus.SelectedItem.Value);
            newsgroup.Language = Language.language;
            newsgroup.Ishot = Convert.ToBoolean(rdbIshot.SelectedValue);
            newsgroup.Ishome = Convert.ToBoolean(rdbIshome.SelectedValue);

            newsgroup.TypeNews = Convert.ToBoolean(rdbTypeNews.SelectedValue);

            newsgroup.IsComment = Convert.ToBoolean(rdbComment.SelectedValue);

            newsgroup.Isview = (hddIsView.Value != "") ? Convert.ToInt32(hddIsView.Value) : 0;
            newsgroup.CommentTotal = (hddCommentTotal.Value != "") ? Convert.ToInt32(hddCommentTotal.Value) : 0;

            newsgroup.CreatedUserName = (hddCreateUserName.Value != "") ? hddCreateUserName.Value : Session["Admin_UserName"].ToString();



            newsgroup.IsApproval = Convert.ToBoolean(rdbApproval.SelectedValue);
            if (hddApprovalUserName.Value != "")
            {
                newsgroup.ApprovalUserName = hddApprovalUserName.Value;
                newsgroup.ApprovalDate = Convert.ToDateTime(hddApprovalDate.Value);
            }
            else
                if (Convert.ToBoolean(rdbApproval.SelectedValue))
                {
                    newsgroup.ApprovalUserName = Session["Admin_UserName"].ToString();
                    newsgroup.ApprovalDate = DateTime.Now;
                }
                else
                {
                    newsgroup.ApprovalUserName = "";
                    newsgroup.ApprovalDate = DateTime.Now;
                }


            return newsgroup;

        }
        private Download ReceiveHtml()
        {
            ConfigBSO configBSO = new ConfigBSO();
            Config config = configBSO.GetAllConfig(Language.language);
            int thumb_w = Convert.ToInt32(config.New_large_w);
            int thumb_h = Convert.ToInt32(config.New_large_h);

            commonBSO commonBSO = new commonBSO();
            string path_thumb = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/Download/DownloadThumb/";
            string image_thumb = commonBSO.UploadImage(file_image_thumb, path_thumb, thumb_w, thumb_h);

            string path = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/Download/Files/";
            string file_upload = commonBSO.UploadFile(file_attached, path, 18000000000000);


            Download download = new Download();
            download.DownloadID = (hddDownloadID.Value != "") ? Convert.ToInt32(hddDownloadID.Value) : 0;
            download.CateDownloadID = Convert.ToInt32(ddlCateDownload.SelectedValue);
            download.Title = txtTitle.Text;
            download.ShortDescribe = txtRadShort.Html;
            download.FullDescribe = txtRadFull.Html;
            download.ImageThumb = (image_thumb != "") ? image_thumb : hddImageThumb.Value;
            download.FileName = (file_upload != "") ? file_upload : hddFileName.Value;
            download.Author = txtAuthor.Text;
            download.PostDate = txtRadDate.SelectedDate.Value;
            download.RelationTotal = (hddRelationTotal.Value != "") ? Convert.ToInt32(hddRelationTotal.Value) : 0;
            download.Status = Convert.ToBoolean(rdbStatus.SelectedItem.Value);
            download.Language = Language.language;
            download.Ishot = Convert.ToBoolean(rdbIshot.SelectedValue);
            download.Ishome = Convert.ToBoolean(rdbIshome.SelectedValue);
            download.IsComment = Convert.ToBoolean(rdbComment.SelectedValue);

            download.Isview = (hddIsView.Value != "") ? Convert.ToInt32(hddIsView.Value) : 0;
            download.CommentTotal = (hddCommentTotal.Value != "") ? Convert.ToInt32(hddCommentTotal.Value) : 0;

            download.CreatedUserName = (hddCreateUserName.Value != "") ? hddCreateUserName.Value : Session["Admin_UserName"].ToString();

            download.IsApproval = Convert.ToBoolean(rdbApproval.SelectedValue);
            if (hddApprovalUserName.Value != "")
            {
                download.ApprovalUserName = hddApprovalUserName.Value;
                download.ApprovalDate = Convert.ToDateTime(hddApprovalDate.Value);
            }
            else
                if (Convert.ToBoolean(rdbApproval.SelectedValue))
                {
                    download.ApprovalUserName = Session["Admin_UserName"].ToString();
                    download.ApprovalDate = DateTime.Now;
                }
                else
                {
                    download.ApprovalUserName = "";
                    download.ApprovalDate = DateTime.Now;
                }


            return download;

        }
        private OfficialFile ReceiveHtml()
        {


            string path = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/Official/Files/";
            commonBSO commonBSO = new commonBSO();
            string file_upload = commonBSO.UploadFile(file_attached, path, 180000000000);


            OfficialFile officialFile = new OfficialFile();


            officialFile.OfficialFileID = (hddOfficialFileID.Value != "") ? Convert.ToInt32(hddOfficialFileID.Value) : 0;
            officialFile.OfficialID = Convert.ToInt32(hddOfficialID.Value);
            officialFile.Title = txtTitle.Text;
            officialFile.FileName = (file_upload != "") ? file_upload : hddFileName.Value;


            return officialFile;
        }
        protected void btnSend_Click(object sender, EventArgs e)
        {

            if (!string.IsNullOrEmpty(Page.RouteData.Values["subid"].ToString())) //Update record
            {
                ListQuestionBSO listQuestionBSO = new ListQuestionBSO();
                if (!string.IsNullOrEmpty(txtRadShort.Html))
                {
                    ConfigBSO configBSO = new ConfigBSO();
                    Config config = configBSO.GetAllConfig(Language.language);
                    int thumb_w = Convert.ToInt32(config.New_thumb_w);
                    int thumb_h = Convert.ToInt32(config.New_thumb_h);
                    ListQuestion listQuestionUpdate = new ListQuestion();

                    commonBSO commonBSO = new commonBSO();
                    string path_thumb = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/Question/Images/";
                    string image_thumb = commonBSO.UploadImage(image_Attach, path_thumb, thumb_w, thumb_h);

                    string path = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/Question/Files/";
                    string file_upload = commonBSO.UploadFile(file_Attach, path, 18000000000);
                    string strFile = (file_upload != "") ? file_upload : HiddenField_FileAttach.Value;
                    string strImage = (image_thumb != "") ? image_thumb : HiddenField_ImageAttach.Value;

                    listQuestionBSO.UpdateSubQuestion(Convert.ToInt32(Page.RouteData.Values["subid"]), txtRadShort.Html, strImage, strFile);
                    txtRadShort.Html = "";
                    //clientview.Text = strFile;
                }
                clientview.Text = String.Format(Resources.StringAdmin.AddNewsSuccessful);
                Response.Redirect("~/Admin/listdetailquestion/" + HiddenField_QuestionID.Value.ToString() + "/Default.aspx");
                //initControl(Id);
            }
            else //Addnew record
            {
                ListQuestion listQuestion = ReceiveHtml_();
                ListQuestionBSO listQuestionBSO = new ListQuestionBSO();
                if (!string.IsNullOrEmpty(listQuestion.Question_Content))
                {
                    listQuestionBSO.CreateListQuestion(listQuestion);
                }
                else
                {
                    //hien thong bao yeu cau nhap noi dung
                }
                //clientview.Text = String.Format(Resources.StringAdmin.AddNewsSuccessful);         

                string strID = HiddenField_QuestionID.Value.ToString() + ",";
                //Cap nhat lai trang thai cau hoi doi voi cau hoi parent
                //Kiem tra user_Name login ? user_name CreateQuestion
                if (Session["Admin_UserName"].ToString() != HiddenField_CreateUserName.Value)
                {
                    //Cap nhat status = 2: Da xu ly
                    listQuestionBSO.UpdateQuestionStatus(strID, 2);
                    //----Gui mail thong bao den khach hang khi co cau tra loi
                    //------Lay userName
                    sendMailToUser(listQuestion);
                }
                else
                {
                    //Cap nhat status = 0: cau hoi moi
                    listQuestionBSO.UpdateQuestionStatus(strID, 0);
                    //Gui mail den nhom support khi khach hang reply
                    sendMailToGroup(listQuestion);
                    //------------ Gui email thong bao den nhom nhom support cua tung san pham              
                }
                Response.Redirect("~/Admin/listdetailquestion/" + HiddenField_QuestionID.Value.ToString() + "/Default.aspx");
            }

        }
        private ListQuestion ReceiveHtml_()
        {
            ConfigBSO configBSO = new ConfigBSO();
            Config config = configBSO.GetAllConfig(Language.language);
            int thumb_w = Convert.ToInt32(config.New_thumb_w);
            int thumb_h = Convert.ToInt32(config.New_thumb_h);

            commonBSO commonBSO = new commonBSO();
            string path_thumb = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/Question/Images/";
            string image_thumb = commonBSO.UploadImage(image_Attach, path_thumb, thumb_w, thumb_h);

            string path = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/Question/Files/";
            string file_upload = commonBSO.UploadFile(file_Attach, path, 18000000000);

            ListQuestion listQuestion = new ListQuestion();

            //Cau hoi moi: Co lay thong tin tu cau hoi parent        
            listQuestion.Question_ParentID = Convert.ToInt32(Page.RouteData.Values["Id"]);
            listQuestion.CateNewsID = int.Parse(HiddenField_CateNewsID.Value.ToString());
            listQuestion.Question_Title = "Trả lời: " + HiddenField_Question_Title.Value.ToString();
            listQuestion.CreateDate = DateTime.Parse(HiddenField_CreateDate.Value.ToString());
            listQuestion.CreateUserName = HiddenField_CreateUserName.Value.ToString();

            //-------------Noi dung lay tu form        
            listQuestion.Question_Content = txtRadShort.Html;
            listQuestion.Question_FileAttach = (file_upload != "") ? file_upload : HiddenField_FileAttach.Value;
            listQuestion.Question_Image = (image_thumb != "") ? image_thumb : HiddenField_ImageAttach.Value;

            listQuestion.IsApproval = false; //Chua duoc duyet
            listQuestion.ApprovalUserName = Session["Admin_UserName"].ToString();
            listQuestion.QuestionStatus = 2; //Cau hoi da tra loi
            listQuestion.ApprovalDate = DateTime.Now; //Ngay phe duyet

            if (Page.RouteData.Values["Id"] != null) //Truong hop edit cau hoi, nhung thong tin duoc fix
            {
                //listQuestion.Question_ID = Id;
                //listQuestion.QuestionStatus = int.Parse(HiddenField_QuestionStatus.Value);
                //listQuestion.CreateDate = DateTime.Parse(HiddenField_CreateDate.Value);
                //listQuestion.CreateUserName = HiddenField_CreateUserName.Value;
            }
            return listQuestion;
        }