Exemplo n.º 1
0
 protected void btEdit_Click(object sender, EventArgs e)
 {
     if (!this.tb_url.Disabled)
     {
         try
         {
             dhuc = new GitHubUrlContext();
             using (SqlConnection conn = new SqlConnection(dhuc.Database.Connection.ConnectionString))
             {
                 string     query = String.Format(CultureInfo.InvariantCulture, "UPDATE [URLS] SET [Url] = '{0}' WHERE Id = {1};", this.tb_url.Value, this.hdField.Value);
                 SqlCommand com   = new SqlCommand(query, conn);
                 conn.Open();
                 if (com.ExecuteNonQuery() == 1)
                 {
                     SelectGridView(dhuc);
                     DisabledTexBox();
                     message.CssClass = "validation_success";
                     message.Text     = "edit url";
                 }
             }
         }
         catch (Exception ex)
         {
             DisabledTexBox();
             message.CssClass = "validation_error";
             message.Text     = ex.Message;
         }
     }
     else
     {
         DisabledTexBox();
         message.CssClass = "validation_error";
         message.Text     = "tex box disabled";
     }
 }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //int countUrl = Convert.ToInt32(Request.QueryString["cu"], CultureInfo.InvariantCulture);

            try
            {
                using (GitHubUrlContext context = new GitHubUrlContext())
                {
                    using (SqlConnection conn = new SqlConnection(context.Database.Connection.ConnectionString))
                    {
                        string     query = String.Format(CultureInfo.InvariantCulture, "SELECT [URLS].[Url] FROM [URLS]");
                        SqlCommand com   = new SqlCommand(query, conn);
                        conn.Open();
                        using (SqlDataReader reader = com.ExecuteReader())
                        {
                            Uri uri;
                            while (reader.Read())
                            {
                                uri = new Uri((string)reader[0]);
                                string[] res = uri.Segments;
                                GetInfo(res[1].Substring(0, res[1].Length - 1), res[2]);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                message.Text = ex.Message;
            }
        }
Exemplo n.º 3
0
        protected void btAdd_Click(object sender, EventArgs e)
        {
            if (!this.tb_url.Disabled)
            {
                Ping      p  = new Ping();
                PingReply pr = p.Send(@"github.com");
                status = pr.Status;
                reg    = new Regex(pattern);

                try
                {
                    if (status == IPStatus.Success && tb_url.Value.Length > 0 &&
                        reg.Match(tb_url.Value, 0).Value == "github.com")
                    {
                        try
                        {
                            dhuc = new GitHubUrlContext();
                            using (SqlConnection conn = new SqlConnection(dhuc.Database.Connection.ConnectionString))
                            {
                                string     query = String.Format(CultureInfo.InvariantCulture, "INSERT INTO [URLS] VALUES ('{0}')", tb_url.Value);
                                SqlCommand com   = new SqlCommand(query, conn);
                                conn.Open();
                                if (com.ExecuteNonQuery() == 1)
                                {
                                    SelectGridView(dhuc);
                                    DisabledTexBox();
                                    message.CssClass = "validation_success";
                                    message.Text     = "add url github.com";
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            DisabledTexBox();
                            message.CssClass = "validation_error";
                            message.Text     = ex.Message;
                        }
                    }
                }
                catch (Exception expt)
                {
                    DisabledTexBox();
                    message.CssClass = "validation_error";
                    message.Text     = expt.Message;
                }
            }
            else
            {
                DisabledTexBox();
                message.CssClass = "validation_error";
                message.Text     = "tex box disabled";
            }
        }
Exemplo n.º 4
0
 private void SelectGridView(GitHubUrlContext gitHubUrlContext)
 {
     try
     {
         SqlDataSourceUrl.ConnectionString = gitHubUrlContext.Database.Connection.ConnectionString;
         SqlDataSourceUrl.SelectCommand    = "SELECT * FROM [URLS]";
         GridViewUrl.DataSourceID          = SqlDataSourceUrl.ID;
         GridViewUrl.RowDataBound         += GridViewUrl_RowDataBound;
     }
     catch (Exception ex)
     {
         message.Text = ex.Message;
     }
     finally
     {
         gitHubUrlContext.Dispose();
     }
 }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                this.regUrl.CssClass = "validation_error";

                dhuc = new GitHubUrlContext();
                SelectGridView(dhuc);

                message.Text = String.Empty;
                if (!IsPostBack)
                {
                    this.tb_url.Value = String.Empty;
                    tb_url.Disabled   = true;
                }
            }
            catch (Exception ex)
            {
                this.message.Text = ex.Message;
            }
        }