Exemple #1
0
        protected void btnDel_Click(object sender, EventArgs e)
        {
            try
            {
                string query = "DELETE FROM Customer WHERE Customer_Id = @Customer_Id";
                dataTransfere = new busMethods();
                table         = new DataTable();
                dataSet       = new DataSet();
                con           = new SqlConnection();
                con           = dataTransfere.Connect();
                con.Open();

                using (adapter = new SqlDataAdapter())
                {
                    cmd = new SqlCommand(query, con);
                    cmd.Parameters.AddWithValue("@Customer_Id", int.Parse(txtId.Text));
                    cmd.ExecuteNonQuery();
                    Response.Write("<script>alert('Record Deleted')</script>");
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Exemple #2
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                string query = "UPDATE Customer SET CustName = @CustName, CustSurname = @CustSurname,Address = @Address ,PhoneNumber = @PhoneNumber WHERE Customer_Id = @Customer_Id";
                dataTransfere = new busMethods();
                con           = new SqlConnection();
                con           = dataTransfere.Connect();
                con.Open();

                using (adapter = new SqlDataAdapter())
                {
                    cmd = new SqlCommand(query, con);
                    cmd.Parameters.AddWithValue("@Customer_Id", int.Parse(txtId.Text));
                    cmd.Parameters.AddWithValue("@CustName", txtName.Text);
                    cmd.Parameters.AddWithValue("@CustSurname", txtSname.Text);
                    cmd.Parameters.AddWithValue("@Address", txtAddr.Text);
                    cmd.Parameters.AddWithValue("@PhoneNumber", txtCell.Text);
                    cmd.ExecuteNonQuery();
                    Response.Write("<script>alert('Record Updated')</script>");
                }
                con.Close();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Exemple #3
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                string query = "SELECT * FROM Customer WHERE Customer_Id = '" + int.Parse(txtId.Text) + "'";
                dataTransfere = new busMethods();
                table         = new DataTable();
                dataSet       = new DataSet();
                con           = new SqlConnection();
                con           = dataTransfere.Connect();
                con.Open();

                using (adapter = new SqlDataAdapter())
                {
                    cmd = new SqlCommand(query, con);
                    adapter.SelectCommand = cmd;
                    adapter.Fill(dataSet, "Customer");
                    table = dataSet.Tables["Customer"];

                    foreach (DataRow row in table.Rows)
                    {
                        txtName.Text  = row["CustName"].ToString();
                        txtSname.Text = row["CustSurname"].ToString();
                        txtCell.Text  = row["PhoneNumber"].ToString();
                        txtAddr.Text  = row["Address"].ToString();
                    }
                }
                con.Close();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Exemple #4
0
        protected void btnSeacrh_Click(object sender, EventArgs e)
        {
            try
            {
                string query = "SELECT BusNo,time,price FROM AllocateBusToTrip,Tri WHERE AllocateBusToTrip.TripId = Tri.TripId AND Tri.location = '" + DropDownList1.SelectedValue.ToString() + "' AND Tri.Destination = '" + DropDownList2.SelectedValue.ToString() + "' ";
                dataTransfere = new busMethods();
                table         = new DataTable();
                dataSet       = new DataSet();
                con           = new SqlConnection();
                con           = dataTransfere.Connect();
                con.Open();

                using (adapter = new SqlDataAdapter())
                {
                    cmd = new SqlCommand(query, con);
                    adapter.SelectCommand = cmd;
                    adapter.Fill(dataSet, "AllocateBusToTrip,Tri");
                    table = dataSet.Tables["AllocateBusToTrip,Tri"];

                    GridView1.DataSource = table;
                    GridView1.DataBind();
                }
                con.Close();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        protected void btnReport_Click(object sender, EventArgs e)
        {
            try
            {
                string query = "INSERT INTO Report (ReportId,BusNo,TripId,Date,Time) VALUES(@ReportId,@BusNo,@TripId,@Date,@Time)";
                dataTransfere = new busMethods();
                con           = new SqlConnection();
                con           = dataTransfere.Connect();
                con.Open();

                using (adapter = new SqlDataAdapter())
                {
                    cmd = new SqlCommand(query, con);
                    cmd.Parameters.AddWithValue("@ReportId", int.Parse(txtTrip_ID.Text));
                    cmd.Parameters.AddWithValue("@BusNo", int.Parse(txtBus_No.Text));
                    cmd.Parameters.AddWithValue("@TripId", int.Parse(txtTrip_ID.Text));
                    cmd.Parameters.AddWithValue("@Date", DateTime.Now.Date.ToString());
                    cmd.Parameters.AddWithValue("@Time", DateTime.Now.TimeOfDay.ToString());
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Exemple #6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            con           = new SqlConnection();
            dataSet       = new DataSet();
            dataTransfere = new busMethods();
            con           = dataTransfere.Connect();
            con.Open();
            try
            {
                string query = "SELECT username,password FROM Login ";
                using (adapter = new SqlDataAdapter())
                {
                    cmd = new SqlCommand(query, con);
                    adapter.SelectCommand = cmd;
                    adapter.Fill(dataSet, "Login");
                    table = new DataTable();
                    table = dataSet.Tables["Login"];

                    foreach (DataRow row in table.Rows)
                    {
                        //for passanger
                        if (row["username"].ToString().Equals(txtUser.Text) && row["password"].ToString().Equals(txtPass.Text))
                        {
                            Response.Redirect("~/payment.aspx");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                string query = "SELECT * FROM Bus WHERE BusNo = '" + int.Parse(txtBusNumber.Text) + "' ";
                dataSet       = new DataSet();
                table         = new DataTable();
                dataTransfere = new busMethods();
                con           = new SqlConnection();
                con           = dataTransfere.Connect();
                con.Open();

                using (adapter = new SqlDataAdapter())
                {
                    cmd = new SqlCommand(query, con);
                    adapter.SelectCommand = cmd;
                    adapter.Fill(dataSet, "Bus");
                    table = dataSet.Tables["Bus"];

                    foreach (DataRow row in table.Rows)
                    {
                        txtRegNo.Text   = row["RegNo"].ToString();
                        txtModel.Text   = row["Model"].ToString();
                        txtBusName.Text = row["BusName"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                string query = "UPDATE Bus SET RegNo = @RegNo,Model = @Model ,BusName = @BusName WHERE BusNo = @BusNo";
                dataTransfere = new busMethods();
                con           = new SqlConnection();
                con           = dataTransfere.Connect();
                con.Open();

                using (adapter = new SqlDataAdapter())
                {
                    cmd = new SqlCommand(query, con);
                    cmd.Parameters.AddWithValue("@RegNo", int.Parse(txtRegNo.Text));
                    cmd.Parameters.AddWithValue("@BusNo", int.Parse(txtBusNumber.Text));
                    cmd.Parameters.AddWithValue("@Model", txtModel.Text);
                    cmd.Parameters.AddWithValue("@BusName", txtBusName.Text);
                    cmd.ExecuteNonQuery();

                    Response.Write("<script>alert('Record Updated')</script>");
                }
                con.Close();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Exemple #9
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            con           = new SqlConnection();
            dataSet       = new DataSet();
            dataTransfere = new busMethods();
            con           = dataTransfere.Connect();
            con.Open();
            try
            {
                string query = "SELECT username,password FROM Login ";
                using (adapter = new SqlDataAdapter())
                {
                    cmd = new SqlCommand(query, con);
                    adapter.SelectCommand = cmd;
                    adapter.Fill(dataSet, "Login");
                    table = new DataTable();
                    table = dataSet.Tables["Login"];

                    foreach (DataRow row in table.Rows)
                    {
                        //for passanger
                        if (row["username"].ToString().Equals(txtUser.Text) && row["password"].ToString().Equals(txtPass.Text))
                        {
                            if (RadioButton1.Checked == true)
                            {
                                File.WriteAllText("C:\\Users\\Sandile Cedric Xulu\\Desktop\\loginDetails.txt", txtUser.Text);
                                Response.Redirect("~/pmHome.aspx");
                            }
                            else if (RadioButton2.Checked == true)
                            {
                                File.WriteAllText("C:\\Users\\Sandile Cedric Xulu\\Desktop\\loginDetails.txt", txtUser.Text);
                                Response.Redirect("~/empHome.aspx");
                            }

                            else if (RadioButton3.Checked == true)
                            {
                                File.WriteAllText("C:\\Users\\Sandile Cedric Xulu\\Desktop\\loginDetails.txt", txtUser.Text);
                                Response.Redirect("~/adHome.aspx");
                            }


                            else if (RadioButton4.Checked == true)
                            {
                                File.WriteAllText("C:\\Users\\Sandile Cedric Xulu\\Desktop\\loginDetails.txt", txtUser.Text);
                                Response.Redirect("~/mngHome.aspx");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Exemple #10
0
        protected void btnPrevPass_Click(object sender, EventArgs e)
        {
            try
            {
                string u_name = File.ReadAllText("C:\\Users\\Sandile Cedric Xulu\\Desktop\\loginDetails.txt");
                // string query = "SELECT * FROM Login";
                string query2 = "SELECT * FROM CreateAccount WHERE username = "******"";
                dataTransfere = new busMethods();
                table         = new DataTable();
                dataSet       = new DataSet();
                con           = new SqlConnection();
                con           = dataTransfere.Connect();
                con.Open();

                using (adapter = new SqlDataAdapter())
                {
                    cmd = new SqlCommand(query2, con);
                    adapter.SelectCommand = cmd;
                    adapter.Fill(dataSet, "CreateAccount");
                    table = dataSet.Tables["CreateAccount"];

                    foreach (DataRow row in table.Rows)
                    {
                        if (row["password"].ToString().Equals(txtPrevPass.Text))
                        {
                            txtAnswer.Enabled     = true;
                            txtAnswer2.Enabled    = true;
                            txtConfirm.Enabled    = true;
                            txtNewPass.Enabled    = true;
                            btnChangePass.Enabled = true;

                            lblQ1.Text = row["question1"].ToString();
                            lblQ2.Text = row["question2"].ToString();
                        }
                        //lblQ1.Text = table.Rows[0][4].ToString();
                        //lblQ2.Text = table.Rows[0][5].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            dataTransfere = new busMethods();
            table         = new DataTable();
            dataSet       = new DataSet();
            string u_name = File.ReadAllText("C:\\Users\\Sandile Cedric Xulu\\Desktop\\loginDetails.txt");

            txtId.Text = u_name;
            string query = "SELECT * FROM Customer WHERE Customer_Id = " + int.Parse(u_name) + "";

            try
            {
                con = dataTransfere.Connect();
                con.Open();
                using (adapter = new SqlDataAdapter())
                {
                    cmd = new SqlCommand(query, con);
                    adapter.SelectCommand = cmd;
                    adapter.Fill(dataSet, "Customer");
                    table = dataSet.Tables["Customer"];

                    foreach (DataRow row in table.Rows)
                    {
                        txtName.Text  = row["CustName"].ToString();
                        txtSname.Text = row["CustSurname"].ToString();
                        txtCell.Text  = row["PhoneNumber"].ToString();
                        txtAddr.Text  = row["Address"].ToString();
                    }
                }
                con.Close();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Exemple #12
0
        protected void btnChangePass_Click(object sender, EventArgs e)
        {
            string u_name = File.ReadAllText("C:\\Users\\Sandile Cedric Xulu\\Desktop\\loginDetails.txt");
            // string query = "SELECT * FROM Login";
            string query2 = "SELECT * FROM CreateAccount WHERE username = "******"";

            dataTransfere = new busMethods();
            table         = new DataTable();
            dataSet       = new DataSet();
            con           = new SqlConnection();
            con           = dataTransfere.Connect();
            con.Open();

            using (adapter = new SqlDataAdapter())
            {
                cmd = new SqlCommand(query2, con);
                adapter.SelectCommand = cmd;
                adapter.Fill(dataSet, "CreateAccount");
                table = dataSet.Tables["CreateAccount"];

                foreach (DataRow row in table.Rows)
                {
                    if (txtAnswer.Text.Equals(row["answer1"].ToString()) && txtAnswer2.Text.Equals(row["answer2"].ToString()))
                    {
                        //Response.Write("<script>alert('Answers are the same');</script>");
                        if (txtConfirm.Text.Equals(txtNewPass.Text))
                        {
                            try
                            {
                                string query  = "UPDATE CreateAccount SET password = @password WHERE username = @username";
                                string query3 = "UPDATE Login SET password = @password WHERE username = @username";
                                dataTransfere = new busMethods();
                                con           = new SqlConnection();
                                con           = dataTransfere.Connect();
                                con.Open();

                                using (adapter = new SqlDataAdapter())
                                {
                                    cmd = new SqlCommand(query, con);
                                    cmd.Parameters.AddWithValue("@password", txtNewPass.Text);
                                    cmd.Parameters.AddWithValue("@username", int.Parse(u_name));
                                    cmd.ExecuteNonQuery();

                                    cmd = new SqlCommand(query3, con);
                                    cmd.Parameters.AddWithValue("@password", txtNewPass.Text);
                                    cmd.Parameters.AddWithValue("@username", int.Parse(u_name));
                                    cmd.ExecuteNonQuery();

                                    Response.Write("<script>alert('Password Changed')</script>");
                                }
                                con.Close();
                            }
                            catch (Exception ex)
                            {
                                ex.ToString();
                            }
                        }
                    }
                }
            }
        }