public string AddAdImageDetails(AdImageDetails adimageDetails) { try { /*string[] strImg = new string[5]; HttpPostedFile postedFile = strImg[0] as HttpPostedFile; strImg = adimageDetails.ImagePath.Split(':'); string path = string.Empty; string strImgFinalPath = ""; string finalPath = string.Empty; string filePath = string.Empty; int userId = 0;// Convert.ToInt32(Session["UserId"].ToString()); string sFilename = ""; if (FileUpload1.PostedFile != null) { HttpPostedFile myFile = FileUpload1.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { DirectoryInfo dirInfo = null; fileSavePath = "/Data/TS_" + userId + "/Images/"; path = Server.MapPath("~" + fileSavePath); if (!Directory.Exists(path)) { dirInfo = Directory.CreateDirectory(path); } sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload1.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); } } strImgFinalPath = finalPath; if (FileUpload2.PostedFile != null) { HttpPostedFile myFile = FileUpload2.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload2.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } } if (FileUpload3.PostedFile != null) { HttpPostedFile myFile = FileUpload3.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload3.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } } if (FileUpload4.PostedFile != null) { HttpPostedFile myFile = FileUpload4.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload4.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } } if (FileUpload5.PostedFile != null) { HttpPostedFile myFile = FileUpload5.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload5.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } }*/ DALComponent objDAL = new DALComponent(); objDAL.SetParameters("@imageId", SqlDbType.Int, 4, adimageDetails.ImageId); objDAL.SetParameters("@adpostId", SqlDbType.Int, 4, adimageDetails.AdPostId); objDAL.SetParameters("@imagePath", SqlDbType.VarChar, 1000, adimageDetails.ImagePath); objDAL.SetParameters("@videoLink", SqlDbType.VarChar, 1000, adimageDetails.VideoLink); objDAL.SetParameters("@idvalue", SqlDbType.Int, true); objDAL.SqlCommandText = "CreateAdImageDetails"; int x = objDAL.CreateRecord(); object y = objDAL.GetParameters("@idvalue"); return y.ToString(); } catch (SqlException sqlEx) { return sqlEx.Message.ToString(); } catch (Exception ex) { return ex.Message.ToString(); } }
public void UpdateAdImagePath(AdImageDetails adImagDetails) { try { objDALComponent.SetParameters("@imageid", SqlDbType.Int, 4, adImagDetails.ImageId); objDALComponent.SetParameters("@imagepath", SqlDbType.VarChar, 1000, adImagDetails.ImagePath); objDALComponent.SqlCommandText = "UpdateImagePath"; int x = objDALComponent.DeleteRecord(); } catch (SqlException sqlEx) { throw new ApplicationException("Data error=" + sqlEx.Message.ToString()); } catch (Exception ex) { throw new ApplicationException("Error=" + ex.Message.ToString()); } }