Ejemplo n.º 1
0
        private void ClearRouteInput()
        {
            this.departureText.Text = "";
            this.richTextBox1.Text  = "";
            try
            {
                this.FillDropDownFromDb();
                this.cmbBus.SelectedIndex = -1;
            }
            catch (Exception e) { }

            this.BusTypeTextField.Text = "";
            this.fareTextField.Text    = "";

            //If the clear button is clicked then this means a new Route is willingly to be created.
            this.invisibleScheduleIdText.Text = "";
            this.routeStatus.Text             = "";

            this.changeStatusBtn.Visible = false;
            this.routeStatus.Visible     = false;

            //If clear button is clicked then a new routeId will be generated
            try
            {
                this.disableBusIdText.Text = RouteRepo.GetId();
            }
            catch (Exception exception)
            {
                Console.WriteLine("Something went wrong in Create!\n" + exception);
            }
        }
        private void cmbBusNo_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string[,] info = RouteRepo.GetRouteAndSchedule(this.cmbBusNo.Text);
                //departure location info[][0]
                //destination info[][1]
                //departure time info[2]
                //arrival info[3]

                this.txtFrom.Text              = info[0, 0];
                this.txtDestination.Text       = info[0, 1];
                this.txtDeptTime.Text          = info[0, 2];
                this.txtArrivalTime.Text       = info[0, 3];
                this.txtReturnFrom.Text        = this.txtDestination.Text;
                this.txtReturnDestination.Text = this.txtFrom.Text;

                this.invisibleFareTextField.Text = info[0, 4];
            }

            catch (Exception f)
            {
                Console.WriteLine("Something went wrong when fetching data" + e);
            }
        }
Ejemplo n.º 3
0
        public static void Main(string[] args, KeyStorage keyStorage)
        {
            //Usage
            if (args.Length != 4)
            {
                throw new HelpException("Missing arguments");
            }
            string sourcePath     = args [1];
            string repoPath       = args [2];
            string receipientName = args [3];

            //Source
            if (Directory.Exists(sourcePath) == false)
            {
                throw new HelpException("Source directory not found: " + sourcePath);
            }

            //Repo
            Repo repo = Repo.Create(repoPath);

            //Sender and Recipient keys
            PrivateKey senderKey    = keyStorage.DefaultKey;
            PublicKey  recipientKey = keyStorage.GetPublic(receipientName);

            //Prepare Route message recording of ChunkID
            RouteRepo rr = new RouteRepo(repo);

            //Prepare Encryption
            EncryptedRepo er = new EncryptedRepo(rr, null);

            er.AddKey(recipientKey);

            Console.Write("Generating Tree...");

            //Send Tree
            ChunkHash tree = TreeChunk.GenerateChunk(sourcePath, er);

            //TreeMessage
            TreeMessage tm   = new TreeMessage(tree, Path.GetDirectoryName(sourcePath));
            Chunk       tmc  = Message.ToChunk(tm, senderKey);
            ChunkHash   tmch = er.WriteChunk(tmc);

            er.StoreMessage("file", tmch);

            //RouteMessage
            RouteMessage rm = rr.RouteMessage;

            rm.MessageChunkHash = tmch.bytes;
            rm.To = receipientName;

            //Store unencrypted RouteMessage
            Chunk rmChunk = Message.ToChunk(rm);

            repo.WriteChunk(rmChunk);
            repo.StoreMessage("route", rmChunk.ChunkHash);
            Console.WriteLine("RouteMessage Stored");
        }
Ejemplo n.º 4
0
 private void GenerateRouteId()
 {
     try
     {
         this.disableBusIdText.Text = RouteRepo.GetId();
     }
     catch (Exception e)
     {
         Console.WriteLine("Something went wrong!");
     }
 }
Ejemplo n.º 5
0
 private void cmbBus_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         this.BusTypeTextField.Text = RouteRepo.BusTypeForRoute(cmbBus.Text);
     }
     catch (Exception exception)
     {
         MessageBox.Show("Something went wrong in Selected Drop Down!\n" + exception);
     }
 }
Ejemplo n.º 6
0
 private void FillRouteDataGridView()
 {
     this.dgvRoute.AutoGenerateColumns = false;
     try
     {
         this.dgvRoute.DataSource = RouteRepo.ShowAll();
     }
     catch (Exception e)
     {
         Console.WriteLine("Something went wrong in Table!" + e);
     }
     this.dgvRoute.ClearSelection();
     this.dgvRoute.Refresh();
 }
Ejemplo n.º 7
0
 private void rtxtSearch_TextChanged(object sender, EventArgs e)
 {
     this.dgvRoute.AutoGenerateColumns = false;
     try
     {
         this.dgvRoute.DataSource = RouteRepo.LiveSearchRoutes(this.rtxtSearch.Text);
     }
     catch
     {
         Console.WriteLine("Something went wrong!");
     }
     this.dgvRoute.ClearSelection();
     this.dgvRoute.Refresh();
 }
Ejemplo n.º 8
0
        public DALUnitOfWork()
        {
            vygCtx = new VoyageContext();

            BusExpeditionPocos   = new BusExpeditionRepo(vygCtx);
            BusPocos             = new BusRepo(vygCtx);
            BusTypePocos         = new BusTypeRepo(vygCtx);
            DriverPocos          = new DriverRepo(vygCtx);
            HostPocos            = new HostRepo(vygCtx);
            PersonPocos          = new PersonRepo(vygCtx);
            RoutePocos           = new RouteRepo(vygCtx);
            SeatInformationPocos = new SeatInformationRepo(vygCtx);
            TicketPocos          = new TicketRepo(vygCtx);
        }
        public async Task Setup()
        {
            /// ARRANGE

            // ask system test setup class to get the context instance
            _context = SingletonTestSetup.Instance().Get();
            //Wait
            route = new Route()
            {
                RouteId = "IR-140"
            };
            await AddRoute(route);

            repo = new RouteRepo(_context);
        }
 private void cboFrom_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.cboTo.Items.Clear();
     try
     {
         this.RouteList = RouteRepo.GetAllDestination(this.cboFrom.Text);
         foreach (var route in this.RouteList)
         {
             this.cboTo.Items.Add(route.Destination);
         }
     }
     catch (Exception error)
     {
         MessageBox.Show($"Error fetching data\n{error.Message}");
     }
 }
Ejemplo n.º 11
0
        private void deleteBusBtn_Click(object sender, EventArgs e)
        {
            if (this.dgvBus.SelectedRows.Count < 1)
            {
                MessageBox.Show("No data selected");
                return;
            }

            if (MessageBox.Show("Are you sure you want to delete?", caption: "Confirmation", MessageBoxButtons.YesNo,
                                MessageBoxIcon.Warning) == DialogResult.No)
            {
                return;
            }

            try
            {
                //MessageBox.Show("hello");
                //when delete button is clicked the bus will be null to route table since it is foreign key
                bool ifBusSetsToNullInRoute = RouteRepo.SetNullToBusNum(this.rtxtPhn.Text);

                if (ifBusSetsToNullInRoute)
                {
                    try
                    {
                        bool ifBusDeleted = BusRepo.Delete(this.rtxtPhn.Text);

                        if (ifBusDeleted)
                        {
                            MessageBox.Show("Deleted Successfully!\nBus associated with routes is inactivated");

                            ClearBusInput();
                            this.invisibleBusNoText.Text = "";
                            this.FillBusDataGridView();
                        }
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show("Something went wrong when deleting the bus");
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Something went wrong when setting bus number to null to route\n" + exception);
            }
        }
 private void RouteFill()
 {
     try
     {
         this.Route = new Route
         {
             RouteId      = RouteRepo.GetId(),
             DeptLocation = this.txtReturnFrom.Text,
             Destination  = this.txtReturnDestination.Text,
             BusNo        = this.cmbBusNo.Text,
             Fare         = this.invisibleFareTextField.Text,
             Status       = "Active"
         };
     }
     catch (Exception e)
     {
         MessageBox.Show("Something went wrong when getting Route Information!");
     }
 }
 private void SaveSalesAmount(string scheduleId)
 {
     try
     {
         string routeId            = ScheduleRepo.GetRouteId(scheduleId);
         int    ticketPrice        = RouteRepo.GetFare(routeId);
         int    currentSalesAmount = SalesRepo.CurrentSalesAmount(MainControl.cashierId);
         if (currentSalesAmount == 0)
         {
             int amount = ticketPrice * MainControl.selectedSeatCount;
             SalesRepo.Insert(MainControl.cashierId, amount);
         }
         else
         {
             int updatedAmount = currentSalesAmount + (ticketPrice * MainControl.selectedSeatCount);
             SalesRepo.Update(MainControl.cashierId, updatedAmount);
         }
     }catch (Exception e)
     {
         MessageBox.Show("Error!" + e.Message);
     }
 }
        private void cashierTicketControl1_Load(object sender, EventArgs e)
        {
            this.dateTimePicker1.MinDate = DateTime.Now;
            this.dateTimePicker1.MaxDate = this.dateTimePicker1.Value.AddDays(30);

            try
            {
                string[] deptLocationList = RouteRepo.GetAllDeptLocation();
                foreach (string s in deptLocationList)
                {
                    this.cboFrom.Items.Add(s);
                }
            }
            catch (Exception error)
            {
                MessageBox.Show($"Error fetching data\n{error.Message}");
            }


            this.cboFrom.Text    = MainControl.cashierFrom;
            this.cboTo.Text      = MainControl.cashierTo;
            this.cmbBusType.Text = MainControl.cashierBusType;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("fdsf");
            //First we have to insert data into route table and then into the schedule table
            this.RouteFill();

            Entity.Schedule schedule = new Entity.Schedule();
            try
            {
                schedule.ScheduleId = ScheduleRepo.GetId();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }

            schedule.DeptTime    = this.dtpDeparture.Text;
            schedule.ArrivalTime = this.dtpArrival.Text;
            schedule.RouteId     = this.Route.RouteId; //In Schedule table route_id is a foreign key.

            try
            {
                RouteRepo.Insert(this.Route);  //inserting into the route table
                ScheduleRepo.Insert(schedule); //inserting into schedule table

                MessageBox.Show("Created Successfully");

                //After inserting data the route home page will be redirected
                controlRoute route = new controlRoute();
                MainControl.showControl(route, frmAdminDashboard.ActiveForm);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Please Select A Bus No", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 16
0
 /*set pilot repo pattern upon instantiation of flights controller*/
 public FlightsController(FlightRepo db_flights, RouteRepo db_route, PilotRepo db_pilot)
 {
     _db_flights = db_flights;
     _db_route   = db_route;
     _db_pilot   = db_pilot;
 }
Ejemplo n.º 17
0
 /* Set context upon instantiation of controller */
 public ScheduleController(PilotRepo db_pilots, FlightRepo db_flights, RouteRepo db_route)
 {
     _db_pilots  = db_pilots;
     _db_flights = db_flights;
     _db_route   = db_route;
 }
Ejemplo n.º 18
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool idExist;
            bool checkIfBusExistSignal;

            try
            {
                idExist = RouteRepo.SearchRouteId(this.disableBusIdText.Text);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                throw;
            }
            if (idExist) //For Update purpose
            {
                if (!this.RouteFill())
                {
                    return;
                }
                else
                {
                    Route.Status = this.routeStatus.Text;

                    //Following line used to store Route information when a row from data grid view is double clicked.
                    Route singleRouteInfo = RouteRepo.SingleRouteInfo(this.disableBusIdText.Text);

                    //Following line gets the route_id.
                    string secondRouteId = RouteRepo.CheckIfTwoRoutesExist(singleRouteInfo);

                    try
                    {
                        if (secondRouteId != null)//if two routes exist, will get a route_id, else null
                        {
                            //So there is two routes, and now checking if the bus exist to any different route if we select a different
                            //bus and click on save button.
                            checkIfBusExistSignal = RouteRepo.CheckIfBusExistInTwoRoutesForUpdate(this.cmbBus.Text, this.disableBusIdText.Text, secondRouteId);
                        }
                        else
                        {
                            //So there is one route, and now checking if the bus exist to any different route if we select a different
                            //bus and click on save button.
                            checkIfBusExistSignal = RouteRepo.CheckIfBusExistInRouteForUpdate(this.cmbBus.Text, this.disableBusIdText.Text);
                        }
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show("Something went wrong when check bus exist or not");
                        throw;
                    }

                    //we will check if the bus number exist for particular route_id in route table.
                    //If exist we will not update, else will update.
                    if (checkIfBusExistSignal == false)
                    {
                        try
                        {
                            bool updateRouteSignal = RouteRepo.Update(this.Route);

                            Entity.Schedule schedule = new Entity.Schedule();
                            schedule.ScheduleId  = this.invisibleScheduleIdText.Text;
                            schedule.DeptTime    = this.dateTimePicker1.Text;
                            schedule.ArrivalTime = this.dateTimePicker2.Text;
                            schedule.RouteId     = this.disableBusIdText.Text;

                            bool updateScheduleSignal = ScheduleRepo.Update(schedule);
                            if (secondRouteId != null)
                            {
                                //MessageBox.Show("not null");
                                bool updateSecondRouteSignal = RouteRepo.UpdateSecondRoute(this.Route, secondRouteId);
                            }
                            if (updateRouteSignal && updateScheduleSignal)
                            {
                                MessageBox.Show("Route Updated Successuflly!!");

                                //Once the save button is clicked for edit, new Id, as primary key, will be generated for the route table.
                                this.disableBusIdText.Text = RouteRepo.GetId();
                                this.ClearRouteInput();
                                this.FillRouteDataGridView();
                            }
                        }
                        catch (Exception exception)
                        {
                            Console.WriteLine("Something went wrong in Update!\n" + exception);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Bus Number already Exists in different Route!\nCannot Update. Get a new Bus!");
                    }
                }
            }
            if (!idExist) //for insert purpose
            {
                if (!this.RouteFill())
                {
                    return;
                }
                else if (this.RouteFill())
                {
                    try
                    {
                        checkIfBusExistSignal = RouteRepo.CheckIfBusExistInRoute(this.cmbBus.Text);
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show("Something went wrong when check bus exist or not");
                        throw;
                    }

                    //we will check if the bus number exist in route table. If exist we will not insert, else will insert.
                    if (!checkIfBusExistSignal)//if return false we will insert, else not
                    {
                        bool insertSignal;
                        try
                        {
                            insertSignal = RouteRepo.Insert(this.Route); //inserting into the route table
                        }
                        catch (Exception exception)
                        {
                            MessageBox.Show("Something went wrong when inserting route");
                            throw;
                        }

                        //First we have to insert data into route table and then into the schedule table
                        Entity.Schedule schedule = new Entity.Schedule();
                        try
                        {
                            schedule.ScheduleId = ScheduleRepo.GetId();
                        }
                        catch (Exception exception)
                        {
                            MessageBox.Show("Something went wrong when getting schedule Id");
                        }

                        schedule.DeptTime    = this.dateTimePicker1.Text;
                        schedule.ArrivalTime = this.dateTimePicker2.Text;
                        schedule.RouteId     = this.disableBusIdText.Text; //In Schedule table route_id is a foreign key.
                        //this.Route.ScheduleId = schedule.ScheduleId; //In Route table schedule_id is a foreign key.

                        bool insertSignalSchedule;
                        try
                        {
                            insertSignalSchedule = ScheduleRepo.Insert(schedule); //inserting into schedule table
                        }
                        catch (Exception exception)
                        {
                            MessageBox.Show("Something went wrong when inserting schedule");
                            throw;
                        }

                        if (insertSignal && insertSignalSchedule)
                        {
                            MessageBox.Show("Route Created Successuflly!!");

                            //Once the save button is clicked, new Id, as primary key, will be generated for the route table.
                            try
                            {
                                this.disableBusIdText.Text = RouteRepo.GetId();
                            }
                            catch (Exception exception)
                            {
                                Console.WriteLine("Something went wrong in Create!\n" + exception);
                            }

                            this.ClearRouteInput();
                            this.FillRouteDataGridView();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Bus Number already Exists in different Route!\nCannot Insert. Get a new Bus!");
                    }
                }
            }
        }