예제 #1
0
        private void btn_gx_Click(object sender, EventArgs e)
        {
            string sql = "";

            if (CheckInput(txb_msg) == false)
            {
                label10.Text    = "只能输入中文字符,标点符号,英文,数字,下划线。但不能输入@,#,$,%,^,&,*  等特殊字符";
                label10.Visible = true;
                return;
            }
            else
            {
                //cmb_zl.Text != "" ? cmb_zl.SelectedValue : null
                if (txt_id.Text == "")
                {
                    MessageBox.Show("你未选择任何行,请先双击需要更新的行!", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    // MessageBox.Show(cmb_sb.Text == "空" ? null : Int32.Parse(cmb_sb.SelectedValue.ToString()).ToString());
                    sql  = "update b_devices_msg t set t.addtype_id='" + Getcmb(cmb_wz) + "',t.devices_id='" + Getcmb(cmb_sb) + "',t.release_time=sysdate,";
                    sql += " t.start_time=to_date('" + dtp_ks.Text + "','yyyy-mm-dd hh24:mi:ss'),t.end_time=to_date('" + dtp_js.Text + "','yyyy-mm-dd hh24:mi:ss'),";
                    sql += " t.description='" + txb_msg.Text + "',t.tru_id='" + Getcmb(cmb_zl) + "',t.ter_id='" + Getcmb(cmb_hzl) + "' ";
                    sql += " where t.id=" + Int32.Parse(txt_id.Text) + "";
                    try
                    {
                        ora.ExecuteSql(sql);
                        MessageBox.Show("ID为" + txt_id.Text + "消息已经成功更新!", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        BindData();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString(), "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
예제 #2
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 = "";
         }
     }
 }
예제 #3
0
        public void Connect()
        {
            ora = new OracleHelper(constr);
            try
            {
                ora.ExecuteSql("select * from B_DEVICES t");
            }

            catch (Exception e)

            {
                throw new Exception(e.Message);
            }
        }
예제 #4
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
         {
             if (cmbgn.Text == "空")
             {
                 ora.ExecuteSql("insert into b_devices_msg (id,addtype_id,start_time,end_time,description,release_time,ter_id) values (SEQ_B_DEVICES_MSG.NEXTVAL,null,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);
                 Reflesh();
             }
             else
             {
                 ora.ExecuteSql("insert into b_devices_msg (id,addtype_id,start_time,end_time,description,release_time,ter_id) values (SEQ_B_DEVICES_MSG.NEXTVAL," + cmbgn.SelectedValue + ",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);
                 Reflesh();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString(), "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
 }
예제 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            CheckTxtbox();
            try
            {
                if (Ishave(txtipaddr) == false)
                {
                    ora.ExecuteSql("update b_devices t set t.sip='" + txtipaddr.Text + "',t.resource_name='" + txtname.Text + "',t.pos_tc='" + comboBox1.SelectedValue.ToString() + "' where t.sip='" + Ip + "' and t.resource_name='" + Hostname + "'");
                    MessageBox.Show("此点位信息已经更新成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //string path = System.Environment.CurrentDirectory + "//config//" + Flag + ".txt";
                    //string[] lines = System.IO.File.ReadAllLines(path);
                    ////转换
                    //List<string> list = new List<string>();
                    //list.AddRange(lines);
                    //for (int i = 0; i < list.Count; i++)
                    //{
                    //    if (list[i].ToString().Contains(Hostname + "," + Ip))
                    //    {
                    //        list[i] = txtname.Text + "," + txtipaddr.Text + "," + txtX.Text + "," + txtY.Text;
                    //    }
                    //}

                    //lines = list.ToArray();
                    ////保存
                    //File.WriteAllLines(path, lines, Encoding.UTF8);
                    //File.w
                    // MessageBox.Show(lines.ToString());
                    //MessageBox.Show("此点位信息已经更新成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //this.Close();
                    Anj_Jk frm = (Anj_Jk)this.Owner;
                    frm.DeleteButton();
                    frm.AddbuttonInfo("images/" + Flag + ".jpg");
                }
                else
                {
                    MessageBox.Show(txtipaddr.Text + "已经存在,请不要重复更新!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #6
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;
         }
     }
 }
예제 #7
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);
            }
        }
예제 #8
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 = "";
             }
         }
     }
 }