private void FillDataInGrid()
 {
     string status = ddlStatus.SelectedValue;
     int type_id = Convert.ToInt32(ddlMediaTypeList.SelectedValue);
     MediaTopics media_topic_obj = new MediaTopics();
     List<Media_Topics> lst = media_topic_obj.GetListByTypeStatus(type_id, status);
     GridView1.DataSource = lst;
     GridView1.DataBind();
 }
        protected void PopulateMediaTopicList2DDL()
        {
            MediaTopics media_topic_obj = new MediaTopics();
            List<Media_Topics> lst = media_topic_obj.GetListByTypeStatus(3,"1");

            ddlMediaTopicList.Items.Clear();
            ddlMediaTopicList.DataSource = lst;
            ddlMediaTopicList.DataTextField = "Name";
            ddlMediaTopicList.DataValueField = "TopicId";
            ddlMediaTopicList.DataBind();
            ddlMediaTopicList.AutoPostBack = true;
        }
        protected void PopulateMediaTopicList2DDL()
        {
            int TypeId = Convert.ToInt32(ddlMediaTypeList.SelectedValue);
            MediaTopics media_topic_obj = new MediaTopics();
            List<Media_Topics> lst = media_topic_obj.GetListByTypeStatus(TypeId, "1");

            ddlMediaTopicList.Items.Clear();
            ddlMediaTopicList.DataSource = lst;
            ddlMediaTopicList.DataTextField = "Name";
            ddlMediaTopicList.DataValueField = "TopicId";
            ddlMediaTopicList.DataBind();
            ddlMediaTopicList.AutoPostBack = true;
        }
 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
     string userid = Session["UserId"].ToString();
     MediaTopics media_topic_obj = new MediaTopics();
     int i = media_topic_obj.Delete(userid, id, upload_front_image_dir);
     FillDataInGrid();
 }
        protected void PopulateMediaTopicList2DDL(string selected_value)
        {
            MediaTopics media_topic_obj = new MediaTopics();
            List<Media_Topics> lst = media_topic_obj.GetListByTypeStatus(1, "1");

            ddlMediaTopicList.Items.Clear();
            ddlMediaTopicList.DataSource = lst;
            ddlMediaTopicList.DataTextField = "Name";
            ddlMediaTopicList.DataValueField = "TopicId";
            ddlMediaTopicList.DataBind();
            ddlMediaTopicList.SelectedValue = selected_value;
        }
        private int UpdateData()
        {
            string UserId = Session["UserId"].ToString();
            int TypeId = Convert.ToInt32(ddlMediaTypeList.SelectedValue);
            string TopicName = txtTopicName.Text;
            string Description = txtDescription.Text;
            string Status = rdlStatus.SelectedValue;
            int ParentId = Convert.ToInt32(ddlMediaTopicList.SelectedValue);

            /*** UPLOAD ************************************************************************************************************/
            string[] FileImg = new String[2];
            string Photo = string.Empty;
            string front_path = Server.MapPath(upload_front_image_dir);
            string orginal_filename = ViewState["Photo"].ToString();
            HttpPostedFile myfile = myFile.PostedFile;
            if (myfile.ContentLength > 0)
            {
                if (System.IO.Directory.Exists(front_path))
                {
                    FileHandleClass file_obj = new FileHandleClass();
                    Photo = file_obj.uploadFixedInputFile(myfile, front_path, 120, 120);
                    file_obj.deleteFile(orginal_filename, front_path);
                }
                else
                {
                    string scriptCode = "<script>alert('Đường dẫn không tồn tại.');</script>";
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode);
                }
            }
            else
            {
                Photo = ViewState["Photo"].ToString();
            }
            ////========================================================================================================================

            MediaTopics media_topic_obj = new MediaTopics();            
            int i = media_topic_obj.Update(UserId,TypeId, _idx, ParentId, TopicName, Photo, Description, Status);
            return i;
        }
        private int AddData()
        {
            string UserId = Session["UserId"].ToString();
            int TypeId = Convert.ToInt32(ddlMediaTypeList.SelectedValue);
            string Description = txtDescription.Text;
            string TopicName = txtTopicName.Text;
            string Status = rdlStatus.SelectedValue;
            int ParentId = Convert.ToInt32(ddlMediaTopicList.SelectedValue);

            /*** UPLOAD ************************************************************************************************************/
            string[] FileImg = new String[2];
            string Photo = string.Empty;
            string front_path = Server.MapPath(upload_front_image_dir);
            HttpPostedFile myfile = myFile.PostedFile;
            if (myfile.ContentLength > 0)
            {
                if (!System.IO.Directory.Exists(front_path))
                    System.IO.Directory.CreateDirectory(front_path);

                FileHandleClass file_obj = new FileHandleClass();
                Photo = file_obj.uploadFixedInputFile(myfile, front_path, 120, 120);
            }
            ////========================================================================================================================

            MediaTopics media_topic_obj = new MediaTopics();
            int i = media_topic_obj.Insert(UserId,TypeId, ParentId, TopicName, Photo, Description, Status);
            return i;
        }
 private void LoadData()
 {
     MediaTopics media_topic_obj = new MediaTopics();
     Media_Topics topic_obj = media_topic_obj.GetDetailById(_idx);
     txtTopicName.Text = topic_obj.Name;
     txtDescription.Text = topic_obj.Description;
     string Status = topic_obj.Status;
     string ParentId = topic_obj.ParentId.ToString();
     PopulateMediaTypeList2DDL(topic_obj.TypeId.ToString());
     PopulateMediaTopicList2DDL(ParentId);
     PopulateStatus2DDL(Status);
     string Photo = topic_obj.Photo;
     imgPhoto.ImageUrl = upload_front_image_dir + "/" + Photo;
     imgPhoto.Height = 70;
     imgPhoto.Width = 50;
     ViewState["Photo"] = Photo;
 }
        private void PopulateMediaTopicList2DDL(string select_value)
        {
            ddlMediaTopicList.Items.Clear(); //DROPDOWNLIST  
            int TypeId = Convert.ToInt32(ddlMediaTypeList.SelectedValue);
            MediaTopics media_topic_obj = new MediaTopics();
            List<Media_Topics> lst = media_topic_obj.GetListByTypeStatus(TypeId, string.Empty);
            if (lst.Count > 0)
            {
                DataTable dt = CommonLibrary.Data.DataUtils.ConvertToDataTable(lst);
                RecursiveFillTree(dt, 0);
            }
            ddlMediaTopicList.Items.Insert(0, new ListItem("- Root -", "0")); //DROPDOWNLIST
            ddlMediaTopicList.SelectedValue = select_value;

        }
        private void PopulateMediaTopicList2DDL()
        {
            ddlMediaTopicList.Items.Clear(); //DROPDOWNLIST  
            MediaTopics media_topic_obj = new MediaTopics();
            List<Media_Topics> lst = media_topic_obj.GetListByStatus("1");
            if (lst.Count > 0)
            {
                DataTable dt = CommonLibrary.Data.DataUtils.ConvertToDataTable(lst);
                RecursiveFillTree(dt, 0);
            }
            ddlMediaTopicList.Items.Insert(0, new ListItem("- Root -", "0")); //DROPDOWNLIST
            ddlMediaTopicList.SelectedIndex = 0;

        }