protected void bntUpdateCatch_Click(object sender, EventArgs e)
 {
     if (txtCatchName.Text.Equals(""))
     {
         txtCatchName.Focus();
         return;
     }
     if (txtSiteName.Text.Equals(""))
     {
         txtSiteName.Focus();
         return;
     }
     if (ddlClassID.SelectedItem.Value == "-1")
     {
         ddlClassID.Focus();
         return;
     }
     try
     {
         DateTime dt = Convert.ToDateTime(txtNextTime.Text);
     }
     catch
     {
         txtNextTime.Focus();
         return;
     }
     try
     {
         int temp = Convert.ToInt32(txtTimespan.Text);
     }
     catch
     {
         txtTimespan.Focus();
         return;
     }
     StockFoo.Entity.Catch ch = new StockFoo.Entity.Catch();
     ch.Id = Convert.ToInt32(Request["id"]);
     ch.CatchName = txtCatchName.Text;
     ch.SiteName = txtSiteName.Text;
     ch.SiteEncode = Convert.ToInt32(ddlSiteEncode.SelectedItem.Value);
     ch.ClassId = Convert.ToInt32(ddlClassID.SelectedItem.Value);
     ch.CatalogUrl = txtCatalogUrl.Text;
     ch.CatalogXPath = txtCatalogXPath.Text;
     ch.CatalogRegex = txtCatalogRegex.Text;
     ch.ArticleXPath = txtArticleXPath.Text;
     ch.ArticleRegex = txtArticleRegex.Text;
     ch.ArticleTitleXPath = txtArticleTitleXPath.Text;
     ch.ArticleTitleRegex = txtArticleTitleRegex.Text;
     ch.ArticleTimeXPath = txtArticleTimeXPath.Text;
     ch.ArticleTimeRegex = txtArticleTimeRegex.Text;
     ch.ArticleTimeFormat = txtArticleTimeFormat.Text;
     if (rblEnabled.SelectedItem.Value == "1")
     {
         ch.Enabled = true;
     }
     else
     {
         ch.Enabled = false;
     }
     ch.NextTime = Convert.ToDateTime(txtNextTime.Text);
     ch.TimeSpan = Convert.ToInt32(txtTimespan.Text);
     int insertcount = UpdateCatchByID(ch);
     if (insertcount > 0)
     {
         Page.RegisterStartupScript("ok", "<script>alert('更新成功!');window.location.href='UpdateCatch.aspx?id="+Request["id"].ToString()+"';</script>");
     }
     else
     {
         Page.RegisterStartupScript("error", "<script>alert('更新失败!');</script>");
     }
 }
 protected void bntAddCatch_Click(object sender, EventArgs e)
 {
     if (txtCatchName.Text.Equals(""))
     {
         txtCatchName.Focus();
         return;
     }
     if (txtSiteName.Text.Equals(""))
     {
         txtSiteName.Focus();
         return;
     }
     if (ddlClassID.SelectedItem.Value == "-1")
     {
         ddlClassID.Focus();
         return;
     }
     try
     {
         DateTime dt = Convert.ToDateTime(txtNextTime.Text);
     }
     catch
     {
         txtNextTime.Focus();
         return;
     }
     try
     {
         int temp = Convert.ToInt32(txtTimespan.Text);
     }
     catch
     {
         txtTimespan.Focus();
         return;
     }
     StockFoo.Entity.Catch ch = new StockFoo.Entity.Catch();
     ch.Guid = Guid.NewGuid();
     ch.CatchName = txtCatchName.Text;
     ch.SiteName = txtSiteName.Text;
     ch.SiteEncode =Convert.ToInt32(ddlSiteEncode.SelectedItem.Value);
     ch.ClassId = Convert.ToInt32(ddlClassID.SelectedItem.Value);
     ch.CatalogUrl = txtCatalogUrl.Text;
     ch.CatalogXPath = txtCatalogXPath.Text;
     ch.CatalogRegex = txtCatalogRegex.Text;
     ch.ArticleXPath = txtArticleXPath.Text;
     ch.ArticleRegex = txtArticleRegex.Text;
     ch.ArticleTitleXPath =txtArticleTitleXPath.Text;
     ch.ArticleTitleRegex = txtArticleTitleRegex.Text;
     ch.ArticleTimeXPath = txtArticleTimeXPath.Text;
     ch.ArticleTimeRegex = txtArticleTimeRegex.Text;
     ch.ArticleTimeFormat = txtArticleTimeFormat.Text;
     if (rblEnabled.SelectedItem.Value == "1")
     {
         ch.Enabled = true;
     }
     else
     {
         ch.Enabled = false;
     }
     ch.NextTime =Convert.ToDateTime(txtNextTime.Text);
     ch.TimeSpan = Convert.ToInt32(txtTimespan.Text);
     int insertcount = InsertCatch(ch);
     if (insertcount > 0)
     {
         Page.RegisterStartupScript("ok", "<script>alert('添加成功!');</script>");
     }
     else
     {
         Page.RegisterStartupScript("error", "<script>alert('添加失败!');</script>");
     }
 }
 private StockFoo.Entity.Catch GetCatchByID(int id)
 {
     string sql = "select * from  [sf_Catch] where id=" + id;
     StockFoo.Entity.Catch ch = null;
     string conStr = ConfigurationManager.ConnectionStrings["Default"].ConnectionString;
     using (SqlConnection conn = new SqlConnection(conStr))
     {
         conn.Open();
         SqlCommand cmd = conn.CreateCommand();
         cmd.CommandType = CommandType.Text;
         cmd.CommandText = sql;
         SqlDataReader sdr = cmd.ExecuteReader();
         sdr.Read();
         ch = new StockFoo.Entity.Catch();
         ch.Id =(int)sdr["id"];
         ch.CatchName = sdr["catch_name"].ToString();
         ch.SiteName = sdr["site_name"].ToString();
         ch.SiteEncode = (int)sdr["site_encode"];
         ch.ClassId = (int)sdr["classid"];
         ch.CatalogUrl = sdr["catalog_url"].ToString();
         ch.CatalogXPath = sdr["catalog_xpath"].ToString();
         ch.CatalogRegex = sdr["catalog_regex"].ToString();
         ch.ArticleXPath = sdr["article_xpath"].ToString();
         ch.ArticleRegex = sdr["article_regex"].ToString();
         ch.ArticleTitleXPath = sdr["article_title_xpath"].ToString();
         ch.ArticleTitleRegex = sdr["article_title_regex"].ToString();
         ch.ArticleTimeXPath = sdr["article_time_xpath"].ToString();
         ch.ArticleTimeRegex = sdr["article_time_regex"].ToString();
         ch.ArticleTimeFormat = sdr["article_time_format"].ToString();
         ch.Enabled = (bool)sdr["enabled"];
         ch.NextTime = (DateTime)sdr["next_time"];
         ch.TimeSpan = Convert.ToInt32(sdr["timespan"]);
     }
     return ch;
 }