Beispiel #1
0
        public async void saveBtnClickedHelper()
        {
            bool exists = await checkIfRouteExists(this.newRouteNameTxtbox.Text);

            // If Route Exists, prompt user to override
            if (exists == true)
            {
                // IF user OK's override,
                // Get Name from Textbox and save route to database
                DialogResult result = MessageBox.Show("Route " + this.newRouteNameTxtbox.Text + "Already Exists in Database. Override?", "Override?",
                                                      MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
                if (result == DialogResult.Yes)
                {
                    this.parentForm.saveNewRoute(this.newRouteNameTxtbox.Text);
                    DialogResult dialogRes = MessageBox.Show("Route " + this.newRouteNameTxtbox.Text + " has been saved", "Saved",
                                                             MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (dialogRes == DialogResult.OK)
                    {
                        parentForm.clearNewRouteTable();
                        this.Close();
                        return;
                    }
                }
                return;
            }
            else
            {
                this.parentForm.saveNewRoute(this.newRouteNameTxtbox.Text);
                DialogResult result = MessageBox.Show("Route " + this.newRouteNameTxtbox.Text + " has been saved", "Saved",
                                                      MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (result == DialogResult.OK)
                {
                    parentForm.clearNewRouteTable();
                    //this.parentForm.TopLevel = true;
                    //this.TopLevel = false;
                    this.Close();
                    return;
                }
            }
        }
Beispiel #2
0
        private async void loadBtn_MouseUp(object sender, MouseEventArgs e)
        {
            if (this.comboBox1.Items.Count == 0)
            {
                // If no routes exist, don't allow "delete"
                if (this.comboBox1.Items.Count == 0)
                {
                    MessageBox.Show("Cannot Load. No Routes Exist", "No Routes Exist",
         MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            myThread = new Thread(new ThreadStart(parentForm.DisplayLoadingScreen));
            myThread.Start();

            // Load Selected Route
            // Get Name of Route
            string routeName = (string)this.comboBox1.SelectedItem;

            // Get All of the Anchors for that Route
            HttpClient c = new HttpClient();
            Task<string> allAnchorsAndInfo = c.GetStringAsync("https://sharingservice20200308094713.azurewebsites.net" + "/api/anchors/allForRoute/" +routeName);

            // Populate the table
            Console.WriteLine(allAnchorsAndInfo.Result);
            string[] outStrArray = allAnchorsAndInfo.Result.Replace("\"","").Replace("[", "").Replace("]", "").Split(',');
            parentForm.clearNewRouteTable();
            for (int i = 0; i < outStrArray.Length; i++)
            {
                List<string> outList = new List<string>();

                outList.Add(outStrArray[i].Split(':')[0]);
                outList.Add(outStrArray[i].Split(':')[1]);
                outList.Add(outStrArray[i].Split(':')[2]);
                outList.Add(outStrArray[i].Split(':')[3]);
                outList.Add(outStrArray[i].Split(':')[4]);
                parentForm.addRowToCurrentRouteTable(i, outList);
          }
            parentForm.newRouteTable.Visible = true;
            parentForm.newRouteTable.ReadOnly = true; // Don't allow edits
                                                      //    parentForm.newRouteTable.Rows[parentForm.newRouteTable.Rows.Count - 1].Cells["routeAnchorsForRemovalChkboxesCol"].Value = false;
            parentForm.newRouteTableLabel.Text = "Loaded Route";
            LoadingForm.setAbort();
            this.Close();
        }