protected void linkSave_Click(object sender, EventArgs e) { //if (!Page.IsValid) return; T_Photo_EventDAL _untilDAL = new T_Photo_EventDAL(); if (!string.IsNullOrEmpty(txtTienNhuanBut.Text)) { try { int.Parse(txtTienNhuanBut.Text.Replace(",", "")); } catch { System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "Message", "alert('" + CommonLib.ReadXML("lblXacnhanTien") + "');", true); return; } } T_Photo_Event _Obj = GetObject(); int _return = 0; if (_Obj.Photo_ID == 0) { _return = _untilDAL.InsertT_Photo_Events(_Obj); string _ActionsCode = "[Thời sự qua ảnh] [Thao tác Thêm] [Ảnh: " + _Obj.Photo_Name + "]"; WriteLogHistory2Database.WriteHistory2Database(_user.UserID, _user.UserFullName, "[Thêm mới]", Convert.ToInt32(Request["Menu_ID"]), _ActionsCode, _return, ConstAction.TSAnh); System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "Message", "alert('" + Global.RM.GetString("VALIDATE_ADDNEWS") + "');", true); } else { _return = _untilDAL.InsertT_Photo_Events(_Obj); string _ActionsCode = "[Thời sự qua ảnh] [Cập nhật ảnh trong ngày] [Ảnh: " + _Obj.Photo_Name + "]"; WriteLogHistory2Database.WriteHistory2Database(_user.UserID, _user.UserFullName, "[Cập nhật]", Convert.ToInt32(Request["Menu_ID"]), _ActionsCode, _return, ConstAction.TSAnh); System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "Message", "alert('" + Global.RM.GetString("VALIDATE_ADDNEWS") + "');", true); } if (Page.Request["Tab"].ToString() != "-1") { if (Page.Request["Menu_ID"] != null) { Page.Response.Redirect("~/Anh24h/List_PhotosChoDuyet.aspx?Menu_ID=" + this.Page.Request["Menu_ID"].ToString() + "&Tab=" + Page.Request["Tab"].ToString()); } else { return; } } else { if (Page.Request["Menu_ID"] != null) { Page.Response.Redirect("~/Anh24h/List_PhotosChoDuyet.aspx?Menu_ID=" + this.Page.Request["Menu_ID"].ToString()); } else { return; } } }
protected void btnLinkTra_Click(object sender, EventArgs e) { T_Photo_EventDAL _cateDAL = new T_Photo_EventDAL(); T_Photo_Event _catObj = new T_Photo_Event(); foreach (DataGridItem m_Item in grdListCate.Items) { CheckBox chk_Select = (CheckBox)m_Item.FindControl("optSelect"); TextBox txtTitle = (TextBox)m_Item.FindControl("txtTitle"); TextBox txttacgia = (TextBox)m_Item.FindControl("txt_tacgia"); Label lblUrlPath = (Label)m_Item.FindControl("lblUrlPath"); DropDownList cboNgonNgu = (DropDownList)m_Item.FindControl("cboNgonNgu"); double PhotoID = double.Parse(grdListCate.DataKeys[int.Parse(m_Item.ItemIndex.ToString())].ToString()); _catObj = setItem(int.Parse(PhotoID.ToString()), lblUrlPath.Text, txtTitle.Text, Convert.ToInt32(cboNgonNgu.SelectedValue), txttacgia.Text); _cateDAL.InsertT_Photo_Events(_catObj); if (chk_Select != null && chk_Select.Checked) { T_Photo_EventDAL _untilDAL = new T_Photo_EventDAL(); T_Photo_Event _obj = new T_Photo_Event(); _obj = _untilDAL.GetOneFromT_Photo_EventsByID(PhotoID); _untilDAL.UpdateStatus_Photo_Events(PhotoID, 7, _user.UserID, DateTime.Now); string _ActionsCode = "[Thời sự qua ảnh] " + menuName + " [Trả Ảnh] [Ảnh: " + _obj.Photo_Name + "]"; WriteLogHistory2Database.WriteHistory2Database(_user.UserID, _user.UserFullName, "[Trả Ảnh]", Convert.ToInt32(Request["Menu_ID"]), _ActionsCode, PhotoID, ConstAction.TSAnh); } } LoadData(status); }
protected void linkSave_Click(object sender, EventArgs e) { try { #region "Duyet danh sach cac doi tuong tren luoi" T_Photo_EventDAL _cateDAL = new T_Photo_EventDAL(); T_Photo_Event _catObj = new T_Photo_Event(); //HPCBusinessLogic.DAL.T_ButdanhDAL obj = new HPCBusinessLogic.DAL.T_ButdanhDAL(); foreach (DataGridItem m_Item in grdListCate.Items) { TextBox txtTitle = (TextBox)m_Item.FindControl("txtTitle"); TextBox txttacgia = (TextBox)m_Item.FindControl("txt_tacgia"); Label lblUrlPath = (Label)m_Item.FindControl("lblUrlPath"); DropDownList cboNgonNgu = (DropDownList)m_Item.FindControl("cboNgonNgu"); int PhotoID = Convert.ToInt32(grdListCate.DataKeys[int.Parse(m_Item.ItemIndex.ToString())].ToString()); _catObj = setItem(PhotoID, lblUrlPath.Text, txtTitle.Text, Convert.ToInt32(cboNgonNgu.SelectedValue), txttacgia.Text); _cateDAL.InsertT_Photo_Events(_catObj); } LoadData(status); this.litMessages.Text = "Lưu giữ thành công"; #endregion } catch (Exception ex) { HPCServerDataAccess.Lib.ShowAlertMessage(ex.Message.ToString()); } }
protected void btnLinkDuyetAnh_Click(object sender, EventArgs e) { T_Photo_EventDAL _cateDAL = new T_Photo_EventDAL(); T_Photo_Event _catObj = new T_Photo_Event(); foreach (DataGridItem m_Item in grdListCate.Items) { CheckBox chk_Select = (CheckBox)m_Item.FindControl("optSelect"); TextBox txtTitle = (TextBox)m_Item.FindControl("txtTitle"); TextBox txttacgia = (TextBox)m_Item.FindControl("txt_tacgia"); Label lblUrlPath = (Label)m_Item.FindControl("lblUrlPath"); DropDownList cboNgonNgu = (DropDownList)m_Item.FindControl("cboNgonNgu"); double PhotoID = double.Parse(grdListCate.DataKeys[int.Parse(m_Item.ItemIndex.ToString())].ToString()); _catObj = setItem(int.Parse(PhotoID.ToString()), lblUrlPath.Text, txtTitle.Text, Convert.ToInt32(cboNgonNgu.SelectedValue), txttacgia.Text); _cateDAL.InsertT_Photo_Events(_catObj); if (chk_Select != null && chk_Select.Checked) { T_Photo_EventDAL _untilDAL = new T_Photo_EventDAL(); T_Photo_Event _obj = new T_Photo_Event(); _obj = _untilDAL.GetOneFromT_Photo_EventsByID(PhotoID); if (pageback == 1) { if (_obj.Photo_Name.Trim().Length > 0) { _untilDAL.UpdateStatus_Photo_Events(PhotoID, 8, _user.UserID, DateTime.Now); } else { ScriptManager.RegisterStartupScript(this, GetType(), "myFunction", "alert('Bạn chưa nhập tiêu đề ảnh !');", true); } } else if (pageback == 2) { _untilDAL.UpdateStatus_Photo_Events(PhotoID, 3, _user.UserID, DateTime.Now); #region Sync // DONG BO ANH SynFiles _syncfile = new SynFiles(); if (_obj.Photo_Medium.Length > 0) { _syncfile.SynData_UploadImgOne(_obj.Photo_Medium, HPCComponents.Global.ImagesService); } //END #endregion } string _ActionsCode = "[Thời sự qua ảnh] " + menuName + " [Gửi duyệt Ảnh] [Ảnh: " + _untilDAL.GetOneFromT_Photo_EventsByID(PhotoID).Photo_Name + "]"; WriteLogHistory2Database.WriteHistory2Database(_user.UserID, _user.UserFullName, "[Gửi duyệt]", Convert.ToInt32(Request["Menu_ID"]), _ActionsCode, PhotoID, ConstAction.TSAnh); } } LoadData(status); }
public void grdListCategory_EditCommand(object source, DataGridCommandEventArgs e) { T_Photo_EventDAL _DAL = new T_Photo_EventDAL(); T_Photo_Event _obj = new T_Photo_Event(); ImageButton btnModify = e.Item.FindControl("btnModify") as ImageButton; ImageButton btnSave = e.Item.FindControl("btnSave") as ImageButton; ImageButton btnBack = e.Item.FindControl("btnBack") as ImageButton; Label lblNgonNgu = e.Item.FindControl("lblNgonNgu") as Label; LinkButton btnEdit = e.Item.FindControl("btnEdit") as LinkButton; Label lblTacGia = e.Item.FindControl("lblTacGia") as Label; Label lblUrlPath = e.Item.FindControl("lblUrlPath") as Label; DropDownList cboNgonNgu = e.Item.FindControl("cboNgonNgu") as DropDownList; TextBox txtTitle = e.Item.FindControl("txtTitle") as TextBox; TextBox txtTacGia = e.Item.FindControl("txt_tacgia") as TextBox; //Image imgView = e.Item.FindControl("imgView") as Image; //Image imgBrowse = e.Item.FindControl("imgBrowse") as Image; int _ID = Convert.ToInt32(grdListCate.DataKeys[e.Item.ItemIndex].ToString()); _obj = _DAL.GetOneFromT_Photo_EventsByID(_ID); if (e.CommandArgument.ToString().ToLower() == "editphoto") { btnSave.Visible = true; btnBack.Visible = true; btnModify.Visible = false; lblNgonNgu.Visible = false; lblTacGia.Visible = false; btnEdit.Visible = false; cboNgonNgu.Visible = true; txtTitle.Visible = true; txtTacGia.Visible = true; //imgView.Visible = false; //imgBrowse.Visible = true; } if (e.CommandArgument.ToString().ToLower() == "savephoto") { if (txtTitle.Text.Trim().Length > 0) { btnSave.Visible = false; btnBack.Visible = false; btnModify.Visible = true; lblNgonNgu.Visible = true; lblTacGia.Visible = true; btnEdit.Visible = true; cboNgonNgu.Visible = false; txtTitle.Visible = false; txtTacGia.Visible = false; //imgView.Visible = true; //imgBrowse.Visible = false; _obj = setItem(_ID, lblUrlPath.Text, txtTitle.Text, Convert.ToInt32(cboNgonNgu.SelectedValue), txtTacGia.Text); _DAL.InsertT_Photo_Events(_obj); } else { txtTitle.Focus(); ScriptManager.RegisterStartupScript(this, GetType(), "myFunction", "alert('Bạn chưa nhập tiêu đề ảnh !');", true); } LoadData(status); } if (e.CommandArgument.ToString().ToLower() == "back") { if (txtTitle.Text.Trim().Length > 0) { btnSave.Visible = false; btnBack.Visible = false; btnModify.Visible = true; lblNgonNgu.Visible = true; lblTacGia.Visible = true; btnEdit.Visible = true; cboNgonNgu.Visible = false; txtTitle.Visible = false; txtTacGia.Visible = false; //imgView.Visible = true; //imgBrowse.Visible = false; } else { txtTitle.Focus(); ScriptManager.RegisterStartupScript(this, GetType(), "myFunction", "alert('Bạn chưa nhập tiêu đề ảnh !');", true); } } if (e.CommandArgument.ToString().ToLower() == "edit") { int tab = 0; //if (TabContainer1.ActiveTabIndex == 0) //tab = 0; int catID = Convert.ToInt32(this.grdListCate.DataKeys[e.Item.ItemIndex].ToString()); Response.Redirect("~/Anh24h/Edit_PhotoDexuat.aspx?Menu_ID=" + Page.Request["Menu_ID"].ToString() + "&ID=" + catID + "&Tab=" + tab); } }
protected void LinkDanganh_Click(object sender, EventArgs e) { //if (!Page.IsValid) return; #region SYNC T_Photo_EventDAL _untilDAL = new T_Photo_EventDAL(); if (!string.IsNullOrEmpty(txtTienNhuanBut.Text)) { try { int.Parse(txtTienNhuanBut.Text.Replace(",", "")); } catch { System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "Message", "alert('" + CommonLib.ReadXML("lblXacnhanTien") + "');", true); return; } } T_Photo_Event _Obj = GetObject(); int _return = 0; if (Request["id"] == null) { _return = _untilDAL.InsertT_Photo_Events(_Obj); _untilDAL.UpdateStatus_Photo_Events(Convert.ToDouble(_return.ToString()), 3, _user.UserID, DateTime.Now); } else { _return = _untilDAL.InsertT_Photo_Events(_Obj); _untilDAL.UpdateStatus_Photo_Events(_Obj.Photo_ID, 3, _user.UserID, DateTime.Now); } #endregion // DONG BO ANH try { SynFiles _syncfile = new SynFiles(); _Obj = _untilDAL.GetOneFromT_Photo_EventsByID(_return); if (_Obj.Photo_Medium.Length > 0) { _syncfile.SynData_UploadImgOne(_Obj.Photo_Medium, HPCComponents.Global.ImagesService); } } catch (Exception) { throw; } //END string _ActionsCode = "[Thời sự qua ảnh] [Duyệt ảnh] [Ảnh: " + _Obj.Photo_Name + "]"; WriteLogHistory2Database.WriteHistory2Database(_user.UserID, _user.UserFullName, "[Duyệt]", Convert.ToInt32(Request["Menu_ID"]), _ActionsCode, _return, ConstAction.TSAnh); if (Page.Request["Tab"].ToString() != "-1") { if (Page.Request["Menu_ID"] != null) { Page.Response.Redirect("~/Anh24h/List_PhotosChoDuyet.aspx?Menu_ID=" + this.Page.Request["Menu_ID"].ToString() + "&Tab=" + Page.Request["Tab"].ToString()); } else { return; } } else { if (Page.Request["Menu_ID"] != null) { Page.Response.Redirect("~/Anh24h/List_PhotosChoDuyet.aspx?Menu_ID=" + this.Page.Request["Menu_ID"].ToString()); } else { return; } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Expires = -1; try { HttpPostedFile postedFile = context.Request.Files["Filedata"]; string[] sArrProdID = null; char[] sep = { '?' }; string[] sArrVkey = null; string strUserID = ""; char[] sep2 = { ',' }; sArrProdID = context.Request.QueryString["user"].ToString().Trim().Split(sep); sArrVkey = sArrProdID[0].ToString().Trim().Split(sep2); string _urlSave = ""; string FolderCat = ""; string savepath = ""; string tempPath = ""; string strRootPathVirtual = ""; _user = _userDAL.GetUserByUserName(sArrVkey[0].ToString()); strUserID = _user.UserID.ToString(); string vType = sArrVkey[1].ToString(); string AlbumID = sArrVkey[2].ToString(); if (vType == "1") { FolderCat = "/Article/"; } else if (vType == "2") { FolderCat = "/Ads/"; } else if (vType == "3") { FolderCat = "/Video/"; } else if (vType == "4") { FolderCat = "/Photo24/"; } else { FolderCat = ""; } tempPath = System.Configuration.ConfigurationManager.AppSettings["UploadPathBDT"] + FolderCat + sArrVkey[0].ToString() + "/"; strRootPathVirtual = tempPath + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/"; savepath = context.Server.MapPath(strRootPathVirtual); string filename = DateTime.Now.Millisecond.ToString() + "_" + postedFile.FileName; string _extenfile = Path.GetExtension(filename.ToString().Trim()).Replace(".", ""); if (!Directory.Exists(savepath)) { Directory.CreateDirectory(savepath); } postedFile.SaveAs(savepath + @"\" + filename); string _logo = context.Server.MapPath("../Dungchung/Images/IconHPC/LoGoDongDau.png"); string _imagesEndWatermark = DateTime.Now.ToString("yyyyMMdd").ToString() + DateTime.Now.ToString("HHmmss") + DateTime.Now.Millisecond + UltilFunc.ReplaceCharsRewrite(filename.Replace(Path.GetExtension(filename.ToString().Trim()), "")) + "." + _extenfile; _urlSave = UrlPathImage_RemoveUpload(strRootPathVirtual + _imagesEndWatermark); // Begin BO CT EDIT Đóng dấu ảnh if (Convert.ToBoolean(Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["WatermarkImages"]))) { HPCImageResize.SaveImage2Server(savepath, filename, "rez_" + filename, _imagesEndWatermark, _logo, Convert.ToInt32(HPCComponents.Global.VNPResizeImages), Convert.ToInt32(HPCComponents.Global.VNPResizeImages)); } else// Không đóng dấu ảnh //END { HPCImageResize.SaveImage2Server(savepath, filename, _imagesEndWatermark, Convert.ToInt32(HPCComponents.Global.VNPResizeImages), Convert.ToInt32(HPCComponents.Global.VNPResizeImages)); } // INSERT DATABASE //phan insert co so du lieu T_ImageFiles _objImage = new T_ImageFiles(); ImageFilesDAL _DAL = new ImageFilesDAL(); _objImage = SetItemImageFiles(filename, postedFile.ContentLength, _urlSave, _extenfile, Convert.ToInt16(strUserID), Convert.ToInt16(vType), 0); int _idReturn = _DAL.InsertT_ImageFiles(_objImage); //phan insert Anh phong su T_Photo_EventDAL _cateDAL = new T_Photo_EventDAL(); T_Photo_Event _obj = new T_Photo_Event(); _obj = setItem(_urlSave, postedFile.FileName); int _return = _cateDAL.InsertT_Photo_Events(_obj); context.Response.Write(savepath + "/" + filename); context.Response.StatusCode = 200; } catch (Exception ex) { context.Response.Write("Error: " + ex.Message); } }