public ActionResult _DeleteEvent(int id) { PictureRepository picRep = new PictureRepository(); Event ins = EventRep.GetEvent(id); if (ins.PictureId != 0) { //...Get Picture... Picture pic = picRep.GetPicture(ins.PictureId); string path = pic.PicUrl.Substring(pic.PicUrl.IndexOf("/Images/") + 8); path = path.Replace('/', '\\'); var finalpath = Path.Combine(Server.MapPath("~/Images"), path); System.IO.File.Delete(finalpath); bool picrem = picRep.RemovePicture(ins.PictureId); } bool ins2 = EventRep.RemoveEvent(id); //...Notify... string regIds = AppRep.GetAllRegIds(Convert.ToInt32(HttpContext.Session["ClientId"])); if (!regIds.Equals("")) { comrep.NewUpdateData(regIds, "CMD_DELEVENT", id.ToString()); } //...Repopulate Grid... List<Event> lst = new List<Event>(); lst = EventRep.GetListEvent(Convert.ToInt32(HttpContext.Session["ClientId"])); return View(new GridModel(lst)); }
public List<Schoolsc> GetListSchools(int ClientId) { List<Schoolsc> list = new List<Schoolsc>(); Schoolsc ins; //...Database Connection... DataBaseConnection dbConn = new DataBaseConnection(); SqlConnection con = dbConn.SqlConn(); SqlCommand cmdI; //...SQL Commands... cmdI = new SqlCommand("SELECT * from Schools WHERE ClientId = " + ClientId + " ORDER BY SchoolId DESC", con); cmdI.Connection.Open(); SqlDataReader drI = cmdI.ExecuteReader(); //...Retrieve Data... if (drI.HasRows) { while (drI.Read()) { ins = new Schoolsc(); ins.SchoolId = Convert.ToInt32(drI["SchoolId"]); ins.ClientId = Convert.ToInt32(drI["ClientId"]); ins.SchoolName = drI["SchoolName"].ToString(); ins.Schoolabbreviation = drI["Schoolabbreviation"].ToString(); ins.PictureId = Convert.ToInt32(drI["PictureId"]); list.Add(ins); } } drI.Close(); con.Close(); PictureRepository picRep = new PictureRepository(); foreach (Schoolsc item in list) { if (item.PictureId != 0) { item.PicUrl = picRep.GetPicture(item.PictureId).PicUrl; /*if (item.PicUrl.Contains("\\Images\\")) { string path = item.PicUrl.Substring(item.PicUrl.IndexOf("\\Images\\")); path = path.Replace('\\', '/'); item.PicUrl = "http://www.netintercom.co.za" + path; }*/ } } return list; }
public List<News> GetListNews(int ClientId) { List<News> list = new List<News>(); News ins; //...Database Connection... DataBaseConnection dbConn = new DataBaseConnection(); SqlConnection con = dbConn.SqlConn(); SqlCommand cmdI; //...SQL Commands... cmdI = new SqlCommand("SELECT * FROM News WHERE ClientId = " + ClientId + " ORDER BY NewsId DESC", con); cmdI.Connection.Open(); SqlDataReader drI = cmdI.ExecuteReader(); //...Retrieve Data... if (drI.HasRows) { while (drI.Read()) { ins = new News(); ins.NewsId = Convert.ToInt32(drI["NewsId"]); ins.ClientId = Convert.ToInt32(drI["ClientId"]); ins.CategoryId = Convert.ToInt32(drI["CategoryId"]); ins.SubCategoryId = Convert.ToInt32(drI["SubCategoryId"]); ins.PictureId = Convert.ToInt32(drI["PictureId"]); ins.Title = drI["Title"].ToString(); ins.Body = drI["Body"].ToString(); ins.PostDate = Convert.ToDateTime(drI["PostDate"]); list.Add(ins); } } drI.Close(); con.Close(); PictureRepository picRep = new PictureRepository(); foreach(News item in list) { if (item.PictureId != 0) { item.PicUrl = picRep.GetPicture(item.PictureId).PicUrl; /*if (item.PicUrl.Contains("\\Images\\")) { string path = item.PicUrl.Substring(item.PicUrl.IndexOf("\\Images\\")); path = path.Replace('\\', '/'); item.PicUrl = "http://www.netintercom.co.za" + path; }*/ } } return list; }
public List<Teams> GetListTeams(int ClientId) { List<Teams> list = new List<Teams>(); Teams ins; //...Database Connection... DataBaseConnection dbConn = new DataBaseConnection(); SqlConnection con = dbConn.SqlConn(); SqlCommand cmdI; //...SQL Commands... cmdI = new SqlCommand("SELECT t.*,sc.CategoryName,sch.* FROM Teams t inner join SportCategory sc on t.SportCategoryID = sc.SportCategoryId inner join Schools sch on t.SchoolId =sch.SchoolId WHERE t.ClientId = " + ClientId + " ORDER BY t.TeamsId DESC", con); cmdI.Connection.Open(); SqlDataReader drI = cmdI.ExecuteReader(); //...Retrieve Data... if (drI.HasRows) { while (drI.Read()) { ins = new Teams(); ins.TeamsId = Convert.ToInt32(drI["TeamsId"]); ins.ClientId = Convert.ToInt32(drI["ClientId"]); ins.Name = drI["Schoolabbreviation"].ToString(); ins.Age = drI["Age"].ToString(); ins.Ranks = drI["Ranks"].ToString(); ins.SportCategoryID = Convert.ToInt32(drI["SportCategoryID"]); ins.sportcategory = drI["CategoryName"].ToString(); ins.SchoolId = Convert.ToInt32(drI["SchoolId"]); ins.schoolname = drI["SchoolName"].ToString(); ins.PictureId = Convert.ToInt32(drI["PictureId"]); list.Add(ins); } } drI.Close(); con.Close(); PictureRepository picRep = new PictureRepository(); foreach (Teams item in list) { if (item.PictureId != 0) { item.PicUrl = picRep.GetPicture(item.PictureId).PicUrl; /*if (item.PicUrl.Contains("\\Images\\")) { string path = item.PicUrl.Substring(item.PicUrl.IndexOf("\\Images\\")); path = path.Replace('\\', '/'); item.PicUrl = "http://www.netintercom.co.za" + path; }*/ } } return list; }