Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Type"] == null)
            {
                Response.Redirect("../Index.aspx");
            }
            else if (Session["Type"].ToString() == "Driver")
            {
                Response.Redirect("../Driver/DriverPage.aspx");
            }
            else if (Session["Type"].ToString() == "Administrator")
            {
                Response.Redirect("../Admin/AdminHome.aspx");
            }
            if (!this.IsPostBack)
            {
                string        strConnection = ConfigurationManager.ConnectionStrings["TAMConnectionString"].ConnectionString;
                SqlConnection sqlcon        = new SqlConnection(strConnection);
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                try
                {
                    DataTable dt = new DataTable();
                    dt.Columns.AddRange(new DataColumn[5] {
                        new DataColumn("NumberPlate"), new DataColumn("WeightCapacity"), new DataColumn("DriverName"), new DataColumn("FamilyName"), new DataColumn("PhoneNo")
                    });

                    SqlCommand sqlcmd = new SqlCommand("SpTruckSelect", sqlcon);
                    sqlcmd.Parameters.AddWithValue("@CargoID", Session["cargo"]);
                    sqlcmd.Parameters.AddWithValue("@Quan", Session["quan"]);
                    sqlcmd.Parameters.AddWithValue("@OwnerLoginID", Session["Logged"]);
                    sqlcmd.CommandType = CommandType.StoredProcedure;
                    SqlDataAdapter da = new SqlDataAdapter(sqlcmd);
                    DataSet        ds = new DataSet();
                    da.Fill(ds, "Drivers");

                    foreach (DataRow pRow in ds.Tables["Drivers"].Rows)
                    {
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "updateProgress"+i, "updateProgress('" + pRow["lat"] + "','" + pRow["lon"] + "');", true);
                        dt.Rows.Add(pRow["NumberPlate"], pRow["WeightCapacity"], pRow["DriverName"], pRow["FamilyName"], pRow["PhoneNo"]);
                    }

                    GridViewTruck.DataSource = dt;
                    GridViewTruck.DataBind();
                    sqlcon.Close();
                }
                catch (Exception ee)
                {
                    Console.WriteLine(ee);
                }
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Type"] == null)
            {
                Response.Redirect("../Administrator.aspx");
            }
            else if (Session["Type"].ToString() == "Driver")
            {
                Response.Redirect("../Driver/DriverPage.aspx");
            }
            else if (Session["Type"].ToString() == "CargoOwner")
            {
                Response.Redirect("../Cargo/CargoHome.aspx");
            }
            if (!this.IsPostBack)
            {
                string        strConnection = ConfigurationManager.ConnectionStrings["TAMConnectionString"].ConnectionString;
                SqlConnection sqlcon        = new SqlConnection(strConnection);
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                try
                {
                    DataTable dt = new DataTable();
                    dt.Columns.AddRange(new DataColumn[4] {
                        new DataColumn("TruckID"), new DataColumn("Number"), new DataColumn("Weight"), new DataColumn("Status")
                    });
                    String     driver = Session["driver"].ToString();
                    SqlCommand sqlcmd = new SqlCommand("SpTruckListAdmin", sqlcon);
                    sqlcmd.Parameters.AddWithValue("@DriverID", driver);
                    sqlcmd.CommandType = CommandType.StoredProcedure;

                    SqlDataAdapter da = new SqlDataAdapter(sqlcmd);
                    DataSet        ds = new DataSet();


                    da.Fill(ds, "Drivers");
                    foreach (DataRow pRow in ds.Tables["Drivers"].Rows)
                    {
                        dt.Rows.Add(pRow["TruckID"], pRow["Number"], pRow["Weight"], pRow["Status"]);
                    }
                    GridViewTruck.DataSource = dt;
                    GridViewTruck.DataBind();
                    sqlcon.Close();
                }
                catch (Exception ee)
                {
                    Console.WriteLine(ee);
                }
            }
        }