private int UpdateData()
        {
            int PortalId = Convert.ToInt32(ddlPortalList.SelectedValue);
            string SkinType = ddlSkinTypeList.SelectedValue;
            string SkinName = txtSkinName.Text;
            string LastModifiedByUserId = Session["UserId"].ToString();
            
            /*** UPLOAD *************************************************************************************************************/
            string SkinIcon = string.Empty;
            string upload_image_physical_path = Server.MapPath(upload_image_dir);
            HttpPostedFile icon_file = FileInput.PostedFile;            
            if (icon_file.ContentLength > 0)
            {
                ModuleClass module_obj = new ModuleClass();
                module_obj.deleteFile(ViewState["SkinIcon"].ToString(), upload_image_physical_path);

                SkinIcon = module_obj.GetEncodeString(System.IO.Path.GetFileName(icon_file.FileName));
                string savePath = System.IO.Path.Combine(upload_image_physical_path, SkinIcon);
                icon_file.SaveAs(savePath);
            }
            else
            {
                SkinIcon = ViewState["SkinIcon"].ToString();
            }
            /************************************************************************************************************************/

            SkinPackages skin_package_obj = new SkinPackages();
            int i = skin_package_obj.Update(_idx, PortalId, SkinName, SkinType, SkinIcon, LastModifiedByUserId);
            return i;
        }
        private int AddData()
        {            
            int PortalId = Convert.ToInt32(ddlPortalList.SelectedValue);
            string SkinType = ddlSkinTypeList.SelectedValue;
            string SkinName = txtSkinName.Text;
            string CreatedByUserId = Session["UserId"].ToString();
            /*** UPLOAD *************************************************************************************************************/
            HttpPostedFile icon_file = FileInput.PostedFile;
            string SkinIcon = "";
            if (icon_file.ContentLength > 0)
            {
                ModuleClass module_obj = new ModuleClass();
                SkinIcon = module_obj.GetEncodeString(System.IO.Path.GetFileName(icon_file.FileName));
                string savePath = Server.MapPath(upload_image_dir+"/" + SkinIcon);
                icon_file.SaveAs(savePath);
            }
            /************************************************************************************************************************/

            SkinPackages skin_package_obj = new SkinPackages();
            int i = skin_package_obj.Insert(PortalId, SkinName, SkinType, SkinIcon, CreatedByUserId);
            return i;
        }
        private int UpdateData()
        {
            string userid = Session["UserId"].ToString();
            int portalid = Convert.ToInt32(ddlPortalList.SelectedValue);
            int typeid = Convert.ToInt32(ddlMediaTypeList.SelectedValue);
            string title = txtTitle.Text;
            string description = txtDescription.Text;


            /*** UPLOAD *************************************************************************************************************/
            string dir_path = "~/" + System.Configuration.ConfigurationManager.AppSettings["upload_background_audio_dir"];
            HttpPostedFile icon_file = FileInput.PostedFile;
            string filename = "";
            if (icon_file != null)
            {
                if (icon_file.ContentLength > 0)
                {
                    ModuleClass module_obj = new ModuleClass();
                    module_obj.deleteFile(ViewState["filename"].ToString(), dir_path);

                    filename = module_obj.GetEncodeString(System.IO.Path.GetFileName(icon_file.FileName));
                    string savePath = Server.MapPath(dir_path + "/" + filename);
                    icon_file.SaveAs(savePath);
                }
                else
                {
                    filename = ViewState["filename"].ToString();
                }
            }            
            /************************************************************************************************************************/

            //MediaClass media_obj = new MediaClass();
            //int i = media_obj.Update(userid, _idx,portalid,typeid, filename, title, description);
            int i=0;
            return i;
        }
        private int[] AddData()
        {            
            int[] result = new int[2];
            if (Session["UserId"] != null && Session["UserId"].ToString() != string.Empty)
            {
                int PortalId = Convert.ToInt32(ddlPortalList.SelectedValue);
                int ContentItemId = int.Parse(ddlContentItem.SelectedValue);
                int RouteId = int.Parse(ddlRouterList.SelectedValue);
                string TabName = txt_TabName.Text;
                string Title = txt_Title.Text;
                int ParentId = int.Parse(ddlParentTab.SelectedValue);
                string Description = txt_Desc.Text;
                string Keywords = txt_Keywords.Text;

                string Url = txt_Url.Text;
                string TabPath = txt_Path.Text;
                decimal SiteMapPriority = Convert.ToDecimal(txtSiteMapPriority.Text)/10;

                string PageHeadText = txt_PageHeadText.Text;
                string PageFooterText = txt_PageFooterText.Text;
                string CssClass = txt_CssClass.Text;
                string CultureCode = ddlCultureCode.SelectedValue;
                //  string StartDate=txt_StartDate.Text;
                //   string EndDate= txt_EndDate.Text;

                #region xu ly thoi gian  ====================================================================================
                System.Globalization.DateTimeFormatInfo MyDateTimeFormatInfo = new System.Globalization.DateTimeFormatInfo();
                MyDateTimeFormatInfo.ShortDatePattern = "dd/MM/yyyy";

                string StartDate = null, EndDate = null;

                if (txt_StartDate.Text != string.Empty && txt_StartDate.Text != "__/__/____")
                {
                    DateTime _start_date = DateTime.Parse(txt_StartDate.Text, MyDateTimeFormatInfo);
                    StartDate = _start_date.ToString("yyyy-MM-dd");
                }
                if (txt_EndDate.Text != string.Empty && txt_EndDate.Text != "__/__/____")
                {
                    DateTime _end_date = DateTime.Parse(txt_EndDate.Text, MyDateTimeFormatInfo);
                    EndDate = _end_date.ToString("yyyy-MM-dd");
                }
                if (txt_StartDate.Text != string.Empty && txt_StartDate.Text != "__/__/____"
                    && txt_EndDate.Text != string.Empty && txt_EndDate.Text != "__/__/____")
                {
                    DateTime _start_date = DateTime.Parse(txt_StartDate.Text, MyDateTimeFormatInfo);
                    DateTime _end_date = DateTime.Parse(txt_EndDate.Text, MyDateTimeFormatInfo);

                    if (DateTime.Compare(_start_date, _end_date) > 0)
                    {
                        string scriptCode = "<script>alert('Thời điểm bắt đầu phải nhỏ hơn thời điểm kết thúc');</script>";
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode);
                    }
                }
                #endregion ================================================================================================

                /*** UPLOAD *************************************************************************************************************/
                HttpPostedFile icon_file = FileIconInput.PostedFile;
                HttpPostedFile icon_large_file = FileIconLargeInput.PostedFile;
                string IconFileName = "", IconFileLargeName = "", IconFilePath = string.Empty, IconFileLargePath = string.Empty;
                if (icon_file.ContentLength > 0)
                {
                    ModuleClass module_obj = new ModuleClass();
                    IconFileName = module_obj.GetEncodeString(System.IO.Path.GetFileName(icon_file.FileName));
                    IconFilePath = Server.MapPath(small_icon_path + "/" + IconFileName);
                    icon_file.SaveAs(IconFilePath);
                }

                if (icon_large_file.ContentLength > 0)
                {
                    IconFileLargeName = System.IO.Path.GetFileName(icon_large_file.FileName);
                    IconFileLargePath = Server.MapPath(large_icon_path + "/" + IconFileLargeName);
                    icon_file.SaveAs(IconFileLargePath);
                }
                /************************************************************************************************************************/

                bool IsDeleted = true, IsVisible = true, DisableLink = false, DisplayTitle = false, IsSecure = false, PermanentRedirect = false;
                IsDeleted = chkIsDelete.Checked;
                IsVisible = chkIsVisible.Checked;
                DisableLink = chkDisableLink.Checked;
                DisplayTitle = chkDisplayTitle.Checked;
                IsSecure = chkIsSecure.Checked;
                PermanentRedirect = chkPermanentRedirect.Checked;

                
                result = tab_obj.Insert(PortalId, ContentItemId, ParentId, TabName, Title, CssClass,
                    IconFileName, IconFileLargeName, Description, Keywords, DisplayTitle, IsDeleted, IsVisible,
                    DisableLink, IsSecure, PermanentRedirect, SiteMapPriority, Url, TabPath, RouteId, PageHeadText, PageFooterText, "", StartDate, EndDate, CultureCode, UserId);
            }
            return result;
        }
        private int UpdateData()
        {
            int SkinPackage_ID = Convert.ToInt32(ddlPackageList.SelectedValue);
            string SkinBackground_Name = txtTitle.Text;
            string SkinBackground_Url = txtUrl.Text;
            bool bStatus = ChkBoxStatus.Checked;
            int SkinBackground_Discontinued = 0;
            if (bStatus == true)
            {
                SkinBackground_Discontinued = 1;
            }
            else
            {
                SkinBackground_Discontinued = 0;
            }


            /*** UPLOAD *************************************************************************************************************/
            string dir_path = "~/" + System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"] + "/background_images/";
            HttpPostedFile icon_file = FileInput.PostedFile;
            string SkinBackground_FileName = "";
            if (icon_file.ContentLength > 0)
            {
                ModuleClass module_obj = new ModuleClass();
                module_obj.deleteFile(txtFileName.Text, dir_path);
               
                SkinBackground_FileName = module_obj.GetEncodeString(System.IO.Path.GetFileName(icon_file.FileName));                   
                string savePath = Server.MapPath(dir_path + SkinBackground_FileName);
                icon_file.SaveAs(savePath);
            }
            else
            {
                SkinBackground_FileName = txtFileName.Text;
            }
            /************************************************************************************************************************/

            SkinBackgrounds background_obj = new SkinBackgrounds();
            int i = background_obj.Update(_idx, SkinPackage_ID, SkinBackground_Name,SkinBackground_FileName, SkinBackground_Url, SkinBackground_Discontinued);            
            return i;
        }