Esempio n. 1
0
 private void 管理消息_Load(object sender, EventArgs e)
 {
     ora = new OracleHelper(constr);
     BindData();
 }
Esempio n. 2
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 = "";
             }
         }
     }
 }