public void dgrListAppro_UpdateCommand(object source, DataGridCommandEventArgs e) { T_Anh objimage = new T_Anh(); AnhDAL _DAL = new AnhDAL(); int _ID = Convert.ToInt32(dgrListAppro.DataKeys[e.Item.ItemIndex].ToString()); TextBox txtTieude = e.Item.FindControl("txtTieude") as TextBox; TextBox txtChuthich = e.Item.FindControl("txtChuthich") as TextBox; TextBox txtTacgia = e.Item.FindControl("txtTacgia") as TextBox; string _tieude = ""; string _chuthich = ""; string _tacgia = ""; int _tacgiaID = 0; if (txtTieude != null) { if (!String.IsNullOrEmpty(txtTieude.Text.Trim())) { _tieude = txtTieude.Text.Trim(); } } if (txtChuthich != null) { if (!String.IsNullOrEmpty(txtChuthich.Text.Trim())) { _chuthich = txtChuthich.Text.Trim(); } } if (txtTacgia != null) { if (!String.IsNullOrEmpty(txtTacgia.Text.Trim())) { _tacgia = txtTacgia.Text; _tacgiaID = Convert.ToInt32(UltilFunc.GetTacgiaID(_tacgia).ToString()); } } objimage.Ma_Anh = _ID; objimage.TieuDe = _tieude; objimage.Chuthich = _chuthich; objimage.NguoiChup = _tacgia; objimage.Ma_Nguoichup = _tacgiaID; _DAL.InsertUpdateT_Anh(objimage); //_DAL.UpdateinfoT_Anh("TieuDe=N'" + _tieude + "',Chuthich=N'" + _chuthich + "',NguoiChup=N'" + _tacgia + "',Ma_Nguoichup=" + _tacgiaID + " WHERE Ma_Anh=" + _ID); dgrListAppro_CancelCommand(source, e); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Write("Hello World"); try { 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); user = DAL.GetUserByUserName(sArrVkey[0].ToString()); strUserID = user.UserID.ToString(); int matinbai = 0; if (sArrVkey[1].ToString() != "") { matinbai = int.Parse(sArrVkey[1].ToString()); } HttpPostedFile postedFile = context.Request.Files["Filedata"]; string tempPath = System.Configuration.ConfigurationManager.AppSettings["UploadPath"].ToString() + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/"; //Create forder CreateFolderByUserName(tempPath); string savepath = context.Server.MapPath("/" + tempPath); string filename = postedFile.FileName; string[] sArrTenfile = null; char[] cat = { '.' }; sArrTenfile = filename.ToString().Trim().Split(cat); string _extenfile = GetDateTimeStringUnique() + "." + sArrTenfile[1].ToString(); string _tenfilegoc = UltilFunc.RemoveSign4VietnameseString(Path.GetFileNameWithoutExtension(filename)) + "." + _extenfile.ToString(); _tenfilegoc = _tenfilegoc.Replace(" ", ""); postedFile.SaveAs(savepath + @"\" + _tenfilegoc); int startchar = tempPath.Substring(1, tempPath.Length - 1).IndexOf("/"); startchar += 1; string _PathFile = tempPath.Substring(startchar, tempPath.Length - startchar); string _savePath = _PathFile + "" + _tenfilegoc; AnhDAL _DAL = new AnhDAL(); T_Anh _obj = new T_Anh(); _obj = SetItem(_savePath, _tenfilegoc, _tenfilegoc); int _MaAnhReturn = _DAL.InsertUpdateT_Anh(_obj); if (matinbai > 0 && _MaAnhReturn > 0) { TinBaiAnhDAL _daltinanh = new TinBaiAnhDAL(); T_Tinbai_Anh _objTA = new T_Tinbai_Anh(); _objTA.ID = 0; _objTA.Ma_Anh = _MaAnhReturn; _objTA.Ma_TinBai = matinbai; _objTA.ChuThich = ""; _daltinanh.InsertUpdateTin_Anh(_objTA); } context.Response.Write(tempPath + "/" + filename); context.Response.StatusCode = 200; } catch (Exception ex) { context.Response.Write("Error: " + ex.Message); } }