Example #1
0
        private void info_delete(object sender, RoutedEventArgs e)
        {
            int count = this.info_list_dg.SelectedItems.Count;

            Member[] dt  = new Member[count];
            string[] ids = new string[count];
            for (int i = 0; i < count; i++)
            {
                dt[i] = this.info_list_dg.SelectedItems[i] as Member;
                try
                {
                    ids[i] = dt[i].id.ToString();
                }
                catch {
                    MessageBox.Show("没有选中");
                }
            }
            string all_id = string.Join(",", ids);
            string sql    = string.Format("delete from busi_control.crawl_info where id in ({0})", all_id);

            dol.dol dl = new dol.dol();
            try
            {
                Debug.WriteLine(sql);
                dl.getmysqlcom(sql);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally {
                load_datagrid();
            }
        }
Example #2
0
        /// <summary>
        /// 添加爬虫信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string busi   = this.busi.Text.Trim();
            string dev    = this.dev.Text.Trim();
            string logic  = this.logic.Text.Trim();
            string locate = this.locate.Text.Trim();
            string sql    = string.Format("insert into busi_control.crawl_info(busi,dev,logic,locate,status) values('{0}','{1}','{2}','{3}',{4})", busi, dev, logic, locate, 2);

            dol.dol d = new dol.dol();
            try
            {
                d.getmysqlcom(sql);
            }
            catch (Exception ex)
            {
                Debug.Write(ex.Message);
            }
            //info_list il = new info_list();
            //il.load_datagrid();
        }
Example #3
0
        /// <summary>
        /// 重新加载datagrid内容
        /// </summary>
        public void load_datagrid()
        {
            ObservableCollection <Member> memberdata = new ObservableCollection <Member>();

            dol.dol dl = new dol.dol();
            //dl.getmysqlcom("insert into crawl_info values(1,'crawl1','','','',1)");
            MySqlDataReader md = dl.getmysqlread("select * from busi_control.crawl_info");

            while (md.Read())
            {
                memberdata.Add(new Member()
                {
                    id     = md.GetInt32(0),
                    busi   = md.GetString(1),
                    dev    = md.GetString(2),
                    logic  = md.GetString(3),
                    locate = md.GetString(4),
                });
            }
            info_list_dg.DataContext = memberdata;
        }