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;
        }
        public int Delete(string userid, int idx)
        {
            // Write your own Delete statement blocks.        

            string dir_path = HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"]) + "/article_category_images";
            string file_name = GetImageByID(idx);
            if (file_name != null)
            {
                ModuleClass module_obj = new ModuleClass();
                module_obj.deleteFile(file_name, dir_path);
            }

            SqlCommand cmd = new SqlCommand("[Articles].[sp_ArticleCategories_Delete]", con) { CommandType = CommandType.StoredProcedure, CommandTimeout = Settings.CommandTimeout };
            cmd.Parameters.AddWithValue("@userid", userid);
            cmd.Parameters.AddWithValue("@ip", ip);
            cmd.Parameters.AddWithValue("@idx", idx);
            cmd.Parameters.Add(new SqlParameter("@o_return", SqlDbType.Int) { Direction = ParameterDirection.Output });
            con.Open();
            cmd.ExecuteNonQuery();
            int retunvalue = (int)cmd.Parameters["@o_return"].Value;
            con.Close();
            return retunvalue;
        }
        private int UpdateData()
        {
            string ApplicationId = ddlApplicationList.SelectedValue;
            int PortalId = Convert.ToInt32(ddlPortalList.SelectedValue);
            int VendorId = Convert.ToInt32(ddlVendorList.SelectedValue);
            string RoleId = ddlRoleList.SelectedValue;
            string FullName = txtFullName.Text;
            string DisplayName = txtDisplayName.Text;                
            string MobilePIN = txtMobilePIN.Text;
            string Address = txtAddress.Text;
            string Phone = txtPhone.Text;
            string Email = txtEmail.Text;         

            //=================================================
            bool _IsSuperUser = chkIsSuperUser.Checked;                
            int IsSuperUser;
            if (_IsSuperUser == true)
            {
                IsSuperUser = 1;
            }
            else
            {
                IsSuperUser = 0;
            }
            //=================================================
            bool _IsDeleted = chkIsDeleted.Checked;
            int IsDeleted;
            if (_IsDeleted == true)
            {
                IsDeleted = 1;
            }
            else
            {
                IsDeleted = 0;
            }
            //=================================================
            bool _IsApproved = chkIsApproved.Checked;
            int IsApproved;
            if (_IsApproved == true)
            {
                IsApproved = 1;
            }
            else
            {
                IsApproved = 0;
            }
            //=================================================
            bool _UpdatePassword = chkUpdatePassword.Checked;
            int UpdatePassword;
            if (_UpdatePassword == true)
            {
                UpdatePassword = 1;
            }
            else
            {
                UpdatePassword = 0;
            }
            //=================================================
            bool _IsLockedOut = chkIsLockedOut.Checked;
            int IsLockedOut;
            if (_IsLockedOut == true)
            {
                IsLockedOut = 1;
            }
            else
            {
                IsLockedOut = 0;
            }
            //=================================================
            ModuleClass module_obj = new ModuleClass();
            string Username = string.Empty;
            if (module_obj.CheckInput(txtUserName.Text))
            {
                Username = txtUserName.Text;
            }
            else
            {
                Response.Write("<script>alert('Invalid Username');</script>");
                Response.End();
            }

            MD5CryptEncrypt md5_obj = new MD5CryptEncrypt();
            string Password = md5_obj.getMd5Hash(txtPassword.Text);
            string PasswordSalt = txtPassword.Text;
            string passwordConfirm = txtPasswordConfirm.Text;
            string PasswordQuestion = ddlPassQuestion.SelectedValue;
            string PasswordAnswer = txtPassAnswer.Text;

            string Comment = txtComment.Text;

            UserController user_obj = new UserController();
            int result = user_obj.Update(_idx, ApplicationId, PortalId, VendorId, RoleId, Username,
            Password, PasswordSalt, PasswordQuestion, PasswordAnswer,
            FullName, DisplayName, Address, MobilePIN, Phone, Email,
            IsSuperUser, UpdatePassword,IsDeleted, IsApproved, IsLockedOut, Comment);           
            
            return result;

        }
        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 AddData()
        {          
            string ApplicationId = ddlApplicationList.SelectedValue;
            int PortalId = Convert.ToInt32(ddlPortalList.SelectedValue);
            int VendorId = Convert.ToInt32(ddlVendorList.SelectedValue);
            string RoleId = ddlRoleList.SelectedValue;
            string FullName = txtFullName.Text;
            string DisplayName = txtDisplayName.Text;                
            string MobilePIN = txtMobilePIN.Text;
            string Address = txtAddress.Text;
            string Phone = txtPhone.Text;
            string Email = txtEmail.Text;          

            bool _IsSuperUser = chkIsSuperUser.Checked;                
            int IsSuperUser;
            if (_IsSuperUser == true)
            {
                IsSuperUser = 1;
            }
            else
            {
                IsSuperUser = 0;
            }

            bool _IsDeleted = chkIsDeleted.Checked;
            int IsDeleted;
            if (_IsDeleted == true)
            {
                IsDeleted = 1;
            }
            else
            {
                IsDeleted = 0;
            }

            bool _IsApproved = chkIsApproved.Checked;
            int IsApproved;
            if (_IsApproved == true)
            {
                IsApproved = 1;
            }
            else
            {
                IsApproved = 0;
            }

            bool _UpdatePassword = chkUpdatePassword.Checked;
            int UpdatePassword;
            if (_UpdatePassword == true)
            {
                UpdatePassword = 1;
            }
            else
            {
                UpdatePassword = 0;
            }

            ModuleClass module_obj = new ModuleClass();
            string Username = string.Empty;
            if (module_obj.CheckInput(txtUserName.Text))
            {
                Username = txtUserName.Text;
            }
            else
            {
                string scriptCode = "<script>alert('Invalid Username.');</script>";
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode);
            }

            MD5CryptEncrypt md5_obj = new MD5CryptEncrypt();
            string Password = md5_obj.getMd5Hash(txtPassword.Text);
            string PasswordSalt = txtPassword.Text;
            string passwordConfirm = txtPasswordConfirm.Text;
            string PasswordQuestion = ddlPassQuestion.SelectedValue;
            string PasswordAnswer = txtPassAnswer.Text;

            string Comment = txtComment.Text;

            UserController user_obj = new UserController();
            int result = user_obj.Insert(ApplicationId, PortalId, VendorId, RoleId, Username, Password, PasswordSalt,
                PasswordQuestion, PasswordAnswer, FullName, DisplayName, Address, MobilePIN,
                Phone, Email, IsSuperUser, UpdatePassword, IsDeleted, IsApproved, Comment);  
            return result;
        }
        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()
        {
            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 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;
        }
        private int UpdateData()
        {           
            string FullName = txtFullName.Text;
            string DisplayName = txtDisplayName.Text;           
            string Address = txtAddress.Text;
            string Phone = txtPhone.Text;
            string Email = txtEmail.Text;

           
            ModuleClass module_obj = new ModuleClass();
            string Username = string.Empty;
            if (module_obj.CheckInput(txtUserName.Text))
            {
                Username = txtUserName.Text;
            }
            else
            {
                Response.Write("<script>alert('Invalid Username');</script>");
                Response.End();
            }

            MD5CryptEncrypt md5_obj = new MD5CryptEncrypt();
            string Password = md5_obj.getMd5Hash(txtPassword.Text);
            string PasswordSalt = txtPassword.Text;
            string passwordConfirm = txtPasswordConfirm.Text;
            string PasswordQuestion = ddlPassQuestion.SelectedValue;
            string PasswordAnswer = txtPassAnswer.Text;

            UserController user_obj = new UserController();
            int result = user_obj.Edit(Username,Password, PasswordSalt, PasswordQuestion, PasswordAnswer,
                                 FullName, DisplayName, Address, Phone, Email);
            return result;

        }