Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["username"] == null)
        {
            Response.Redirect("Login.aspx");
        }

        var name = Session["username"];

        id_user = (from user in db.Users where user.username == name.ToString() select user.id).FirstOrDefault();
        var data_logged_work = (from log in db.Logs where log.id_user == id_user select log).ToList();

        foreach (var dlw in data_logged_work)
        {
            var proj = (from project in db.Projects where project.id == dlw.id_project select project.name).FirstOrDefault();
            data.Add(dlw, proj);
        }
        SqlDataSourcePontajeleMele.SelectParameters.Clear();
        var usr = Session["id_user"].ToString();

        SqlDataSourcePontajeleMele.SelectParameters.Add("usr", usr);
        SqlDataSourcePontajeleMele.SelectCommand = "SELECT * FROM [Logs] where [id_user]=@usr order by [date] desc";
        SqlDataSourcePontajeleMele.DataBind();
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["username"] == null)
        {
            Response.Redirect("Login.aspx");
        }

        if (DropDownList1.Items.Count == 0)
        {
            var car = (from c in db.Cars select c).ToList();
            foreach (var c in car)
            {
                ListItem element = new ListItem(c.number, c.id.ToString());
                DropDownList1.Items.Add(element);
            }
            DropDownList1.Items.Add(new ListItem("Mașină proprie", ""));
        }


        if (DropDownList2.Items.Count == 0)
        {
            var category = (from c in db.ProjectCategories select c).ToList();
            foreach (var c in category)
            {
                ListItem element = new ListItem(c.name, c.id.ToString());
                DropDownList2.Items.Add(element);
            }
            DropDownList2.DataBind();
        }
        if (!((Page)System.Web.HttpContext.Current.CurrentHandler).IsPostBack)
        {
            var category_selected = Int32.Parse(DropDownList2.SelectedItem.Value);
            if (DropDownList3.Items.Count == 0)
            {
                var project = (from p in db.Projects where p.id_category == category_selected select p).ToList();
                foreach (var p in project)
                {
                    ListItem element = new ListItem(p.name, p.id.ToString());
                    DropDownList3.Items.Add(element);
                }
            }
            DropDownList3.DataBind();
        }

        DropDownListPassengerInitialisation(DropDownListPass1);
        DropDownListPassengerInitialisation(DropDownListPass2);
        DropDownListPassengerInitialisation(DropDownListPass3);
        DropDownListPassengerInitialisation(DropDownListPass4);

        var name = Session["username"];

        id_user = (from user in db.Users where user.username == name.ToString() select user.id).FirstOrDefault();
        var data_logged_work = (from log in db.Log_driver where log.id_user == id_user select log).ToList();

        foreach (var dlw in data_logged_work)
        {
            var proj = (from project in db.Projects where project.id == dlw.id_project select project.name).FirstOrDefault();
            data.Add(dlw, proj);
        }
        SqlDataSourcePontajeleMele.SelectParameters.Clear();
        var usr = Session["id_user"].ToString();

        SqlDataSourcePontajeleMele.SelectParameters.Add("usr", usr);
        SqlDataSourcePontajeleMele.SelectCommand = "SELECT * FROM [Log_driver] where [id_user]=@usr order by [date] desc";
        SqlDataSourcePontajeleMele.DataBind();
    }