public void deactivateTruckHandlings(int truckHandlingID, string active) { TruckHandlings t = new TruckHandlings(); t.TruckHandlingID = truckHandlingID; t.deactivateTruckHandlings(active); }
public List <TruckHandlings> getTruckLicenses(bool active) { #region DB functions string query = "select * from TruckHandlings th inner join TruckHandlingTypes tht on th.TruckHandlingTypeID=tht.TruckHandlingTypeID inner join Trucks t on th.TruckID=t.TruckID where 1=1"; if (active) { query += " and th.Active = 'Y'"; } List <TruckHandlings> list = new List <TruckHandlings>(); DbService db = new DbService(); DataSet ds = db.GetDataSetByQuery(query); foreach (DataRow dr in ds.Tables[0].Rows) { TruckHandlings tmp = new TruckHandlings(); tmp.TruckHandlingID = (int)dr["TruckHandlingID"]; tmp.TruckHandlingDescription = dr["TruckHandlingDescription"].ToString(); tmp.HandlingProvider = dr["HandlingProvider"].ToString(); tmp.Active = dr["Active"].ToString(); //tmp.Url = dr["Url"].ToString(); tmp.Cost = float.Parse(dr["Cost"].ToString()); tmp.Date = (DateTime)dr["Date"]; tmp.TruckHandlingType = new TruckHandlingTypes((int)dr["TruckHandlingTypeID"], dr["TruckHandlingType"].ToString()); tmp.Truck = new Trucks(); tmp.Truck.TruckID = (int)dr["TruckID"]; tmp.Truck.TruckLicense = (int)dr["TruckLicense"]; list.Add(tmp); } #endregion return(list); }
public TruckHandlings getTruckHandling() { #region DB functions string query = "select * from TruckHandlings th inner join TruckHandlingTypes tht on th.TruckHandlingTypeID=tht.TruckHandlingTypeID inner join Trucks t on th.TruckID=t.TruckID where th.TruckHandlingID =" + TruckHandlingID; TruckHandlings t = new TruckHandlings(); DbService db = new DbService(); DataSet ds = db.GetDataSetByQuery(query); foreach (DataRow dr in ds.Tables[0].Rows) { t.TruckHandlingID = (int)dr["TruckHandlingID"]; t.TruckHandlingDescription = dr["TruckHandlingDescription"].ToString(); t.HandlingProvider = dr["HandlingProvider"].ToString(); t.Active = dr["Active"].ToString(); if (dr["HasImg"].ToString() == "Y") { t.ImgID = (int)dr["ImgID"]; } t.Cost = float.Parse(dr["Cost"].ToString()); t.Date = (DateTime)dr["Date"]; t.TruckHandlingType = new TruckHandlingTypes((int)dr["TruckHandlingTypeID"], dr["TruckHandlingType"].ToString()); t.Truck = new Trucks(); t.Truck.TruckID = (int)dr["TruckID"]; t.Truck.TruckLicense = (int)dr["TruckLicense"]; } #endregion return(t); }
public string getTruckLicenses(bool active) { JavaScriptSerializer j = new JavaScriptSerializer(); TruckHandlings t = new TruckHandlings(); List <TruckHandlings> trucksHandlingsList = t.getTruckLicenses(active); return(j.Serialize(trucksHandlingsList)); }
public string getTruckHandlingsPeriod(bool active, int selectedTruckID, int func) { JavaScriptSerializer j = new JavaScriptSerializer(); TruckHandlings t = new TruckHandlings(); List <TruckHandlings> trucksHandlingsList = t.getTruckHandlingsPeriodList(active, selectedTruckID, func); return(j.Serialize(trucksHandlingsList)); }
public string getTruckHandling(int truckHandlingID) { JavaScriptSerializer j = new JavaScriptSerializer(); TruckHandlings t = new TruckHandlings(); t.TruckHandlingID = truckHandlingID; TruckHandlings truckHandling = t.getTruckHandling(); return(j.Serialize(truckHandling)); }
public List <TruckHandlings> getTruckHandlingsList(bool active, int selectedTruckID, DateTime startDate, DateTime endDate) { #region DB functions string sqlStartDate = startDate.ToString("yyyy-MM-dd"); string sqlEndDate = endDate.ToString("yyyy-MM-dd"); string query = "select * from TruckHandlings th inner join TruckHandlingTypes tht on th.TruckHandlingTypeID=tht.TruckHandlingTypeID inner join Trucks t on th.TruckID=t.TruckID where 1=1"; if (active) { query += " and th.Active = 'Y'"; } if (selectedTruckID != -1) { query += " and th.TruckID =" + selectedTruckID; } if (startDate.Year != 1) { query += " and th.Date >= '" + sqlStartDate + "'"; if (endDate.Year != 1) { query += " and th.Date <= '" + sqlEndDate + "'"; } } query += " order by th.Date desc"; List <TruckHandlings> list = new List <TruckHandlings>(); DbService db = new DbService(); DataSet ds = db.GetDataSetByQuery(query); foreach (DataRow dr in ds.Tables[0].Rows) { TruckHandlings tmp = new TruckHandlings(); tmp.TruckHandlingID = (int)dr["TruckHandlingID"]; tmp.TruckHandlingDescription = dr["TruckHandlingDescription"].ToString(); tmp.HandlingProvider = dr["HandlingProvider"].ToString(); tmp.Active = dr["Active"].ToString(); if (dr["HasImg"].ToString() == "Y") { try { tmp.ImgID = (int)dr["ImgID"]; } catch { tmp.ImgID = 0; } } tmp.Cost = float.Parse(dr["Cost"].ToString()); tmp.Date = (DateTime)dr["Date"]; tmp.TruckHandlingType = new TruckHandlingTypes((int)dr["TruckHandlingTypeID"], dr["TruckHandlingType"].ToString()); tmp.Truck = new Trucks(); tmp.Truck.TruckID = (int)dr["TruckID"]; tmp.Truck.TruckLicense = (int)dr["TruckLicense"]; list.Add(tmp); } #endregion return(list); }
public void setTruckHandling(int truckHandlingID, string truckHandlingDescription, string handlingProvider, string url, float cost, string date, int truckHandlingTypeID, int truckID, string func) { DateTime dt; if (date.Contains(".") || date.Contains("-")) { dt = DateTime.Parse(date); } else { dt = DateTime.ParseExact(date, "dd/MM/yyyy", CultureInfo.InvariantCulture); } TruckHandlings t = new TruckHandlings(truckHandlingID, truckHandlingDescription, handlingProvider, url, cost, dt, new TruckHandlingTypes(truckHandlingTypeID, ""), new Trucks(truckID)); t.setTruckHandling(func); }
public string getTruckHandlings(bool active, int selectedTruckID, string startDate, string endDate) { if (startDate == "") { startDate = "01/01/1990"; } if (endDate == "") { endDate = "01/01/2990"; } DateTime sdt = DateTime.ParseExact(startDate, "dd/MM/yyyy", null); DateTime edt = DateTime.ParseExact(endDate, "dd/MM/yyyy", null); JavaScriptSerializer j = new JavaScriptSerializer(); TruckHandlings t = new TruckHandlings(); List <TruckHandlings> trucksHandlingsList = t.getTruckHandlingsList(active, selectedTruckID, sdt, edt); return(j.Serialize(trucksHandlingsList)); }
public List <TruckHandlings> getTruckHandlingsPeriodList(bool active, int selectedTruckID, int func) { #region DB functions string query = "select * from TruckHandlings th inner join TruckHandlingTypes tht on th.TruckHandlingTypeID=tht.TruckHandlingTypeID inner join Trucks t on th.TruckID=t.TruckID where 1=1"; if (active) { query += " and th.Active = 'Y'"; } if (selectedTruckID != -1) { query += " and th.TruckID =" + selectedTruckID; } #region selecting Period if (func == 1) { query += " and th.Date >= convert(date, GETDATE())" + " order by th.Date asc"; } if (func == 2) { query += " and th.Date < DATEADD(mm, DATEDIFF(mm, 0, GETDATE()) +1, 0) and th.Date >= DATEADD(mm, DATEDIFF(mm, 0, GETDATE()) -0, 0)" + " order by th.Date asc"; } if (func == 3) { query += " and th.Date <= convert(date, GETDATE())" + " order by th.Date desc"; } #endregion List <TruckHandlings> list = new List <TruckHandlings>(); DbService db = new DbService(); DataSet ds = db.GetDataSetByQuery(query); foreach (DataRow dr in ds.Tables[0].Rows) { TruckHandlings tmp = new TruckHandlings(); tmp.TruckHandlingID = (int)dr["TruckHandlingID"]; tmp.TruckHandlingDescription = dr["TruckHandlingDescription"].ToString(); tmp.HandlingProvider = dr["HandlingProvider"].ToString(); tmp.Active = dr["Active"].ToString(); if (dr["HasImg"].ToString() == "Y") { tmp.ImgID = (int)dr["ImgID"]; } tmp.Cost = float.Parse(dr["Cost"].ToString()); tmp.Date = (DateTime)dr["Date"]; tmp.TruckHandlingType = new TruckHandlingTypes((int)dr["TruckHandlingTypeID"], dr["TruckHandlingType"].ToString()); tmp.Truck = new Trucks(); tmp.Truck.TruckID = (int)dr["TruckID"]; tmp.Truck.TruckLicense = (int)dr["TruckLicense"]; list.Add(tmp); } #endregion return(list); }