private void goButton_Click(object sender, EventArgs e)
        {
            try
            {
                bool found;
                var  row = dal.GetWebsiteRow(websiteNameTextBox.Text, out found);
                if (found)
                {
                    urlTextBox.Text = row.url;
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
                return;
            }
            if ((!urlTextBox.Text.StartsWith("http://")) &&
                (!urlTextBox.Text.StartsWith("https://")) &&
                (!urlTextBox.Text.StartsWith("file://")))
            {
                urlTextBox.Text = "http://" + urlTextBox.Text;
            }
            if ((Uri.IsWellFormedUriString(urlTextBox.Text, UriKind.RelativeOrAbsolute)) || urlTextBox.Text.StartsWith("file://"))
            {
                try
                {
                    webBrowser.Navigate(urlTextBox.Text);
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                    return;
                }
                try
                {
                    WebsiteID  = dal.GetWebsiteID(urlTextBox.Text);
                    WebsiteRow = dal.GetWebsiteRow(urlTextBox.Text);
                }
                catch (Exception exc)
                {
                    MessageBox.Show("Internal Error:" + exc.Message);
                    Application.Exit();
                }

                // New Website
                if (WebsiteID < 0)
                {
                    if (websiteNameTextBox.Text.Length > 0)
                    {
                        awaDAL.AutoWebAgentDBDataSet.websiteRow row = dal.DB.website.AddwebsiteRow(websiteNameTextBox.Text, urlTextBox.Text);
                    }
                    else
                    {
                        awaDAL.AutoWebAgentDBDataSet.websiteRow row = dal.DB.website.AddwebsiteRow(urlTextBox.Text, urlTextBox.Text);
                    }
                    dal.SaveChanges("website");
                    WebsiteID  = dal.GetWebsiteID(urlTextBox.Text);
                    WebsiteRow = dal.GetWebsiteRow(urlTextBox.Text);
                }
                //update website
                else
                {
                    if (websiteNameTextBox.Text.Length > 0)
                    {
                        dal.DB.website.FindByid(WebsiteID).name = websiteNameTextBox.Text;
                    }
                    else
                    {
                        websiteNameTextBox.Text = dal.DB.website.FindByid(WebsiteID).name;
                    }
                }
                updateGrid();
            }
            else
            {
                MessageBox.Show("URL Error");
            }
        }
Beispiel #2
0
        private void goButton_Click(object sender, EventArgs e)
        {
            try
            {
                bool found;

                var row = dal.GetWebsiteRow(websiteNameTextBox.Text, out found);
                if (found)
                {
                    DialogResult res = DialogResult.No;
                    if (row.url != urlTextBox.Text)
                    {
                        res = MessageBox.Show("Entered URL and saved URL are Conflicted,\nPress Yes to save the Entered URL,\nPress NO to use the saved URL",
                                              "URL COnflict Detected", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    }
                    if (res == DialogResult.Yes)
                    {
                        if ((!urlTextBox.Text.StartsWith("http://")) &&
                            (!urlTextBox.Text.StartsWith("https://")) &&
                            (!urlTextBox.Text.StartsWith("file://")))
                        {
                            urlTextBox.Text = "http://" + urlTextBox.Text;
                        }
                        if ((Uri.IsWellFormedUriString(urlTextBox.Text, UriKind.RelativeOrAbsolute)) || urlTextBox.Text.StartsWith("file://"))
                        {
                            row.url = urlTextBox.Text;
                            dal.SaveChanges("website");
                        }
                    }
                    else
                    {
                        urlTextBox.Text = row.url;
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
                return;
            }
            if ((!urlTextBox.Text.StartsWith("http://")) &&
                (!urlTextBox.Text.StartsWith("https://")) &&
                (!urlTextBox.Text.StartsWith("file://")))
            {
                urlTextBox.Text = "http://" + urlTextBox.Text;
            }
            if ((Uri.IsWellFormedUriString(urlTextBox.Text, UriKind.RelativeOrAbsolute)) || urlTextBox.Text.StartsWith("file://"))
            {
                try
                {
                    WebsiteID  = dal.GetWebsiteID(urlTextBox.Text);
                    WebsiteRow = dal.GetWebsiteRow(urlTextBox.Text);
                }
                catch (Exception exc)
                {
                    MessageBox.Show("Internal Error:" + exc.Message);
                    Application.Exit();
                }
                // New Website
                if (WebsiteID < 0)
                {
                    if (websiteNameTextBox.Text.Length > 0)
                    {
                        awaDAL.AutoWebAgentDBDataSet.websiteRow row = dal.DB.website.AddwebsiteRow(websiteNameTextBox.Text, urlTextBox.Text);
                    }
                    else
                    {
                        awaDAL.AutoWebAgentDBDataSet.websiteRow row = dal.DB.website.AddwebsiteRow(urlTextBox.Text, urlTextBox.Text);
                    }
                    dal.SaveChanges("website");
                    WebsiteID  = dal.GetWebsiteID(urlTextBox.Text);
                    WebsiteRow = dal.GetWebsiteRow(urlTextBox.Text);
                }
                //update website
                else
                {
                    if (websiteNameTextBox.Text.Length > 0)
                    {
                        WebsiteRow.name = websiteNameTextBox.Text;
                    }
                    else
                    {
                        websiteNameTextBox.Text = WebsiteRow.name;
                    }
                }
                updateGrid();
                try
                {
                    webBrowser.Navigate(urlTextBox.Text);
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                    return;
                }
            }
            else
            {
                MessageBox.Show("URL Error");
            }
        }