Example #1
0
    public void deactivateDriverConstraints(int driverConstraintID, string active)
    {
        DriverConstraints dc = new DriverConstraints();

        dc.DriverConstraintID = driverConstraintID;
        dc.deactivateDriverConstraints(active);
    }
Example #2
0
    public void setDriverConstraint(int driverConstraintID, string startdate, string enddate, int driverID, string comments, string func)
    {
        DateTime dtStart;
        DateTime dtFinish;

        if (startdate.Contains("."))
        {
            dtStart = DateTime.Parse(startdate);
        }
        else
        {
            dtStart = DateTime.ParseExact(startdate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
        }
        if (enddate.Contains("."))
        {
            dtFinish = DateTime.Parse(enddate);
        }
        else
        {
            dtFinish = DateTime.ParseExact(enddate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
        }

        DateTime dt = dtStart;

        while (dt <= dtFinish)
        {
            Drivers tmp = new Drivers();
            Drivers d   = new Drivers();
            tmp.DriverID = driverID;
            d            = tmp.getDriver();
            DriverConstraints dc = new DriverConstraints(driverConstraintID, dt, d, comments);
            dc.setDriverConstraint(func);
            dt = dt.AddDays(1);
        }
    }
Example #3
0
    public List <DriverConstraints> getDriverConstraintsListForView(bool active, int selectedDriver, DateTime startDate, DateTime endDate)
    {
        #region DB functions
        ////DateTime dt = DateTime.ParseExact(date, "dd/MM/yyyy", null);
        string sqlStartDate = startDate.ToString("yyyy-MM-dd");
        string sqlEndtDate  = endDate.ToString("yyyy-MM-dd");

        string query = "select c.DriverConstraintID, c.Date, d.FirstName, d.LastName, c.Comments, c.Active from DriverConstraints c inner join Drivers d on c.DriverID = d.DriverID where 1=1";
        if (active)
        {
            query += " and c.Active = 'Y'";
        }
        if (selectedDriver != -1)
        {
            query += " and d.DriverID =" + selectedDriver;
        }
        if (startDate.Year != 1)
        {
            query += " and c.Date >= '" + sqlStartDate + "'";
            if (endDate.Year != 1)
            {
                query += " and c.Date <= '" + sqlEndtDate + "'";
            }
        }

        List <DriverConstraints> list = new List <DriverConstraints>();
        DbService db = new DbService();
        DataSet   ds = db.GetDataSetByQuery(query);

        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            DriverConstraints tmp = new DriverConstraints();
            tmp.DriverConstraintID = (int)dr["DriverConstraintID"];
            tmp.Date = (DateTime)dr["Date"];
            Drivers d = new Drivers();
            d.FirstName  = dr["FirstName"].ToString();
            d.LastName   = dr["LastName"].ToString();
            tmp.Driver   = d;
            tmp.Comments = dr["Comments"].ToString();
            tmp.Active   = dr["Active"].ToString();

            list.Add(tmp);
        }
        #endregion
        return(list);
    }
Example #4
0
    public string getDriverConstraintsView(bool active, int selectedDrivers, string startDate, string endDate)
    {
        if (startDate == "")
        {
            startDate = "01/01/1990";
        }
        if (endDate == "")
        {
            endDate = "01/01/2990";
        }
        DateTime startDatedt = DateTime.ParseExact(startDate, "dd/MM/yyyy", null);
        DateTime endDatedt   = DateTime.ParseExact(endDate, "dd/MM/yyyy", null);


        JavaScriptSerializer     j  = new JavaScriptSerializer();
        DriverConstraints        dc = new DriverConstraints();
        List <DriverConstraints> driverConstraintsList = dc.getDriverConstraintsListForView(active, selectedDrivers, startDatedt, endDatedt);

        return(j.Serialize(driverConstraintsList));
    }