コード例 #1
0
        private int UpdateData()
        {
            string ApplicationId = ddlApplicationList.SelectedValue;
            string PortalName = txtPortalName.Text;           
            string Currency = ddlCurrencyTypeList.SelectedValue;
            string HostFee = txtHostFee.Text;
            int HostSpace = Convert.ToInt32(txtHostSpace.Text);          
            string DefaultLanguage = ddlLanguageList.Text;
            string HomeDirectory = txtHomeDirectory.Text;
            string Url = txtUrl.Text;
            string KeyWords = txtKeyWords.Text;
            string FooterText = txtFooterText.Text;
            string Description = txtDescription.Text;
            string LastModifiedByUserId = Session["UserId"].ToString(); ;

            #region UPLOAD ************************************************************************************************************/            
            string logo_dir_path = HttpContext.Current.Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"] + "/portal_images/logo");
            string background_dir_path = HttpContext.Current.Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"] + "/portal_images/backgrounds");
            string LogoFile = string.Empty; string BackgroundFile = string.Empty;            
            FileHandleClass file_handle_obj = new FileHandleClass();

            HttpPostedFile _logo_file = InputLogoFile.PostedFile;
            if (_logo_file.ContentLength > 0)
            {
                string logo_file_path = logo_dir_path + "/" + HiddenLogoFile.Value;
                if (File.Exists(logo_file_path))
                {
                    File.Delete(logo_file_path);
                }
                LogoFile = file_handle_obj.uploadInputFile(_logo_file, logo_dir_path);
            }
            else
            {
                LogoFile = HiddenLogoFile.Value;
            }

            HttpPostedFile _background_file = InputBackgroundFile.PostedFile;
            if (_background_file.ContentLength > 0)
            {
                string background_file_path = background_dir_path + "/" + HiddenLogoFile.Value;
                if (File.Exists(background_file_path))
                {
                    File.Delete(background_file_path);
                }
                BackgroundFile = file_handle_obj.uploadInputFile(_background_file, background_dir_path);
            }
            else
            {
                BackgroundFile = HiddenBackgroundFile.Value;
            }
            #endregion ================================================================================

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

            if (txtExpiryDate.Text != string.Empty)
            {
                DateTime _ExpiryDate = DateTime.Parse(txtExpiryDate.Text, MyDateTimeFormatInfo);
                ExpiryDate = _ExpiryDate.ToString("yyyy-MM-dd");
            }
            #endregion ====================================================================================================

            PortalController portal_obj = new PortalController();
            int i = portal_obj.Update(_idx, ApplicationId, PortalName, ExpiryDate, Currency, HostFee, HostSpace, DefaultLanguage,
                 HomeDirectory, Url, LogoFile, BackgroundFile, KeyWords, FooterText, Description, LastModifiedByUserId);
            return i;
        }