Пример #1
0
        protected void btnAddBus_Click(object sender, EventArgs e)
        {
            // Assigning data Entered by user to Bussiness Object properties for Bus Details.
            BussinessObjectsClass bussinessObject = new BussinessObjectsClass();

            bussinessObject.BusNumber     = TxtBusNumber.Text;
            bussinessObject.StartPoint    = TxtStratingPoint.Text;
            bussinessObject.Destination   = TxtDestination.Text;
            bussinessObject.Capacity      = int.Parse(TxtCapacity.Text);                    // since Capacity is int-type, user string is parsed back to int.
            bussinessObject.DepartureTime = TxtDepartureTime.Text;
            bussinessObject.ArrivalTime   = TxtArrivalTime.Text;
            bussinessObject.CompanyName   = TxtCompanyName.Text;
            bussinessObject.BusType       = ListBusType.SelectedItem.Text;

            BussinessLogicClass bussinessLogicObject = new BussinessLogicClass();
            int isProcessSucessful = bussinessLogicObject.AddBus(bussinessObject);     // Addbus() method from Bussiness logic layer called and return value stored in variable isProcessSuccessful.

            if (isProcessSucessful == 1)                                               // If return value is 1, display "Bus added Successfully." else display apprpriate error messages.
            {
                Response.Write("Bus added Successfully.");
            }
            else
            {
                Response.Write("Cannot add bus details,please try again!");            // This could also be an actual exception/error message.
            }
        }
 protected void btnAddBus_Click(object sender, EventArgs e)
 {
     if (txtPickupLocation.Text == "")                                                        // TextBox validation. Make sure user enters a Pickup Location.
     {
         lblPickupLocation.Text = "*Please enter a Pickup Location";
         txtPickupLocation.Focus();
     }
     else
     {
         lblPickupLocation.Text = "";
         BussinessLogicClass   bussinessLogicObject = new BussinessLogicClass();
         BussinessObjectsClass bussinessObject      = new BussinessObjectsClass();
         bussinessObject.PickupId       = txtPickupId.Text;                                      // Pass pickup-Id from front-end to PickupId Property in BussinessObjects.
         bussinessObject.PickupLocation = txtPickupLocation.Text;                                // Passing user entered pickup Location PickupLocation Property in BussinessObjects.
         int isBusPickupInfoAdded = bussinessLogicObject.AddBusPickupPointInfo(bussinessObject); // Send values to Logic layer. From there to DataAccess layer and from there to Database. Return 1 if process succeeded.
         if (isBusPickupInfoAdded == 1)
         {
             lblMessage.Text        = txtPickupLocation.Text + " is added to Pickup Points successfully."; // Show message.
             txtPickupLocation.Text = "";                                                                  // Clear TextBox
             AutoGenPickupIDs();                                                                           // Generate new Pickup Id.
             txtPickupLocation.Focus();                                                                    // Focus cursor to Pickup Location to enter Another location.
         }
         else
         {
             lblMessage.Text = "Failed to add Pickup point info. Please try again";
         }
     }
 }
 protected void gridViewDestinationPoints_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName.ToString() == "cmdDelete")
     {
         int                   rowIndex        = Convert.ToInt32(e.CommandArgument.ToString());
         GridViewRow           row             = (GridViewRow)gridViewDestinationPoints.Rows[rowIndex];
         Label                 destID          = (Label)row.FindControl("lblDestinationId");
         BussinessObjectsClass bussinessObject = new BussinessObjectsClass();
         bussinessObject.DestinationId = destID.Text;
         BussinessLogicClass bussinessLogicObject = new BussinessLogicClass();
         int isDestinationDeleted = bussinessLogicObject.DelDestinationPoint(bussinessObject);
         if (isDestinationDeleted == 1)
         {
             Response.Write("Destination point deleted successfully");
             GetDestinationInfo();
         }
         else
         {
             Response.Write("Failed to delete the Destination Point");
         }
     }
     else if (e.CommandName.ToString() == "cmdUpdate")
     {
         int                   rowIndex             = Convert.ToInt32(e.CommandArgument.ToString());
         GridViewRow           row                  = (GridViewRow)gridViewDestinationPoints.Rows[rowIndex];
         Label                 destID               = (Label)row.FindControl("lblDestinationId");
         Label                 destLoc              = (Label)row.FindControl("lblDestinationLocation");
         BussinessObjectsClass bussinessLogicObject = new BussinessObjectsClass();
         bussinessLogicObject.DestinationId       = destID.Text;
         bussinessLogicObject.DestinationLocation = destLoc.Text;
         Session["d_id"]      = destID.Text;
         Session["d_station"] = destLoc.Text;
         Response.Redirect("UpdateDestinationPoints.aspx");
     }
 }
        public void AutoGenDestinationIDs()
        {
            BussinessLogicClass bussinessLogicObject = new BussinessLogicClass();
            string DestinationID = bussinessLogicObject.AutoGenDestinationIDs();

            txtDestinationID.Text = DestinationID;
        }
        private void AutoGenPickupIDs()                                                              // Pass auto generated values to PickupID TextBox.
        {
            BussinessLogicClass bussinessLogicObject = new BussinessLogicClass();
            string pickupId = bussinessLogicObject.AutoGenPickupIDs();

            txtPickupId.Text = pickupId;
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            BussinessLogicClass   bussinessLogicObject = new BussinessLogicClass();
            BussinessObjectsClass bussinessObject      = new BussinessObjectsClass();

            foreach (GridViewRow row in gridDestinationPoints.Rows)
            {
                CheckBox cb = (CheckBox)row.FindControl("checkDestination");
                if (cb.Checked)
                {
                    Label destID = (Label)row.FindControl("lblDestinationID");
                    bussinessObject.DestinationId = destID.Text.ToString();
                    string   selectedBus = ddlSelectBus.SelectedItem.ToString();
                    string[] busInfo     = selectedBus.Split('/');                                                       // Split the string to extract BusNumber from the String.
                    bussinessObject.BusNumber = busInfo[0].ToString();
                    int isProcessSuccessfull = bussinessLogicObject.AddBusSpecificDestinationPoint(bussinessObject);     // Add values to BusDestination table
                    if (isProcessSuccessfull == 1)
                    {
                        lblMessage.Text = "Destination Points are added Successfully for " + busInfo[0].ToString();
                    }
                    else
                    {
                        lblMessage.Text = "Failed to add Bus Destination Points. Please try again.";
                    }
                }
            }
        }
        //Displays all the Destination Points.
        private void GetDestinationInfo()
        {
            BussinessLogicClass bussinessLogicObject = new BussinessLogicClass();
            DataSet             ds = bussinessLogicObject.ViewDestinationPoints();

            gridDestinationPoints.DataSource = ds;
            gridDestinationPoints.DataBind();
        }
Пример #8
0
        private void GetBusDetails()                                                // Gets the data from BussinessLogic Layer and binds it with Grid view control(gridBusDetails).
        {
            BussinessLogicClass bussinessLogicObject = new BussinessLogicClass();
            DataSet             ds = bussinessLogicObject.ViewBus();                // Call view Bus function from Bussiness logic Layer.

            gridBusDetails.DataSource = ds;                                         // Define the above created dataset as DataSource of the gridBusDetails.
            gridBusDetails.DataBind();                                              // Bind data.
        }
Пример #9
0
        private void BindPickupPoints()                                                                  // Shows all PickupPoints in Select Pickup Point dropdown-list.
        {
            BussinessLogicClass bussinessLogicObject = new BussinessLogicClass();
            // Using same method used for Admin to view Pickup Points.
            DataSet ds = bussinessLogicObject.ViewPickupPoints();                                        // Since return type of ViewPickupPoints() method is DataSet, save results in DataSet ds.

            ddlSelectPickupPoint.DataSource     = ds;                                                    // Set DataSource for Select PickupPoint List as ds.
            ddlSelectPickupPoint.DataTextField  = "pp_station";                                          // Show Pickup Location in the list.
            ddlSelectPickupPoint.DataValueField = "pp_id";                                               // Save Pickup Id as value. This is used later to add values in BusPickupPoint table.
            ddlSelectPickupPoint.DataBind();                                                             // DataBind
        }
Пример #10
0
        protected void userLogin_Authenticate(object sender, AuthenticateEventArgs e)   //Login authentication Event. Fired when user clicks loogin
        {
            BussinessLogicClass   bussinessLogic  = new BussinessLogicClass();          // Business logic class object. This allows Presentation Layer to interact with Bussiness logic layer.
            BussinessObjectsClass bussinessObject = new BussinessObjectsClass();        // Bussiness Objects class object. This allows Presentation Layer to interact with Bussiness Objects layer.

            bussinessObject.UserName = userLogin.UserName;                              // Accessing properties defined in Bussiness Object class for username and password.
            bussinessObject.Password = userLogin.Password;
            int loginAttempt = bussinessLogic.AdminLogin(bussinessObject);              // Call AdminLogin() method fo admin login

            if (loginAttempt == 1)                                                      // Redirect to AdminHime.aspx page if return value = 1.
            {
                Response.Redirect("AdminHome.aspx");
            }
            else
            {
                userLogin.FailureText = "Either the username or password is incorrect.";
            }
        }
Пример #11
0
        private void BindBusInfo()                                                                       // Shows BusInfo in Select Bus dropdown-list.
        {
            BussinessLogicClass bussinessLogicObject = new BussinessLogicClass();
            SqlDataReader       dr = bussinessLogicObject.BusInfoForBusPickupPoint();                    // Get data reader from Bussiness Logic Layer.

            if (dr.HasRows)                                                                              // if the table contain row(s)
            {
                while (dr.Read())
                {
                    //get BusNumber, StartingPoint and Destination from each row.
                    string busNumber     = dr[0].ToString();
                    string stratingPoint = dr[1].ToString();
                    string destination   = dr[2].ToString();
                    string info          = busNumber + " / " + stratingPoint + " to " + destination;     // Show info in form of <busNumber> / <stratingPoint> to <destination>
                    ddlSelectBus.Items.Add(info);
                }
            }
        }
Пример #12
0
        protected void gridBusDetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            BussinessLogicClass   bussinessLogicObject = new BussinessLogicClass();
            BussinessObjectsClass bussinessObject      = new BussinessObjectsClass();
            GridViewRow           row = (GridViewRow)gridBusDetails.Rows[e.RowIndex];               // Get the number of rows in the gridview and the index where user clicked edit.
            TextBox bNum = (TextBox)row.FindControl("txt_bNumber");                                 // Find the control in which the user has edited the value.

            bussinessObject.BusNumber = bNum.Text;                                                  // Assign the properties in the business-object layer with te user entered values.
            TextBox sPoint = (TextBox)row.FindControl("txt_sPoint");

            bussinessObject.StartPoint = sPoint.Text;
            TextBox dest = (TextBox)row.FindControl("txt_dest");

            bussinessObject.Destination = dest.Text;
            TextBox cap = (TextBox)row.FindControl("txt_cap");

            bussinessObject.Capacity = int.Parse(cap.Text);
            TextBox dTime = (TextBox)row.FindControl("txt_dTime");

            bussinessObject.DepartureTime = dTime.Text;
            TextBox aTime = (TextBox)row.FindControl("txt_aTime");

            bussinessObject.ArrivalTime = aTime.Text;
            TextBox cName = (TextBox)row.FindControl("txt_cName");

            bussinessObject.CompanyName = cName.Text;
            TextBox bType = (TextBox)row.FindControl("txt_bType");

            bussinessObject.BusType = bType.Text;
            int isEditProcessSuccessfull = bussinessLogicObject.EditBus(bussinessObject);            // Passing above values to Edit bus function.

            if (isEditProcessSuccessfull == 1)                                                       // If query execution returns 1, update records and switch back to static view with updated data.
            {
                Response.Write("Bus details Edited Successfully");
                gridBusDetails.EditIndex = -1;
                GetBusDetails();
            }
            else
            {
                Response.Write("Unable to Edit bus details.Please try again");
                GetBusDetails();
            }
        }
Пример #13
0
        protected void gridBusDetails_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            BussinessLogicClass   bussinessLogicObject = new BussinessLogicClass();
            BussinessObjectsClass bussinessObject      = new BussinessObjectsClass();
            string busNumber = gridBusDetails.DataKeys[e.RowIndex].Value.ToString();            // getting bus number

            bussinessObject.BusNumber = busNumber;
            int isDeleteSuccessful = bussinessLogicObject.DeleteBus(bussinessObject);           // passing the bus number via bussinessObject's object.

            if (isDeleteSuccessful == 1)                                                        // if deletes successfull
            {
                Response.Write("Bus entry is Deleted");                                         // Show user message
                GetBusDetails();                                                                // Update gridBusDetails on page for user to see.
            }
            else
            {
                Response.Write("Could not delete Bus entry. Please try again");                    // else show error message.
            }
        }
        protected void gridViewPickupPoints_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            BussinessLogicClass   bussinessLogicObject = new BussinessLogicClass();
            BussinessObjectsClass bussinessObject      = new BussinessObjectsClass();
            string pickupID = gridViewPickupPoints.DataKeys[e.RowIndex].Value.ToString();             // getting pickup ID

            bussinessObject.PickupId = pickupID;
            int isDeleteSuccessful = bussinessLogicObject.DelPickupPoint(bussinessObject);            // passing the pickup ID via bussinessObject's object.

            if (isDeleteSuccessful == 1)                                                              // if deletetion successful
            {
                Response.Write("PickupPoint entry is Deleted");
                GetPickupPointDetails();                                                              // Update gridViewPickupPoints on page for user to see.
            }
            else
            {
                Response.Write("Could not delete PickupPoint entry. Please try again");
            }
        }
Пример #15
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            BussinessLogicClass   bussinessLogicObject = new BussinessLogicClass();
            BussinessObjectsClass bussinessObject      = new BussinessObjectsClass();

            bussinessObject.PickupId = ddlSelectPickupPoint.SelectedValue.ToString();                     // Get PickupId(pp_id) from the list.
            string selectedBus = ddlSelectBus.SelectedItem.ToString();                                    // Get Selected Bus from the list.

            string[] busInfo = selectedBus.Split('/');                                                    // Split the string to extract BusNumber from the String.
            bussinessObject.BusNumber = busInfo[0].ToString();
            int isProcessSuccessfull = bussinessLogicObject.AddBusSpecificPickupPoint(bussinessObject);   // Add values to table

            if (isProcessSuccessfull == 1)
            {
                Response.Write("Bus pickup point added Successfully");
            }
            else
            {
                Response.Write("Could not add Bus Pickup Point. Please try again");
            }
        }
Пример #16
0
        //Bind the Destination Points when user selects Bus from first DropDownList.
        private void BindDestinationsPointsBasedOnBusNumber()
        {
            //Get Bus Number  when Admin Selects bus from Select Bus DropDown List.
            BussinessLogicClass   bussinessLogicObject = new BussinessLogicClass();
            BussinessObjectsClass bussinessObject      = new BussinessObjectsClass();
            string selectedBus = ddlBusNumber.SelectedItem.ToString();

            string[] busInfo = selectedBus.Split('/');
            bussinessObject.BusNumber = busInfo[0];
            ViewState["BusNumber"]    = bussinessObject.BusNumber;                                              // Save BusNumber for later use when Fare info is added to Fare table in DataBase
            // Get Destination associated with BusNumber that Admin Selected.
            DataSet ds = bussinessLogicObject.DestinationPointsBasedOnBusNumber(bussinessObject);

            ddlFromPlace.DataSource     = ds;
            ddlFromPlace.DataTextField  = "d_station";                                                          // Text to show when Data is Binded based on Bus Number.
            ddlFromPlace.DataValueField = "d_id";                                                               // Value that goes into Database when Admin press Add on Fare Page
            ddlFromPlace.DataBind();
            ddlToPlace.DataSource     = ds;
            ddlToPlace.DataTextField  = "d_station";
            ddlToPlace.DataValueField = "d_id";
            ddlToPlace.DataBind();
        }
Пример #17
0
        protected void btnAddFare_Click(object sender, EventArgs e)
        {
            //All Textbox Validations.
            if (txtStartTime.Text == "")
            {
                lblStartTime.Text = "Please Enter Starting Time";
            }
            if (txtArrivalTime.Text == "")
            {
                lblArrivalTime.Text = "Please Enter Arrival Time";
            }
            if (txtFare.Text == "")
            {
                lblFare.Text = "Please enter Fare";
            }
            BussinessLogicClass   bussinessLogicObject = new BussinessLogicClass();
            BussinessObjectsClass bussinessObject      = new BussinessObjectsClass();

            // Collecting all Data Entered by Admin. NOTE: In Fare table we are Entering ID's not Name of place.
            bussinessObject.BusNumber         = ViewState["BusNumber"].ToString();
            bussinessObject.FromDepartureID   = ddlFromPlace.SelectedValue.ToString();
            bussinessObject.ToDestinationID   = ddlToPlace.SelectedValue.ToString();
            bussinessObject.FromDepartureTime = txtStartTime.Text.ToString();
            bussinessObject.ToDepartureTime   = txtArrivalTime.Text.ToString();
            bussinessObject.Fare = Convert.ToDouble(txtFare.Text.ToString());
            int isFareAddedSuccessfully = bussinessLogicObject.AddFare(bussinessObject);

            if (isFareAddedSuccessfully == 1)
            {
                lblMessage.Text = "Fare added for Bus Number: " + ViewState["BusNumber"].ToString() + " from " + ddlFromPlace.SelectedItem.ToString() + " to " + ddlToPlace.SelectedItem.ToString() + " successfully";
            }
            else
            {
                lblMessage.Text = "Failed to add Fare info. Please try Again";
            }
        }
Пример #18
0
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     if (txtDestinationLocation.Text == "")
     {
         lblDestinationLocation.Text = "*Please Enter a Destinatoin Location";
     }
     else
     {
         lblDestinationLocation.Text = "*";
         BussinessObjectsClass bussinessObject = new BussinessObjectsClass();
         bussinessObject.DestinationId       = txtDestinationID.Text;
         bussinessObject.DestinationLocation = txtDestinationLocation.Text;
         BussinessLogicClass bussinessLogicObject = new BussinessLogicClass();
         int isLocationUpdated = bussinessLogicObject.UpdateDestinationPoint(bussinessObject);
         if (isLocationUpdated == 1)
         {
             lblMessage.Text = "Destination Lcation Updated Successfully. Click Back to go back to View Page";
         }
         else
         {
             Response.Write("Failed to update Destination Location. Please try again");
         }
     }
 }