private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                int pp = 0;
                if (this.listView1.SelectedItems.Count > 0)
                {
                    string id = this.listView1.FocusedItem.SubItems[0].Text;

                    DialogResult dr = MessageBox.Show("确认删除吗?", "提示", MessageBoxButtons.OKCancel);
                    if (dr == DialogResult.OK)
                    {
                        string sql = string.Format("delete from EBTime_Strategy where id='{0}'", id);
                        mainForm.dba.DelDataBySQL(sql);
                        timestrategies SELECTED = SingletonInfo.GetInstance().audit.TimeList.Find(C => C.ID.Equals(id));
                        SingletonInfo.GetInstance().audit.TimeList.Remove(SELECTED);
                        pp = SingletonInfo.GetInstance().audit.TimeList.Count;
                        // MessageBox.Show("策略数量:"+ pp.ToString());
                        FlashData();
                    }
                }
                else
                {
                    MessageBox.Show("未选中任何行");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void GetAuditData()
        {
            string    sqlstr = "select * from EBTime_Strategy";
            DataTable dt     = mainForm.dba.getQueryInfoBySQL(sqlstr);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                timestrategies tt = new timestrategies();
                tt.ID        = dt.Rows[i][0].ToString();
                tt.StartTime = dt.Rows[i][1].ToString();
                tt.EndTime   = dt.Rows[i][2].ToString();
                tt.EvenType  = dt.Rows[i][3].ToString();
                SingletonInfo.GetInstance().audit.TimeList.Add(tt);
            }
        }
        private void btn_AddEvent_Click(object sender, EventArgs e)
        {
            string StartTime = dtp_StartTime.Text;
            string EndTime   = dtp_EndTime.Text;
            string EvenType  = cbb_Type.SelectedValue.ToString();
            string sql       = string.Format("insert into EBTime_Strategy values('{0}','{1}','{2}') SELECT CAST(scope_identity() AS int)", StartTime, EndTime, EvenType);

            int            ID = mainForm.dba.InsertDbBySQLRetID(sql);
            timestrategies pp = new timestrategies();

            pp.ID        = ID.ToString();
            pp.StartTime = StartTime;
            pp.EndTime   = EndTime;
            pp.EvenType  = EvenType;
            SingletonInfo.GetInstance().audit.TimeList.Add(pp);
            FlashData();
        }