示例#1
0
    protected void Remove(object sender, EventArgs e)
    {
        int    ttid = Convert.ToInt32(Session["ttid"].ToString());
        Button btn  = (Button)sender;

        string[] arguments = btn.CommandArgument.ToString().Split(new char[] { ',' });
        int      carid     = Convert.ToInt32(arguments[0]);
        string   parkingid = arguments[1];
        string   name      = arguments[2];
        int      parking   = Convert.ToInt32(parkingid);

        if (parking == 0)
        {
            Response.Write("there is no car");
        }
        else if (name == "Public lane")
        {
            User tempUser = new User();
            tempUser.pick_from_public(ttid, parking);
        }

        else
        {
            user_parking_view u = new user_parking_view();
            // u.remove(ttid, carid);
        }
        //  GridView2.DataSource = new user_parking_view().ShowMyCarsParking(ttid);
        GridView2.DataBind();
    }
示例#2
0
    public List <user_parking_view> GetUsersOnMyParking(int id)
    {
        Connect connect;

        Connect.ConnectPark();
        string q = "select user_parking.parking_id,garage.user_id,user.username from user_parking inner join garage on garage.parking_id = user_parking.parking_id inner join user on user.ttid = garage.user_id where user_parking.user_id = @id";

        string[] s2 = { "@id" };
        connect = new Connect(q, s2, id);

        List <user_parking_view> lst_user = new List <user_parking_view>();

        index = 0;
        foreach (DataRow row in connect.ds.Tables[0].Rows)
        {
            user_parking_view user = new user_parking_view();
            user.userid     = Convert.ToInt32(row[1]);
            user.username   = row[2].ToString();
            user.parking_id = Convert.ToInt32(row[0]);
            // user.index = index;
            lst_user.Add(user);
        }

        return(lst_user);
    }
示例#3
0
    protected void Unnamed_Click1(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(((Button)sender).CommandArgument);

        var lst = new user_parking_view().MyCarsParked(Convert.ToInt32(Session["ttid"]));

        if (lst.Count == 0)
        {
            return;
        }
        user_parking_view parking = lst.Find(m => m.carid == id);

        if (parking.username != "Public lane")
        {
            int logid = new User().RemoveParkedCar(Convert.ToInt32(Session["ttid"]), id);
        }
        else
        {
            new User().pick_from_public(Convert.ToInt32(Session["ttid"]), parking.parking_id);
        }

        money.InnerText = "";
        money.InnerText = money.InnerText + new User().GetCashWithUser(Convert.ToInt32(Session["ttid"]));
        grid_view_parked_cars.DataSource = new user_parking_view().MyCarsParked(Convert.ToInt32(Session["ttid"]));
        grid_view_parked_cars.DataBind();
    }
示例#4
0
    public List <user_parking_view> MyCarsParked(int ttid)
    {
        Connect connect;

        Connect.ConnectPark();
        string insert2 = "Select car_id from garage where user_id=@id && status=0 && parking_id !=0";

        string[] s2 = { "@id" };
        connect = new Connect(insert2, s2, ttid);

        List <user_parking_view> lst_user = new List <user_parking_view>();

        index = 0;
        foreach (DataRow row in connect.ds.Tables[0].Rows)
        {
            index = index + 1;
            user_parking_view user = new user_parking_view();
            int      carid         = Convert.ToInt32(row["car_id"]);
            string   insert3       = "Select parking_id from garage where car_id=@carid && user_id=@user && status=0";
            string[] s3            = { "@carid", "@user" };
            connect = new Connect(insert3, s3, carid, ttid);
            int parkingid1 = Convert.ToInt32(connect.executescalar());

            string   insert4 = "Select user_id from user_parking where parking_id=@p_id";
            string[] s4      = { "@p_id" };
            connect = new Connect(insert4, s4, parkingid1);
            if (connect.ds.Tables[0].Rows.Count > 0)
            {
                user.userid = Convert.ToInt32(connect.ds.Tables[0].Rows[0][0]);
            }

            string   query = "select private from parking where Id=@id";
            string[] q     = { "@id" };
            connect = new Connect(query, q, parkingid1);
            bool public1 = Convert.ToBoolean(connect.ds.Tables[0].Rows[0][0]);

            string   insert5 = "Select username from user where ttid=@tid";
            string[] s5      = { "@tid" };
            connect = new Connect(insert5, s5, user.userid);
            if (parkingid1 == 0)
            {
            }
            else
            if (public1 == false)
            {
                user.username = "******";
            }
            else
            {
                user.username = Convert.ToString(connect.ds.Tables[0].Rows[0][0]);
            }
            user.index      = index;
            user.carid      = carid;
            user.parking_id = parkingid1;

            lst_user.Add(user);
        }

        return(lst_user);
    }
示例#5
0
    protected void Unnamed_Click1(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(((Button)sender).CommandArgument);

        var lst = new user_parking_view().MyCarsParked(Convert.ToInt32(Session["ttid"]));
        user_parking_view parking = lst.Find(m => m.carid == id);

        if (parking.username != "Public lane")
        {
            int logid = new User().RemoveParkedCar(Convert.ToInt32(Session["ttid"]), id);
        }
        else
        {
            new User().pick_from_public(Convert.ToInt32(Session["ttid"]), parking.parking_id);
        }

        grid_previous.DataSource = new ParkingLog().GetLogs(Convert.ToInt32(Session["ttid"]));
        grid_previous.DataBind();
        money.InnerText = "";
        money.InnerText = money.InnerText + new User().GetCashWithUser(Convert.ToInt32(Session["ttid"]));
        grid_view_parked_cars.DataSource = new user_parking_view().MyCarsParked(Convert.ToInt32(Session["ttid"]));
        grid_view_parked_cars.DataBind();
        var i = new Cars().GetCarsOwnedByUser(Convert.ToInt32(Session["ttid"]));

        d.DataSource = i;
        d.DataBind();
        a.DataSource = i;
        a.DataBind();

        GridView2.DataSource = new user_parking_view().GetUsersOnMyParking(Convert.ToInt32(Session["ttid"]));
        GridView2.DataBind();
    }
示例#6
0
    protected void btn_fine_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(((ImageButton)sender).CommandArgument);

        var i = new user_parking_view().GetUsersOnMyParking(Convert.ToInt32(Session["ttid"]));

        var u = i.Find(l => l.parking_id == id);

        new fine().Finebyuser(Convert.ToInt32(Session["ttid"]), id, u.userid);
        money.InnerText      = "";
        money.InnerText      = money.InnerText + new User().GetCashWithUser(Convert.ToInt32(Session["ttid"]));
        GridView2.DataSource = new user_parking_view().GetUsersOnMyParking(Convert.ToInt32(Session["ttid"]));
        GridView2.DataBind();
    }
示例#7
0
    protected void btn_fine_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(((Button)sender).CommandArgument);
        // GridViewRow row = GridView2.SelectedRow;
        //Label l = (Label)row.FindControl("lbl_car_owner_id");
        var i = new user_parking_view().GetUsersOnMyParking(Convert.ToInt32(Session["ttid"]));
        var u = i.Find(l => l.parking_id == id);

        new fine().Finebyuser(Convert.ToInt32(Session["ttid"]), id, u.userid);
        money.InnerText      = "";
        money.InnerText      = money.InnerText + new User().GetCashWithUser(Convert.ToInt32(Session["ttid"]));
        GridView2.DataSource = new user_parking_view().GetUsersOnMyParking(Convert.ToInt32(Session["ttid"]));
        GridView2.DataBind();
    }
示例#8
0
    public List <user_parking_view> GetUsersOnMyParking(int id)
    {
        Connect connect;

        Connect.ConnectPark();
        string insert2 = "Select parking_id from user_parking where user_id=@id";

        string[] s2 = { "@id" };
        connect = new Connect(insert2, s2, id);

        List <user_parking_view> lst_user = new List <user_parking_view>();

        index = 0;
        foreach (DataRow row in connect.ds.Tables[0].Rows)
        {
            user_parking_view user = new user_parking_view();
            int      parkingid     = Convert.ToInt32(row["parking_id"]);
            string   insert3       = "Select user_id from garage where parking_id=@parkingid && status=0";
            string[] s3            = { "@parkingid" };
            connect = new Connect(insert3, s3, parkingid);
            if (connect.ds.Tables[0].Rows.Count == 1)

            {
                index = index + 1;
                int      userid  = Convert.ToInt32(connect.ds.Tables[0].Rows[0][0]);
                string   insert4 = "Select username from user where ttid=@ttid";
                string[] s4      = { "@ttid" };
                connect = new Connect(insert4, s4, userid);

                user.userid     = userid;
                user.username   = connect.ds.Tables[0].Rows[0][0].ToString();
                user.parking_id = parkingid;
                user.index      = index;
                lst_user.Add(user);
            }
            else
            {
                continue;
            }

            //if (userid == 0)
            //{
            //}
        }

        return(lst_user);
    }
示例#9
0
    public List <user_parking_view> MyCarsParked(int ttid)
    {
        Connect connect;

        Connect.ConnectPark();
        string q = "Select garage.parking_id,garage.car_id,garage.user_id,parking.private from garage inner join parking on garage.parking_id = parking.id  where garage.user_id=@id && status=0 && garage.parking_id !=0";

        string[] s2 = { "@id" };
        connect = new Connect(q, s2, ttid);
        List <user_parking_view> lst_user = new List <user_parking_view>();

        foreach (DataRow row in connect.ds.Tables[0].Rows)
        {
            user_parking_view user = new user_parking_view();
            //int parkingid =
            user.parking_id = Convert.ToInt32(row["parking_id"]);
            //   user.userid = Convert.ToInt32(row[3]);
            user.carid = Convert.ToInt32(row[1]);
            // user.username = row[1].ToString();
            bool public1 = Convert.ToBoolean(row[3]);

            if (public1 == false)
            {
                user.username = "******";
            }
            else
            {
                string   insert4 = "Select user_id from user_parking where parking_id=@p_id";
                string[] s4      = { "@p_id" };
                connect = new Connect(insert4, s4, user.parking_id);
                if (connect.ds.Tables[0].Rows.Count > 0)
                {
                    user.userid = Convert.ToInt32(connect.ds.Tables[0].Rows[0][0]);
                }
                user.username = new User().getName(user.userid);
            } lst_user.Add(user);
        }

        return(lst_user);
    }
示例#10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Response.Redirect("leaders.html");
        if (Session["ttid"] == null)
        {
            Response.Redirect("index.aspx");
        }
        else
        {
            if (!Page.IsPostBack)
            {
                Session.Remove("oponent");
                name.InnerText  = new User().getName(Convert.ToInt32(Session["ttid"]));
                money.InnerText = money.InnerText + new User().GetCashWithUser(Convert.ToInt32(Session["ttid"]));
                Span1.InnerText = new User().getSector(Convert.ToInt32(Session["ttid"])).ToString();
                var u = new user_parking_view().MyCarsParked(Convert.ToInt32(Session["ttid"]));


                new User().CheckUsers();
            }
        }
    }