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() { 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; }