public static bool CheckPtDestination(int tl_id, int pid) { string Distination = DBTour.GetDistination(pid); SqlConnection con = new SqlConnection(); DBConnect db = new DBConnect(); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select count(*) from ParttimeLeaders where TourLeaderId = " + tl_id + " and (DistinationsOpted like '%," + Distination + ",%' OR DistinationsOpted like '%," + Distination + "' OR DistinationsOpted like '" + Distination + ",%' OR DistinationsOpted like '" + Distination + "')"; //cmd.CommandText = @"select count(*) from ParttimeLeaders where TourLeaderId = " + tl_id + " and DistinationsOpted like '%," + Distination + ",%' OR DistinationsOpted like '%," + Distination + "' OR DistinationsOpted like '" + Distination + ,"%'"; db.SetData(cmd); DataTable tbl = db.GetData(cmd); if (Convert.ToInt32(tbl.Rows[0][0]) > 0) { return(true); } return(false); }
public static bool CheckLeader(int tid, int tl_id) { bool Isok = true; List <Tour> tours = new List <Tour>(); tours = DBTour.GetTourListByLeaderId(tl_id); Tour newtour = new Tour(); newtour = DBTour.GetTourDetailsById(tid); DateTime NewStartDate = Convert.ToDateTime(newtour.StartDate); DateTime NewEndDate = Convert.ToDateTime(newtour.EndDate); if (tours.Count() != 0) { foreach (Tour t in tours.Where(x => x.TourId != tid)) { DateTime OldStartDate = Convert.ToDateTime(t.StartDate); DateTime OldEndDate = Convert.ToDateTime(t.EndDate); //if (NewStartDate == OldStartDate) //{ // Isok = false; // break; //} //else if (NewStartDate >= OldStartDate && NewStartDate <= OldEndDate) { Isok = false; break; } else if (NewEndDate >= OldStartDate && NewEndDate <= OldEndDate) //just in case { Isok = false; break; } } } return(Isok); }