private int AddData() { string userid = Session["UserId"].ToString(); int portalid = Convert.ToInt32(ddlPortalList.SelectedValue); string culturecode = ddlCultureList.SelectedValue; string code = ddlTreeNode_Category.SelectedValue; string title = txtTitle.Text; string headline = txtHeadline.Text; string abstract_info = txtAbstract.Text; string contents = FCKeditorContent.Value; string source = txtSource.Text; string status = rdlStatus.SelectedValue; string navigateurl = txtNavigateUrl.Text; /*** UPLOAD ****************************************************************************************************************************************/ string front_img = "", main_img = ""; HttpPostedFile myfile = FileInput.PostedFile; if (myfile.FileName != string.Empty) { string front_img_path = Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"] + "/article_images/front_images"); string main_img_path = Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"] + "/article_images/main_images"); FileHandleClass file_handle_obj = new FileHandleClass(); string[] FileImg = new String[2]; FileImg = file_handle_obj.uploadFrontMainInputFile(myfile, front_img_path, main_img_path, 120, 120); main_img = FileImg[0].ToString(); front_img = FileImg[1].ToString(); } /*************************************************************************************************************************************************/ ArticleController article_obj = new ArticleController(); int i = article_obj.Insert(userid, portalid, culturecode, code, title, headline, abstract_info, front_img, main_img, contents, source, navigateurl, status); return(i); }
protected int UpdateData() { string userid = Session["UserId"].ToString(); int portalid = Convert.ToInt32(ddlPortalList.SelectedValue); string culturecode = ddlCultureList.SelectedValue; string code = ddlTreeNode_Category.SelectedValue; string title = txtTitle.Text; string headline = txtHeadline.Text; string abstract_info = txtAbstract.Text; string contents = FCKeditorContent.Value; string source = txtSource.Text; string status = rdlStatus.SelectedValue; string navigateurl = txtNavigateUrl.Text; /*** UPLOAD ****************************************************************************************************************************************/ string front_img = "", main_img = ""; HttpPostedFile myfile = FileInput.PostedFile; if (myfile.FileName != string.Empty) { string front_img_path = Server.MapPath(upload_front_image_dir); string main_img_path = Server.MapPath(upload_main_image_dir); FileHandleClass file_handle_obj = new FileHandleClass(); string[] FileImg = new String[2]; FileImg = file_handle_obj.uploadFrontMainInputFile(myfile, front_img_path, main_img_path, 120, 120); main_img = FileImg[0].ToString(); front_img = FileImg[1].ToString(); front_Img.ImageUrl = upload_front_image_dir + "/" + front_img; string Orginal_front_image = ViewState["FrontImage"].ToString(); string Orginal_main_image = ViewState["MainImage"].ToString(); file_handle_obj.DeleteFile(Orginal_front_image, front_img_path); file_handle_obj.DeleteFile(Orginal_main_image, main_img_path); } else { main_img = ViewState["MainImage"].ToString(); front_img = ViewState["FrontImage"].ToString(); } /*************************************************************************************************************************************************/ int i = article_obj.Update(userid, portalid, culturecode, _idx, code, title, headline, abstract_info, front_img, main_img, contents, source, navigateurl, status); return(i); }
private int UpdateData() { int vendorid = Convert.ToInt32(Session["VendorId"].ToString()); if (ddlPosition.SelectedValue == string.Empty) { string scriptCode = "<script>alert('Vui lòng chọn vị trí!!!');</script>"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode); } string culturecode = ddlCultureList.SelectedValue; int height = Convert.ToInt32(txtHeight.Text); int width = Convert.ToInt32(txtWidth.Text); string title = txtTitle.Text; string url = txtUrl.Text; int position = Convert.ToInt32(ddlPosition.SelectedValue); string description = txtDescription.Text; string tags = txtTags.Text; bool bStatus = ChkBoxStatus.Checked; string status = string.Empty; if (bStatus == true) { status = "1"; } else { status = "0"; } /*** UPLOAD ****************************************************************************************************************************************/ string thumb_image = "", main_image = ""; HttpPostedFile myfile = FileInput.PostedFile; if (myfile.FileName != string.Empty) { if (myfile.ContentLength > 0) { string banner_img_path = Server.MapPath(banner_dir_path); string front_img_path = Server.MapPath(thumb_banner_dir_path); string main_img_path = Server.MapPath(main_banner_dir_path); if (!Directory.Exists(banner_img_path)) { Directory.CreateDirectory(banner_img_path); } if (!Directory.Exists(front_img_path)) { Directory.CreateDirectory(front_img_path); } if (!Directory.Exists(main_img_path)) { Directory.CreateDirectory(main_img_path); } FileHandleClass file_handle_obj = new FileHandleClass(); string[] FileImg = new String[2]; FileImg = file_handle_obj.uploadFrontMainInputFile(myfile, front_img_path, main_img_path, 120, 120); main_image = FileImg[0].ToString(); thumb_image = FileImg[1].ToString(); imgPhoto.ImageUrl = thumb_banner_dir_path + "/" + thumb_image; string Orginal_front_image = ViewState["ThumbImage"].ToString(); string Orginal_main_image = ViewState["MainImage"].ToString(); file_handle_obj.DeleteFile(Orginal_front_image, front_img_path); file_handle_obj.DeleteFile(Orginal_main_image, main_img_path); } } else { main_image = ViewState["MainImage"].ToString(); thumb_image = ViewState["ThumbImage"].ToString(); } /*************************************************************************************************************************************************/ #region xu ly thoi gian ==================================================================================== System.Globalization.DateTimeFormatInfo MyDateTimeFormatInfo = new System.Globalization.DateTimeFormatInfo(); MyDateTimeFormatInfo.ShortDatePattern = "dd/MM/yyyy"; string start_date = null, end_date = null; if (txtStartDate.Text != string.Empty) { DateTime _start_date = DateTime.Parse(txtStartDate.Text, MyDateTimeFormatInfo); start_date = _start_date.ToString("yyyy-MM-dd"); } if (txtEndDate.Text != string.Empty) { DateTime _end_date = DateTime.Parse(txtEndDate.Text, MyDateTimeFormatInfo); end_date = _end_date.ToString("yyyy-MM-dd"); } if (txtStartDate.Text != string.Empty && txtEndDate.Text != string.Empty) { DateTime _start_date = DateTime.Parse(txtStartDate.Text, MyDateTimeFormatInfo); DateTime _end_date = DateTime.Parse(txtEndDate.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 ================================================================================================ BannerController banner_obj = new BannerController(); int i = banner_obj.Update(vendorid, _idx, culturecode, title, main_image, thumb_image, url, position, description, tags, width, height, start_date, end_date, status); return(i); }
private int UpdateData() { string userid = Session["UserId"].ToString(); int typeid = Convert.ToInt32(ddlMediaTypeList.SelectedValue); int topicid = Convert.ToInt32(ddlMediaTopicList.SelectedValue); int albumid = Convert.ToInt32(ddlAlbumList.SelectedValue); int artistid = Convert.ToInt32(ddlArtistList.SelectedValue); int composerid = Convert.ToInt32(ddlComposerList.SelectedValue); int playlistid = Convert.ToInt32(ddlPlayList.SelectedValue); string title = txtFileTitle.Text; string description = txtDescription.Value; string dimension = txtDimension.Text; string source = txtSource.Text; string status = "0"; int autostart = 0; int medialoop = 0; if (chkAutoStart.Checked == true) { autostart = 1; } if (chkMedialoop.Checked == true) { medialoop = 1; } if (chkIsFilePublished.Checked == true) { status = "1"; } /*** UPLOAD IMAGE************************************************************************************************************/ string Orginal_Photo = ViewState["Photo"].ToString(); string Orginal_Thumbnail = ViewState["Thumbnail"].ToString(); string[] FileImg = new String[2]; string photo = string.Empty; string thumbnail = string.Empty; string front_path = Server.MapPath(front_image_dir); string main_path = Server.MapPath(main_image_dir); HttpPostedFile myfile = File2.PostedFile; if (chkAutoCreateThumbnail.Checked == true) { if (myfile.ContentLength > 0) { if (System.IO.Directory.Exists(front_path) && System.IO.Directory.Exists(main_path)) { FileHandleClass file_obj = new FileHandleClass(); FileImg = file_obj.uploadFrontMainInputFile(myfile, front_path, main_path, 120, 120); photo = FileImg[0]; thumbnail = FileImg[1]; DeleteFrontImage(Orginal_Photo); DeleteMainImage(Orginal_Thumbnail); } 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(); thumbnail = ViewState["Thumbnail"].ToString(); } } else { if (myfile.ContentLength > 0) { FileHandleClass file_handle_obj = new FileHandleClass(); photo = file_handle_obj.uploadFixedInputFile(myfile, front_path, 120, 120); DeleteFrontImage(Orginal_Photo); } else { photo = ViewState["Photo"].ToString(); thumbnail = ViewState["Thumbnail"].ToString(); } } ////======================================================================================================================== /*** UPLOAD FILE*************************************************************************************************************/ string filename = string.Empty; string fileurl = string.Empty, file_ext = string.Empty; int TypeId = Convert.ToInt32(ddlMediaTypeList.SelectedValue); MediaTypes media_type_obj = new MediaTypes(); Media_Types type_obj = media_type_obj.GetDetails(TypeId); string TypeExt = type_obj.TypeExt.Trim(); string TypePath = type_obj.TypePath; string dir_path = Server.MapPath("~/" + TypePath); string[] arr_list = GetArray(TypeExt); if (rdlFileUpload.SelectedValue == "0") { HttpPostedFile posted_file = File1.PostedFile; if (posted_file.ContentLength > 0) { file_ext = System.IO.Path.GetExtension(myfile.FileName).ToLower().Trim(); if (Directory.Exists(dir_path)) { for (int i = 0; i < arr_list.Length; i++) { if (file_ext == arr_list[i].ToString()) { FileHandleClass file_obj = new FileHandleClass(); filename = file_obj.uploadInputFile(posted_file, dir_path); } } } } } else { file_ext = System.IO.Path.GetExtension(txtFileUrl.Text).ToLower().Trim(); filename = System.IO.Path.GetFileName(txtFileUrl.Text); for (int i = 0; i < arr_list.Length; i++) { if (file_ext == arr_list[i].ToString()) { fileurl = txtFileUrl.Text; } } } /************************************************************************************************************************/ MediaFiles media_obj = new MediaFiles(); int relust = media_obj.Update(_idx, userid, typeid, topicid, playlistid, albumid, artistid, composerid, filename, fileurl, title, description, autostart, medialoop, dimension, source, photo, thumbnail, status); return(relust); }