Exemplo n.º 1
0
        public void BindData()
        {
            string sql = "";

            sql  = "select t.id ID,a.add_display  位置,d.resource_name 设备,t.start_time 开始,t.end_time 结束,tr.tru_name 指廊,ter.ter_name 航站楼,t.description 消息 from ";
            sql += " B_DEVICES_MSG t,b_devices_addtype a,b_devices_funtype f,b_devices d,b_terminals ter,b_trunks tr where";
            sql += " a.id(+)=t.addtype_id and f.id(+)=t.funtype_id and d.id(+)=t.devices_id and tr.tru_id(+)=t.tru_id and ter.ter_id(+)=t.ter_id";
            sql += " order by t.id desc";
            DataTable dt = ora.GetDt(sql);

            dgv_msg.DataSource = dt;
            for (int i = 0; i < dgv_msg.Columns.Count; i++)
            {
                if (dgv_msg.Columns[i].Name == "消息")
                {
                    dgv_msg.Columns[i].Width = 460;
                    // dgv_msg.Columns[i].DefaultCellStyle = Color.Red;
                    //break;
                }
                if (dgv_msg.Columns[i].Name == "ID" || dgv_msg.Columns[i].Name == "设备" || dgv_msg.Columns[i].Name == "指廊" || dgv_msg.Columns[i].Name == "航站楼")
                {
                    dgv_msg.Columns[i].Width = 65;
                }
            }
            // string sqlcount = "select count(*) from B_DEVICES_MSG t,b_devices_addtype a,b_devices_funtype f,b_devices d,b_terminals ter,b_trunks tr where a.id(+)=t.addtype_id and f.id(+)=t.funtype_id and d.id(+)=t.devices_id and tr.tru_id(+)=t.tru_id and ter.ter_id(+)=t.ter_id";
            label1.Text = "消息总数:" + ora.GetRecordCount(sql);
        }
Exemplo n.º 2
0
        private bool Ishave(TextBox txt)
        {
            bool      flag = false;
            DataTable dt   = ora.GetDt("select t.sip from B_DEVICES t");

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["sip"].ToString() == txt.Text && txt.Text != Ip)
                    {
                        flag = true;
                        break;
                    }
                }
                return(flag);
            }
            else
            {
                flag = false;
                return(flag);
            }
        }
Exemplo n.º 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (CheckInput(txtname) == false)
     {
         MessageBox.Show("只能输入数字,中文或者字母,请不要非法输入!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     else
     {
         ora = new OracleHelper(constr);
         DataTable dt = ora.GetDt("select distinct t.pos_tc  from b_devices t where t.pos_tc is not null");
         //string path = System.Environment.CurrentDirectory + "//config//Position.txt";      //读取Position文件中显示层
         if (txtname.Text == "" || txtname.Text == null)
         {
             MessageBox.Show("请输入图层名称!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (dt.Rows.Count > 0)
         {
             //string str = File.ReadAllText(path);
             // string[] line = File.ReadAllLines(path, Encoding.Default);
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 if (dt.Rows[i]["pos_tc"].ToString() == txtname.Text.ToString().Trim())
                 {
                     MessageBox.Show("图层名称已经存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     return;
                 }
             }
         }
         if (openFileDialog1.ShowDialog() == DialogResult.OK)
         {
             string   oldName   = openFileDialog1.FileName;
             string[] splitName = oldName.Split('.');
             string   ext       = splitName[splitName.Length - 1];
             string   dbName    = "\\images\\" + txtname.Text.ToString().Trim() + "." + ext;
             string   newName   = System.Environment.CurrentDirectory + dbName;
             File.Copy(oldName, newName, true);
             //File.AppendAllText(path, txtname.Text.ToString().Trim() + "\r\n");
             ora.ExecuteSql("insert into b_devices_addtype values (SEQ_B_DEVICES_ADDTYPE.NEXTVAL,'','" + txtname.Text.Trim() + "','LGH','')");
             string paths = System.Environment.CurrentDirectory + "//config//" + txtname.Text.ToString().Trim() + ".txt";
             if (File.Exists(paths) == false)
             {
                 File.CreateText(paths);
             }
             MessageBox.Show("图层已经成功添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtname.Text = "";
         }
     }
 }
Exemplo n.º 4
0
        private void Addmenu()     //根据txt文件,动态添加菜单
        {
            //添加菜单一
            ToolStripMenuItem subItem;

            subItem = AddContextMenu("航显位置", menuStrip1.Items, null);
            // string path = System.Environment.CurrentDirectory+"//config//Position.txt";
            ora = new OracleHelper(constr);
            // MessageBox.Show(path);
            DataTable dt = ora.GetDt("select distinct t.pos_tc  from b_devices t where t.pos_tc is not null");

            if (dt.Rows.Count > 0)
            {
                // string[] str = File.ReadAllLines(path, Encoding.UTF8);
                //FileStream fs = new FileStream(path, FileMode.Open);
                //StreamReader sr = new StreamReader(fs, Encoding.Default);
                //string line = sr.re
                //sr.Close();
                //fs.Close();
                //string[] str = line.Split('@');
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    AddContextMenu(dt.Rows[i]["pos_tc"].ToString(), subItem.DropDownItems, new EventHandler(MenuClicked));  //添加子菜单
                }
                // MessageBox.Show(line);
            }
            else
            {
                MessageBox.Show("数据库无任何数据,请检查!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            //添加菜单二
            subItem = AddContextMenu("人工操作", menuStrip1.Items, null);
            //添加子菜单
            AddContextMenu("重启全部终端", subItem.DropDownItems, new EventHandler(MenuClicked));
            AddContextMenu("重启全部程序", subItem.DropDownItems, new EventHandler(MenuClicked));
            AddContextMenu("关闭全部终端", subItem.DropDownItems, new EventHandler(MenuClicked));
            // AddContextMenu("发布消息", subItem.DropDownItems, new EventHandler(MenuClicked));
            AddContextMenu("管理消息", subItem.DropDownItems, new EventHandler(MenuClicked));
            // AddContextMenu("远程开机全部终端", subItem.DropDownItems, new EventHandler(MenuClicked));
            //添加菜单三
            subItem = AddContextMenu("配置编辑", menuStrip1.Items, null);
            //添加子菜单
            // AddContextMenu("新增图层", subItem.DropDownItems, new EventHandler(MenuClicked));
            AddContextMenu("变更图层", subItem.DropDownItems, new EventHandler(MenuClicked));
            AddContextMenu("新增点位", subItem.DropDownItems, new EventHandler(MenuClicked));
            AddContextMenu("重启本程序", subItem.DropDownItems, new EventHandler(MenuClicked));
            // AddContextMenu("删除点位", subItem.DropDownItems, new EventHandler(MenuClicked));
        }
Exemplo n.º 5
0
        private void BindData()
        {
            DataTable dt = ora.GetDt("select t.id,t.add_display from B_DEVICES_ADDTYPE t");

            cmbgn.DataSource = dt;
            dt.Rows.Add(-10, "空");
            cmbgn.ValueMember   = "id";
            cmbgn.DisplayMember = "add_display";
            cmbgn.SelectedIndex = 0;
            //DataTable dt1 = ora.GetDt("select t.tru_id,t.tru_display from B_TRUNKS t");
            //cmbzl.DataSource = dt1;
            //cmbzl.ValueMember = "tru_id";
            //cmbzl.DisplayMember = "tru_display";
            //cmbzl.SelectedIndex = 0;
        }
Exemplo n.º 6
0
        private void BindCombox()
        {
            ora = new OracleHelper(constr);
            DataTable dt = ora.GetDt("select distinct t.pos_tc  from b_devices t where t.pos_tc is not null");

            comboBox1.Items.Clear();
            if (dt.Rows.Count > 0)
            {
                // string str = File.ReadAllText(path);
                //string[] line = File.ReadAllLines(path, Encoding.UTF8);
                comboBox1.DataSource    = dt;
                comboBox1.ValueMember   = "pos_tc";
                comboBox1.DisplayMember = "pos_tc";
                comboBox1.SelectedIndex = 0;
            }
        }
Exemplo n.º 7
0
        private void BindCombox()
        {
            ora = new OracleHelper(constr);
            DataTable dt = ora.GetDt("select * from B_DEVICES_ADDTYPE t where t.terminal='LGH'");

            comboBox1.Items.Clear();
            if (dt.Rows.Count > 0)
            {
                // string str = File.ReadAllText(path);
                //string[] line = File.ReadAllLines(path, Encoding.UTF8);
                comboBox1.DataSource    = dt;
                comboBox1.ValueMember   = "ID";
                comboBox1.DisplayMember = "ADD_DISPLAY";
                //  comboBox1.Items.Clear();
                comboBox1.Text = Flag;
            }
        }
Exemplo n.º 8
0
 private void btnfb_Click(object sender, EventArgs e)
 {
     if (CheckInput(txtnr) == false)
     {
         label5.Text    = "只能输入中文字符,标点符号,英文,数字,下划线。但不能输入@,#,$,%,^,&,*  等特殊字符";
         label5.Visible = true;
         return;
     }
     if (CheckDTP(dtpks, dtpjs) == false)
     {
         MessageBox.Show("结束时间必须大于开始时间,请重新选择时间!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     else
     {
         try
         {
             DataTable dt = ora.GetDt("select t.id from B_DEVICES t where t.sip='" + Ip + "' ");
             if (dt.Rows.Count > 0)
             {
                 int d_id = Int32.Parse(dt.Rows[0]["id"].ToString());
                 ora.ExecuteSql("insert into b_devices_msg (id,devices_id,start_time,end_time,description,release_time,ter_id) values (SEQ_B_DEVICES_MSG.NEXTVAL," + d_id + ",to_date('" + dtpks.Text + "','yyyy-mm-dd hh24:mi:ss'),to_date('" + dtpjs.Text + "','yyyy-mm-dd hh24:mi:ss'),'" + txtnr.Text.Trim() + "',sysdate,1)");  //1代表T1航站楼
                 MessageBox.Show("消息发布成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show("没有找到IP为" + Ip + "的相关数据,请先检查数据库!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString(), "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
 }
Exemplo n.º 9
0
        public void AddbuttonInfo(string picPath)
        {
            try
            {
                string       paths = System.Environment.CurrentDirectory + "//config//Size.txt"; //读取Size文件中button的size值(宽和高)
                FileStream   fss   = new FileStream(paths, FileMode.Open);
                StreamReader srr   = new StreamReader(fss, Encoding.Default);
                string       lines = srr.ReadToEnd();
                srr.Close();
                fss.Close();
                string[]  size = lines.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                DataTable dt   = ora.GetDt("select t.id, t.resource_name,t.sip,t.pos_x,t.pos_y,t.pos_tc from B_DEVICES t");
                //string path = System.Environment.CurrentDirectory + configPath;
                pictureBox1.Image = Image.FromFile(picPath);
                // MessageBox.Show(path);
                if (dt.Rows.Count > 0)
                {
                    //FileStream fs = new FileStream(path, FileMode.Open);                    //读取出港大厅配置文件详细信息
                    // StreamReader sr = new StreamReader(fs, Encoding.Default);
                    // string line = sr.ReadToEnd();
                    //sr.Close();
                    // fs.Close();
                    // string[] str = line.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                    //Button[] btn = new Button[str.Length];

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["pos_tc"].ToString() == "")
                        {
                            ora.ExecuteSql("update b_devices t set t.pos_x='1024',t.pos_y='768',t.pos_tc='" + Name + "' where t.id=" + Int32.Parse(dt.Rows[i]["id"].ToString()) + "");
                        }
                    }
                }
                dt = ora.GetDt("select t.id, t.resource_name,t.sip,t.pos_x,t.pos_y,t.pos_tc from B_DEVICES t");
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["pos_tc"].ToString() == Name)
                        {
                            if (list.Contains(dt.Rows[i]["resource_name"].ToString() + "," + dt.Rows[i]["sip"].ToString()) == false)
                            {
                                list.Add(dt.Rows[i]["resource_name"].ToString() + "," + dt.Rows[i]["sip"].ToString());
                            }
                            Button btn = new Button();                               //动态添加button按钮
                            btn.Parent           = this.pictureBox1;
                            btn.ContextMenuStrip = contextMenuStrip1;

                            //btn.Top = 25 * i;
                            btn.Name = dt.Rows[i]["resource_name"].ToString();
                            btn.Text = dt.Rows[i]["sip"].ToString();
                            // btn.ContextMenuStrip =
                            btn.Size = new System.Drawing.Size(Int32.Parse(size[0]), Int32.Parse(size[1]));
                            // btn.BackColor = Color.Red;
                            btn.Image = Image.FromFile("png/断开.png");
                            btn.Font  = new System.Drawing.Font(btn.Font.FontFamily, 1, btn.Font.Style);
                            //btn.Left = Int32.Parse(Math.Round(((rect.Width) * float.Parse(info[2]))).ToString());
                            //btn.Top = Int32.Parse(Math.Round(((rect.Height) * float.Parse(info[3]))).ToString());
                            btn.Location = new Point(Int32.Parse(dt.Rows[i]["pos_x"].ToString()), Int32.Parse(dt.Rows[i]["pos_y"].ToString()));
                            ShowInfo(btn, dt.Rows[i]["resource_name"].ToString(), dt.Rows[i]["sip"].ToString());
                            // Setposition_button(btn,float.Parse(info[2]),float.)
                            // btn.Click += new EventHandler(btn_Click);
                            btn.MouseMove += new System.Windows.Forms.MouseEventHandler(btn_MouseMove);
                            btn.MouseDown += new System.Windows.Forms.MouseEventHandler(btn_MouseDown);
                            btn.MouseUp   += new System.Windows.Forms.MouseEventHandler(btn_MouseUp);
                            this.pictureBox1.Controls.Add(btn);
                            // this.Controls.Add(btn);
                        }
                    }

                    BindMenu();
                }
                //MessageBox.Show(list.Count.ToString());
                // MessageBox.Show(line);


                else
                {
                    MessageBox.Show("数据库无数据,请检查!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 10
0
 private void button1_Click(object sender, EventArgs e)
 {
     // string path = System.Environment.CurrentDirectory + "//config//" + Flag + ".txt";
     //if(File.Exists(path))
     //{
     //    string[] line = File.ReadAllLines(path, Encoding.UTF8);
     //foreach(string str in line)
     //{
     //    if (str.Contains(txtname.Text + "," + txtipaddr.Text) || str.Contains(txtname.Text) || str.Contains(txtipaddr.Text))
     //    {
     //        MessageBox.Show("此点位已经存在,请重新添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     //        return;
     //    }
     //}
     //StreamWriter sw = new StreamWriter(path, true);
     //sw.WriteLine(txtname.Text+","+txtipaddr.Text+","+txtX.Text+","+txtY.Text);
     //sw.Close();
     if (checkBox1.Checked == false)
     {
         if (CheckTxtbox() == false)
         {
             return;
         }
         try
         {
             if (Ishave(txtipaddr) == false)
             {
                 ora.ExecuteSql("insert into b_devices (id,sip,resource_name,pos_x,pos_y,pos_tc) values (SEQ_B_DEVICES.NEXTVAL,'" + txtipaddr.Text + "','" + txtname.Text + "','" + txtX.Text + "','" + txtY.Text + "','" + comboBox1.Text + "')");
                 Anj_Jk frm = (Anj_Jk)this.Owner;
                 frm.DeleteButton();
                 frm.AddbuttonInfo("images/" + Flag + ".jpg");
             }
             else
             {
                 MessageBox.Show("此点位已经存在,请重新添加!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString(), "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         if (CheckTxtbox() == false)
         {
             return;
         }
         if (CheckInput(txttc) == false)
         {
             txtname.BackColor = Color.Red;
             return;
         }
         else
         {
             ora = new OracleHelper(constr);
             DataTable dt = ora.GetDt("select distinct t.pos_tc  from b_devices t where t.pos_tc is not null");
             //string path = System.Environment.CurrentDirectory + "//config//Position.txt";      //读取Position文件中显示层
             if (txtname.Text == "" || txtname.Text == null)
             {
                 MessageBox.Show("请输入图层名称!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
             if (dt.Rows.Count > 0)
             {
                 //string str = File.ReadAllText(path);
                 // string[] line = File.ReadAllLines(path, Encoding.Default);
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
                     if (dt.Rows[i]["pos_tc"].ToString() == txtname.Text.ToString().Trim())
                     {
                         MessageBox.Show("图层名称已经存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         return;
                     }
                 }
             }
             if (openFileDialog1.ShowDialog() == DialogResult.OK)
             {
                 string   oldName   = openFileDialog1.FileName;
                 string[] splitName = oldName.Split('.');
                 string   ext       = splitName[splitName.Length - 1];
                 string   dbName    = "\\images\\" + txttc.Text.ToString().Trim() + "." + ext;
                 string   newName   = System.Environment.CurrentDirectory + dbName;
                 File.Copy(oldName, newName, true);
                 //File.AppendAllText(path, txtname.Text.ToString().Trim() + "\r\n");
                 ora.ExecuteSql("insert into b_devices (id,sip,resource_name,pos_x,pos_y,pos_tc) values (SEQ_B_DEVICES.NEXTVAL,'" + txtipaddr.Text + "','" + txtname.Text + "','" + txtX.Text + "','" + txtY.Text + "','" + txttc.Text.Trim() + "')");
                 string paths = System.Environment.CurrentDirectory + "//config//" + txtname.Text.ToString().Trim() + ".txt";
                 if (File.Exists(paths) == false)
                 {
                     File.CreateText(paths);
                 }
                 MessageBox.Show("图层已经成功添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 txtname.Text = "";
             }
         }
     }
 }