예제 #1
0
        /// <summary>
        /// 生成缓存数据
        /// </summary>
        private void GenCacheData()
        {
            //以下缓存报警信息
            DataBaseServer.MySqlCmd dbobj = new DataBaseServer.MySqlCmd();
            string    sql = "select Id,EvidenceImgSavePath from systemset";
            DataTable dt  = dbobj.GetTabel(sql);
            SystemSet ss  = new SystemSet();

            if (dt != null && dt.Rows.Count > 0)
            {
                ss.Id = dt.Rows[0]["Id"].ToString();
                string path = dt.Rows[0]["EvidenceImgSavePath"].ToString();
                if (!Path.IsPathRooted(path))
                {
                    path = Path.GetFullPath(path);
                }
                ss.EvidenceImgSavePath = path;
            }
            else
            {
                //向数据库插入一条数据
                string path = Path.Combine(Directory.GetCurrentDirectory(), "EvidenceImgSavePath");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                sql = "insert into systemset values('1', 'EvidenceImgSavePath')";
                if (dbobj.ExecuteNonQueryInt(sql) > 0)
                {
                    ss.Id = "1";
                    ss.EvidenceImgSavePath = path;
                }
            }
            GlobalPars.GloPars.Add("systemset", ss);
        }
예제 #2
0
        private bool DeleteData()
        {
            if (MessageBox.Show("确定要删除选定的数据吗?删除后将无法恢复", "警告", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                DataGridViewSelectedRowCollection dvs = dataGridView1.SelectedRows;
                StringBuilder sb      = new StringBuilder("update ReleaseInfo set deleted=1 where uid in (");
                StringBuilder sb1     = new StringBuilder();
                List <string> removes = new List <string>();
                foreach (DataGridViewRow dr in dvs)
                {
                    string uid = dr.Cells["uid"].Value.ToString();
                    sb1.Append("," + uid);

                    removes.Add(uid);
                }

                string nextUid = "";
                if (removes.Count > 0)
                {
                    bool fund = false;
                    foreach (DataGridViewRow row in dataGridView1.Rows)
                    {
                        if (string.Compare(row.Cells["uid"].Value.ToString(), removes[0]) == 0)
                        {
                            fund = true;
                        }
                        if (fund)
                        {
                            if (string.Compare(row.Cells["uid"].Value.ToString(), removes[0]) != 0 && !removes.Contains(row.Cells["uid"].Value.ToString()))
                            {
                                nextUid = row.Cells["uid"].Value.ToString();
                                break;
                            }
                        }
                    }
                }

                sb.Append(sb1.Length > 1 ? sb1.ToString().Substring(1) : sb1.ToString());
                sb.Append(")");
                if (sb.Length > 48)
                {
                    cmd.ExecuteNonQueryInt(sb.ToString());
                }
                GetResultData();

                if (!string.IsNullOrEmpty(nextUid))
                {
                    foreach (DataGridViewRow row in dataGridView1.Rows)
                    {
                        if (string.Compare(row.Cells["uid"].Value.ToString(), nextUid) == 0)
                        {
                            dataGridView1.CurrentCell = row.Cells[0];
                            break;
                        }
                    }
                }
                else
                {
                    dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0];
                }
            }
            return(true);
        }
예제 #3
0
파일: MainForm.cs 프로젝트: wcgcw/Finder
        /// <summary>
        /// 生成缓存数据
        /// </summary>
        private void GenCacheData()
        {
            //以下缓存报警信息
            DataBaseServer.MySqlCmd dbobj = new DataBaseServer.MySqlCmd();
            string sql = "select Id,EvidenceImgSavePath from systemset";
            DataTable dt = dbobj.GetTabel(sql);
            SystemSet ss = new SystemSet();
            if (dt != null && dt.Rows.Count > 0)
            {
                ss.Id = dt.Rows[0]["Id"].ToString();
                string path = dt.Rows[0]["EvidenceImgSavePath"].ToString();
                if (!Path.IsPathRooted(path))
                {
                    path = Path.GetFullPath(path);
                }
                ss.EvidenceImgSavePath = path;
            }
            else
            {
                //向数据库插入一条数据
                string path = Path.Combine(Directory.GetCurrentDirectory(), "EvidenceImgSavePath");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                sql = "insert into systemset values('1', 'EvidenceImgSavePath')";
                if (dbobj.ExecuteNonQueryInt(sql) > 0)
                {
                    ss.Id = "1";
                    ss.EvidenceImgSavePath = path;
                }
            }
            GlobalPars.GloPars.Add("systemset", ss);
        }