private bool GetNozzleListFromDB() { string queryString = "select * from nozzle"; try { Global.nozzleList.Clear(); DataTable dt = Global.mysqlHelper.GetDataTable(queryString); if (dt == null || dt.Rows.Count < 1) { return(true); } foreach (DataRow dr in dt.Rows) { ClsNozzle nozzle = new ClsNozzle(); nozzle.id = int.Parse(dr["id"].ToString()); nozzle.parentid = int.Parse(dr["parentid"].ToString()); nozzle.nozzleNo = int.Parse(dr["nozzleno"].ToString()); nozzle.oilType = int.Parse(dr["oiltype"].ToString()); nozzle.areaid = int.Parse(dr["areaid"].ToString()); nozzle.subAreaid = int.Parse(dr["subareaid"].ToString()); Global.nozzleList.Add(nozzle); Global.LogServer.Add(new LogInfo("ParamSet-Debug", "Main->GetNozzleListFromDB nozzleNo:" + nozzle.nozzleNo.ToString(), (int)EnumLogLevel.DEBUG)); } return(true); } catch (System.Exception ex) { Global.LogServer.Add(new LogInfo("ParamSet-Error", "Main->InitParam->GetNozzleListFromDB 运行初始化失败:" + ex.Message, (int)EnumLogLevel.ERROR)); return(false); } }
private void hk_btnAdd_Click(object sender, EventArgs e) { if (hk_comboNoz.SelectedIndex < 2) { if (hk_comboMainVideoChan1.Text != "") { int videoChan = int.Parse(hk_comboMainVideoChan1.Text); int vchLane = hk_comboMainVideoArea1.SelectedIndex + 1; int id = HK_FindRecogAreaInVideoChan(videoChan, vchLane); int nozNo = hk_comboNoz.SelectedIndex + 98; //入口99 出口100 if (id > 0) { string sql = "insert into nozzle_area (nozzleNo,areaid,linkmode) values (" + nozNo.ToString() + "," + id.ToString() + ",1)"; Global.mysqlHelper.ExecuteSql(sql); FlushDGV_HK(); MessageBox.Show("添加出入口成功!"); } } return; } ClsNozzle nozzle = new ClsNozzle(); nozzle.nozzleNo = int.Parse(hk_comboNoz.Text); nozzle.oilType = hk_comboOilType.SelectedIndex; nozzle.areaid = 0; nozzle.subAreaid = 0; nozzle.id = Global.mysqlHelper.ExecuteSql(nozzle.getInsertString()); Global.nozzleList.Add(nozzle); StringBuilder sbSql = new StringBuilder(); sbSql.Append("insert into nozzle_area (nozzleNo,areaid,linkmode) values"); if (hk_comboMainVideoChan1.Text != "") { int videoChan = int.Parse(hk_comboMainVideoChan1.Text); int vchLane = hk_comboMainVideoArea1.SelectedIndex + 1; int id = HK_FindRecogAreaInVideoChan(videoChan, vchLane); if (id > 0) { sbSql.Append(" ( " + nozzle.nozzleNo.ToString() + "," + id.ToString() + ",1)"); } } if (hk_comboMainVideoChan2.SelectedIndex != 0) { int videoChan = int.Parse(hk_comboMainVideoChan2.Text); int vchLane = hk_comboMainVideoArea2.SelectedIndex + 1; int id = HK_FindRecogAreaInVideoChan(videoChan, vchLane); if (id > 0) { sbSql.Append(" ,( " + nozzle.nozzleNo.ToString() + "," + id.ToString() + ",1)"); } } if (hk_comboSubVideoChan1.SelectedIndex != 0) { int videoChan = int.Parse(hk_comboSubVideoChan1.Text); int vchLane = hk_comboSubVideoArea1.SelectedIndex + 1; int id = HK_FindRecogAreaInVideoChan(videoChan, vchLane); if (id > 0) { sbSql.Append(" ,( " + nozzle.nozzleNo.ToString() + "," + id.ToString() + ",2)"); } } if (hk_comboSubVideoChan2.SelectedIndex != 0) { int videoChan = int.Parse(hk_comboSubVideoChan2.Text); int vchLane = hk_comboSubVideoArea2.SelectedIndex + 1; int id = HK_FindRecogAreaInVideoChan(videoChan, vchLane); if (id > 0) { sbSql.Append(" ,( " + nozzle.nozzleNo.ToString() + "," + id.ToString() + ",2)"); } } Global.mysqlHelper.ExecuteSql(sbSql.ToString()); FlushDGV_HK(); hk_btnAdd.Enabled = false; hk_btnDelete.Enabled = true; Global.LogServer.Add(new LogInfo("ParamSet-Debug", sbSql.ToString(), (int)EnumLogLevel.DEBUG)); MessageBox.Show("油枪添加成功!"); }
private void AddOrUpdateArea(int AoU) { switch (AoU) { case 1: foreach (ClsNVRInfo nvr in Global.nvrList) { if (nvr.nvrName == Global.sCurSelectedNvrName) { foreach (ClsVideoChannel video in nvr.videoList) { if (video.channelNo == Global.nCurSelectedVideoChan) { ClsRecogArea area = new ClsRecogArea(); area.videoid = video.id; area.left = (double)Math.Round((decimal)struDrawInfo.start.X / this.videoBox.Width, 4); area.right = (double)Math.Round((decimal)struDrawInfo.end.X / this.videoBox.Width, 4); area.top = (double)Math.Round((decimal)struDrawInfo.start.Y / this.videoBox.Height, 4); area.bottom = (double)Math.Round((decimal)struDrawInfo.end.Y / this.videoBox.Height, 4); area.videoLaneNo = comboHKArea.SelectedIndex + 1; area.id = Global.mysqlHelper.ExecuteSql(area.getInsertString()); Global.recogAreaList.Add(area); video.areaList.Add(area); return; } } } } break; case 2: foreach (ClsRecogArea area in Global.recogAreaList) { if (area.id.ToString() == comboArea.Text.Trim()) { area.left = (double)Math.Round((decimal)struDrawInfo.start.X / this.videoBox.Width, 4); area.right = (double)Math.Round((decimal)struDrawInfo.end.X / this.videoBox.Width, 4); area.top = (double)Math.Round((decimal)struDrawInfo.start.Y / this.videoBox.Height, 4); area.bottom = (double)Math.Round((decimal)struDrawInfo.end.Y / this.videoBox.Height, 4); Global.mysqlHelper.ExecuteSql(area.getUpdateString()); } } break; case 3: ClsNozzle nozzle = new ClsNozzle(); nozzle.nozzleNo = int.Parse(comboNozzleNo.Text); nozzle.oilType = comboOilType.SelectedIndex; nozzle.areaid = int.Parse(comboMainArea.Text); nozzle.id = Global.mysqlHelper.ExecuteSql(nozzle.getInsertString()); string linkSqlString = "insert into nozzle_area (nozzleNo,areaid,linkmode) values (" + nozzle.nozzleNo.ToString() + "," + comboMainArea.Text + ",1)"; nozzle.linkedMainAreaList.Add(int.Parse(comboMainArea.Text)); if (comboMainArea2.Text != "不使用") { linkSqlString += ",(" + nozzle.nozzleNo.ToString() + "," + comboMainArea.Text + ",1)"; nozzle.linkedMainAreaList.Add(int.Parse(comboMainArea2.Text)); } if (comboSubArea.Text != "不使用") { linkSqlString += ",(" + nozzle.nozzleNo.ToString() + "," + comboSubArea.Text + ",2)"; nozzle.linkedSubAreaList.Add(int.Parse(comboSubArea.Text)); } if (comboSubArea2.Text != "不使用") { linkSqlString += ",(" + nozzle.nozzleNo.ToString() + "," + comboSubArea2.Text + ",2)"; nozzle.linkedSubAreaList.Add(int.Parse(comboSubArea2.Text)); } Global.mysqlHelper.ExecuteSql(linkSqlString); Global.nozzleList.Add(nozzle); break; case 4: break; default: break; } }