Exemple #1
0
        private void layerDelAllCmd_Click(object sender, EventArgs e)
        {
            string            message = "target : " + layerListBox.SelectedItem.ToString();
            string            caption = "delete layer";
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;
            DialogResult      result;

            result = MessageBox.Show(message, caption, buttons);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                for (int layerindex = 1; layerindex < memoryData.LayerData.Count; layerindex++)
                {
                    for (int i = memoryData.ButtonData.Count - 1; i >= 0; i--)
                    {
                        ButtonObjstruct tar = (ButtonObjstruct)memoryData.ButtonData[i];
                        if (tar.layer == layerListBox.Items[layerindex].ToString())
                        {
                            memoryData.ButtonData.Remove(tar);
                            int index = memoryData.iconTemp.IndexOf(tar.name);
                            if (index != -1)
                            {
                                memoryData.iconTemp.RemoveAt(index);
                                memoryData.iconDelTemp.Add(tar.name);
                            }
                        }
                    }

                    for (int i = memoryData.LabelData.Count - 1; i >= 0; i--)
                    {
                        LabelObjstruct tar = (LabelObjstruct)memoryData.LabelData[i];
                        if (tar.layer == layerListBox.Items[layerindex].ToString())
                        {
                            memoryData.LabelData.Remove(tar);
                            int index = memoryData.iconTemp.IndexOf(tar.name);
                            if (index != -1)
                            {
                                memoryData.iconTemp.RemoveAt(index);
                                memoryData.iconDelTemp.Add(tar.name);
                            }
                        }
                    }

                    for (int i = memoryData.InputData.Count - 1; i >= 0; i--)
                    {
                        InputObjectstruct tar = (InputObjectstruct)memoryData.InputData[i];
                        if (tar.layer == layerListBox.Items[layerindex].ToString())
                        {
                            memoryData.InputData.Remove(tar);
                            int index = memoryData.iconTemp.IndexOf(tar.name);
                            if (index != -1)
                            {
                                memoryData.iconTemp.RemoveAt(index);
                                memoryData.iconDelTemp.Add(tar.name);
                            }
                        }
                    }

                    for (int i = memoryData.OutputButtonData.Count - 1; i >= 0; i--)
                    {
                        OutputButtonObjectstruct tar = (OutputButtonObjectstruct)memoryData.OutputButtonData[i];
                        if (tar.layer == layerListBox.Items[layerindex].ToString())
                        {
                            memoryData.OutputButtonData.Remove(tar);
                            int index = memoryData.iconTemp.IndexOf(tar.name);
                            if (index != -1)
                            {
                                memoryData.iconTemp.RemoveAt(index);
                                memoryData.iconDelTemp.Add(tar.name);
                            }
                        }
                    }

                    for (int i = memoryData.OutputTextData.Count - 1; i >= 0; i--)
                    {
                        OutputTextObjectstruct tar = (OutputTextObjectstruct)memoryData.OutputTextData[i];
                        if (tar.layer == layerListBox.Items[layerindex].ToString())
                        {
                            memoryData.OutputTextData.Remove(tar);
                            int index = memoryData.iconTemp.IndexOf(tar.name);
                            if (index != -1)
                            {
                                memoryData.iconTemp.RemoveAt(index);
                                memoryData.iconDelTemp.Add(tar.name);
                            }
                        }
                    }

                    for (int i = memoryData.OutputPopData.Count - 1; i >= 0; i--)
                    {
                        OutputPopObjectstruct tar = (OutputPopObjectstruct)memoryData.OutputPopData[i];
                        if (tar.layer == layerListBox.Items[layerindex].ToString())
                        {
                            memoryData.OutputPopData.Remove(tar);
                            int index = memoryData.iconTemp.IndexOf(tar.name);
                            if (index != -1)
                            {
                                memoryData.iconTemp.RemoveAt(index);
                                memoryData.iconDelTemp.Add(tar.name);
                            }
                        }
                    }

                    for (int i = memoryData.PictureData.Count - 1; i >= 0; i--)
                    {
                        PictureboxObjectstruct tar = (PictureboxObjectstruct)memoryData.PictureData[i];
                        if (tar.layer == layerListBox.Items[layerindex].ToString())
                        {
                            memoryData.PictureData.Remove(tar);
                            int index = memoryData.iconTemp.IndexOf(tar.name);
                            if (index != -1)
                            {
                                memoryData.iconTemp.RemoveAt(index);
                                memoryData.iconDelTemp.Add(tar.name);
                            }
                        }
                    }

                    for (int i = memoryData.AlarmData.Count - 1; i >= 0; i--)
                    {
                        AlarmObjectstruct tar = (AlarmObjectstruct)memoryData.AlarmData[i];
                        if (tar.layer == layerListBox.Items[layerindex].ToString())
                        {
                            for (int am = 0; am < memoryData.AlarmMonitorValue.Count; am++)
                            {
                                AlarmMoniTorNV edit = (AlarmMoniTorNV)memoryData.AlarmMonitorValue[am];
                                if (edit.name == tar.name)
                                {
                                    memoryData.AlarmMonitorValue.Remove(edit);
                                    break;
                                }
                            }
                            memoryData.AlarmData.Remove(tar);
                            int index = memoryData.iconTemp.IndexOf(tar.name);
                            if (index != -1)
                            {
                                memoryData.iconTemp.RemoveAt(index);
                                memoryData.iconDelTemp.Add(tar.name);
                            }
                        }
                    }
                }
            }



            for (int i = layerListBox.Items.Count - 1; i > 0; i--)
            {
                layerListBox.Items.RemoveAt(i);
                memoryData.LayerData.RemoveAt(i);
            }
        }
Exemple #2
0
        private void layerDelCmd_Click(object sender, EventArgs e)
        {
            if (layerListBox.SelectedItem != null)
            {
                if (layerListBox.SelectedIndex != 0)
                {
                    string tarName = layerListBox.Text;

                    string            message = "target : " + layerListBox.SelectedItem.ToString();
                    string            caption = "delete layer";
                    MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                    DialogResult      result;
                    result = MessageBox.Show(message, caption, buttons);

                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        for (int i = memoryData.AlarmData.Count - 1; i >= 0; i--)
                        {
                            AlarmObjectstruct tar = (AlarmObjectstruct)memoryData.AlarmData[i];
                            if (tar.layer == tarName)
                            {
                                memoryData.AlarmData.Remove(tar);
                                int index = memoryData.iconTemp.IndexOf(tar.name);
                                if (index != -1)
                                {
                                    memoryData.iconTemp.RemoveAt(index);
                                    memoryData.iconDelTemp.Add(tar.name);
                                }
                            }

                            for (int a = 0; a < memoryData.AlarmMonitorValue.Count; a++)
                            {
                                AlarmMoniTorNV mtar = (AlarmMoniTorNV)memoryData.AlarmMonitorValue[a];
                                if (mtar.name == tar.name)
                                {
                                    memoryData.AlarmMonitorValue.Remove(mtar);
                                    break;
                                }
                            }
                        }

                        for (int i = memoryData.ButtonData.Count - 1; i >= 0; i--)
                        {
                            ButtonObjstruct tar = (ButtonObjstruct)memoryData.ButtonData[i];
                            if (tar.layer == tarName)
                            {
                                memoryData.ButtonData.Remove(tar);
                                int index = memoryData.iconTemp.IndexOf(tar.name);
                                if (index != -1)
                                {
                                    memoryData.iconTemp.RemoveAt(index);
                                    memoryData.iconDelTemp.Add(tar.name);
                                }
                            }
                        }

                        for (int i = memoryData.InputData.Count - 1; i >= 0; i--)
                        {
                            InputObjectstruct tar = (InputObjectstruct)memoryData.InputData[i];
                            if (tar.layer == tarName)
                            {
                                memoryData.InputData.Remove(tar);
                                int index = memoryData.iconTemp.IndexOf(tar.name);
                                if (index != -1)
                                {
                                    memoryData.iconTemp.RemoveAt(index);
                                    memoryData.iconDelTemp.Add(tar.name);
                                }
                            }
                        }

                        for (int i = memoryData.LabelData.Count - 1; i >= 0; i--)
                        {
                            LabelObjstruct tar = (LabelObjstruct)memoryData.LabelData[i];
                            if (tar.layer == tarName)
                            {
                                memoryData.LabelData.Remove(tar);
                                int index = memoryData.iconTemp.IndexOf(tar.name);
                                if (index != -1)
                                {
                                    memoryData.iconTemp.RemoveAt(index);
                                    memoryData.iconDelTemp.Add(tar.name);
                                }
                            }
                        }

                        for (int i = memoryData.OutputButtonData.Count - 1; i >= 0; i--)
                        {
                            OutputButtonObjectstruct tar = (OutputButtonObjectstruct)memoryData.OutputButtonData[i];
                            if (tar.layer == tarName)
                            {
                                memoryData.OutputButtonData.Remove(tar);
                                int index = memoryData.iconTemp.IndexOf(tar.name);
                                if (index != -1)
                                {
                                    memoryData.iconTemp.RemoveAt(index);
                                    memoryData.iconDelTemp.Add(tar.name);
                                }
                            }
                        }

                        for (int i = memoryData.OutputPopData.Count - 1; i >= 0; i--)
                        {
                            OutputPopObjectstruct tar = (OutputPopObjectstruct)memoryData.OutputPopData[i];
                            if (tar.layer == tarName)
                            {
                                memoryData.OutputPopData.Remove(tar);
                                int index = memoryData.iconTemp.IndexOf(tar.name);
                                if (index != -1)
                                {
                                    memoryData.iconTemp.RemoveAt(index);
                                    memoryData.iconDelTemp.Add(tar.name);
                                }
                            }
                        }

                        for (int i = memoryData.OutputTextData.Count - 1; i >= 0; i--)
                        {
                            OutputTextObjectstruct tar = (OutputTextObjectstruct)memoryData.OutputTextData[i];
                            if (tar.layer == tarName)
                            {
                                memoryData.OutputTextData.Remove(tar);
                                int index = memoryData.iconTemp.IndexOf(tar.name);
                                if (index != -1)
                                {
                                    memoryData.iconTemp.RemoveAt(index);
                                    memoryData.iconDelTemp.Add(tar.name);
                                }
                            }
                        }

                        for (int i = memoryData.PictureData.Count - 1; i >= 0; i--)
                        {
                            PictureboxObjectstruct tar = (PictureboxObjectstruct)memoryData.PictureData[i];
                            if (tar.layer == tarName)
                            {
                                memoryData.PictureData.Remove(tar);
                                int index = memoryData.iconTemp.IndexOf(tar.name);
                                if (index != -1)
                                {
                                    memoryData.iconTemp.RemoveAt(index);
                                    memoryData.iconDelTemp.Add(tar.name);
                                }
                            }
                        }

                        for (int i = 0; i < memoryData.LayerData.Count; i++)
                        {
                            Layerstruct getVal = (Layerstruct)memoryData.LayerData[i];
                            if (getVal.name == tarName)
                            {
                                memoryData.LayerData.Remove(memoryData.LayerData[i]);
                                //layerListBox.Items.Remove(layerListBox.SelectedItem);
                                layerListBox.Items.RemoveAt(layerListBox.SelectedIndex);
                                break;
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("bottom layer can not delete!");
                }
            }
        }
Exemple #3
0
        private void layerRenameCmd_Click(object sender, EventArgs e)
        {
            if (layerListBox.SelectedItem != null)
            {
                if (layerListBox.SelectedIndex != 0)
                {
                    for (int i = 0; i < memoryData.LayerData.Count; i++)
                    {
                        Layerstruct getVal = (Layerstruct)memoryData.LayerData[i];
                        if (getVal.name == layerListBox.Text)
                        {
                            getVal.name             = layerName.Text;
                            memoryData.LayerData[i] = getVal;
                            break;
                        }
                    }

                    for (int i = 0; i < memoryData.LabelData.Count; i++)
                    {
                        LabelObjstruct edit = (LabelObjstruct)memoryData.LabelData[i];
                        if (edit.layer == layerListBox.Text)
                        {
                            edit.layer = layerName.Text;
                            memoryData.LabelData[i] = edit;
                        }
                    }

                    for (int i = 0; i < memoryData.ButtonData.Count; i++)
                    {
                        ButtonObjstruct edit = (ButtonObjstruct)memoryData.ButtonData[i];
                        if (edit.layer == layerListBox.Text)
                        {
                            edit.layer = layerName.Text;
                            memoryData.ButtonData[i] = edit;
                        }
                    }

                    for (int i = 0; i < memoryData.InputData.Count; i++)
                    {
                        InputObjectstruct edit = (InputObjectstruct)memoryData.InputData[i];
                        if (edit.layer == layerListBox.Text)
                        {
                            edit.layer = layerName.Text;
                            memoryData.InputData[i] = edit;
                        }
                    }

                    for (int i = 0; i < memoryData.OutputButtonData.Count; i++)
                    {
                        OutputButtonObjectstruct edit = (OutputButtonObjectstruct)memoryData.OutputButtonData[i];
                        if (edit.layer == layerListBox.Text)
                        {
                            edit.layer = layerName.Text;
                            memoryData.OutputButtonData[i] = edit;
                        }
                    }

                    for (int i = 0; i < memoryData.OutputTextData.Count; i++)
                    {
                        OutputTextObjectstruct edit = (OutputTextObjectstruct)memoryData.OutputTextData[i];
                        if (edit.layer == layerListBox.Text)
                        {
                            edit.layer = layerName.Text;
                            memoryData.OutputTextData[i] = edit;
                        }
                    }

                    for (int i = 0; i < memoryData.OutputPopData.Count; i++)
                    {
                        OutputPopObjectstruct edit = (OutputPopObjectstruct)memoryData.OutputPopData[i];
                        if (edit.layer == layerListBox.Text)
                        {
                            edit.layer = layerName.Text;
                            memoryData.OutputPopData[i] = edit;
                        }
                    }

                    for (int i = 0; i < memoryData.PictureData.Count; i++)
                    {
                        PictureboxObjectstruct edit = (PictureboxObjectstruct)memoryData.PictureData[i];
                        if (edit.layer == layerListBox.Text)
                        {
                            edit.layer = layerName.Text;
                            memoryData.PictureData[i] = edit;
                        }
                    }

                    for (int i = 0; i < memoryData.AlarmData.Count; i++)
                    {
                        AlarmObjectstruct edit = (AlarmObjectstruct)memoryData.AlarmData[i];
                        if (edit.layer == layerListBox.Text)
                        {
                            edit.layer = layerName.Text;
                            memoryData.AlarmData[i] = edit;
                        }
                    }

                    layerListBox.Items[layerListBox.SelectedIndex] = layerName.Text;
                }
                else
                {
                    MessageBox.Show("bottom layer can not rename!");
                }
            }
        }
Exemple #4
0
        private void CMDApply_Click(object sender, EventArgs e)
        {
            if (buttonWidth.Text == "")
            {
                buttonWidth.Text = "80";
            }
            if (buttonHeight.Text == "")
            {
                buttonHeight.Text = "28";
            }

            Demobutton.Tag = textX.Text + "_" + textY.Text;

            Form1 lForm1 = (Form1)this.Owner;//把Form2的父窗口指針賦給lForm1

            lForm1.Rebutton   = Demobutton;
            lForm1.Gettooltip = description.Text;

            for (int i = 0; i < memoryData.OutputPopData.Count; i++)
            {
                OutputPopObjectstruct edit = (OutputPopObjectstruct)memoryData.OutputPopData[i];
                if (edit.name == popName)
                {
                    edit.AlignIMG  = Demobutton.ImageAlign;
                    edit.AlignText = Demobutton.TextAlign;
                    edit.backColor = Demobutton.BackColor.ToArgb();
                    if (Demobutton.Image != null)
                    {
                        edit.backImage = imagePath;
                    }
                    else
                    {
                        edit.backImage = null;
                    }

                    edit.font      = Demobutton.Font;
                    edit.forecolor = Demobutton.ForeColor.ToArgb();
                    edit.text      = Demobutton.Text;
                    edit.height    = Demobutton.Size.Height;
                    edit.width     = Demobutton.Size.Width;
                    edit.x         = int.Parse(textX.Text);
                    edit.y         = int.Parse(textY.Text);
                    edit.ip        = targetip;

                    string[] gettag = edit.tag.Split('@');
                    edit.NVtype = gettag[1];

                    edit.description = description.Text;

                    if (Labtext.Text != "")
                    {
                        edit.target      = Labtext.Text;
                        edit.targetindex = targetindex.Text;

                        string[] getpath = deviceList.SelectedNode.FullPath.ToString().Split('\\');
                        edit.site     = getpath[0];
                        edit.fab      = getpath[1];
                        edit.area     = getpath[2];
                        edit.device   = getpath[3];
                        edit.function = getpath[4];
                        edit.NV       = getpath[5];
                    }
                    else
                    {
                        edit.target      = "";
                        edit.targetindex = "";
                    }

                    if (backgroundimage.Checked == true)
                    {
                        edit.useBackIMG   = true;
                        edit.useBackColor = false;
                    }
                    else if (backgroundcolor.Checked == true)
                    {
                        edit.useBackIMG   = false;
                        edit.useBackColor = true;
                    }
                    else if (backgroundcolor.Checked == false && backgroundimage.Checked == false)
                    {
                        edit.useBackIMG   = false;
                        edit.useBackColor = false;
                    }

                    if (checkBox1.Checked == true)
                    {
                        edit.log = true;
                    }
                    else
                    {
                        edit.log = false;
                    }

                    if (checkBox2.Checked == true)
                    {
                        edit.mail = true;
                    }
                    else
                    {
                        edit.mail = false;
                    }

                    if (checkBox3.Checked == true)
                    {
                        edit.SMS = true;
                    }
                    else
                    {
                        edit.SMS = false;
                    }

                    if (GroupContact.Text != "")
                    {
                        edit.contactGroup = GroupContact.Text;
                    }
                    else
                    {
                        edit.contactGroup = "";
                    }

                    memoryData.OutputPopData[i] = edit;
                    break;
                }
            }
            this.Close();
        }
Exemple #5
0
        private void config_OutputObjectPopEdit_Load(object sender, EventArgs e)
        {
            for (int site = 0; site < deviceList.Nodes.Count; site++)
            {
                for (int fab = 0; fab < deviceList.Nodes[site].Nodes.Count; fab++)
                {
                    for (int area = 0; area < deviceList.Nodes[site].Nodes[fab].Nodes.Count; area++)
                    {
                        for (int device = 0; device < deviceList.Nodes[site].Nodes[fab].Nodes[area].Nodes.Count; device++)
                        {
                            if (deviceList.Nodes[site].Nodes[fab].Nodes[area].Nodes[device].Tag.ToString() == "lon")
                            {
                                for (int obj = 0; obj < deviceList.Nodes[site].Nodes[fab].Nodes[area].Nodes[device].Nodes.Count; obj++)
                                {
                                    for (int nv = deviceList.Nodes[site].Nodes[fab].Nodes[area].Nodes[device].Nodes[obj].Nodes.Count - 1; nv >= 0; nv--)
                                    {
                                        string[] tmpStr = NVType2.Split('@');
                                        if (deviceList.Nodes[site].Nodes[fab].Nodes[area].Nodes[device].Nodes[obj].Nodes[nv].Tag.ToString() != tmpStr[1])
                                        {
                                            deviceList.Nodes[site].Nodes[fab].Nodes[area].Nodes[device].Nodes[obj].Nodes[nv].Remove();
                                        }
                                        else if (deviceList.Nodes[site].Nodes[fab].Nodes[area].Nodes[device].Nodes[obj].Nodes[nv].Tag.ToString() == tmpStr[1])
                                        {
                                            if (deviceList.Nodes[site].Nodes[fab].Nodes[area].Nodes[device].Nodes[obj].Text != "VirtFb")
                                            {
                                                string snvt = deviceList.Nodes[site].Nodes[fab].Nodes[area].Nodes[device].Nodes[obj].Nodes[nv].Text.Substring(0, 3);
                                                if (snvt != "nvi")
                                                {
                                                    deviceList.Nodes[site].Nodes[fab].Nodes[area].Nodes[device].Nodes[obj].Nodes[nv].Remove();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            deviceList.CollapseAll();

            for (int i = 0; i < memoryData.OutputPopData.Count; i++)
            {
                OutputPopObjectstruct tar = (OutputPopObjectstruct)memoryData.OutputPopData[i];
                if (tar.name == popName)
                {
                    if (tar.target != "")
                    {
                        string[] index = tar.targetindex.Split('_');
                        deviceList.SelectedNode = deviceList.Nodes[int.Parse(index[0])].Nodes[int.Parse(index[1])].Nodes[int.Parse(index[2])].Nodes[int.Parse(index[3])].Nodes[int.Parse(index[4])].Nodes[int.Parse(index[5])];
                        deviceList.Select();
                    }
                    else
                    {
                        deviceList.SelectedNode = deviceList.Nodes[0].Nodes[0].Nodes[0];
                        deviceList.Nodes[0].Expand();
                        deviceList.Nodes[0].Nodes[0].Expand();
                        deviceList.Nodes[0].Nodes[0].Nodes[0].Expand();
                    }

                    if (tar.AlignText.ToString() != "")
                    {
                        textAlign.Text = tar.AlignText.ToString();
                    }
                    if (tar.AlignIMG.ToString() != "")
                    {
                        imageAlign.Text = tar.AlignIMG.ToString();
                    }

                    Demobutton.BackColor = Color.FromArgb(tar.backColor);
                    description.Text     = tar.description;

                    if (tar.backImage != null && tar.backImage != "")
                    {
                        Demobutton.Image = Image.FromFile(tar.backImage);
                        imagePath        = tar.backImage;
                    }

                    if (tar.useBackIMG == true)
                    {
                        backgroundimage.Checked = true;
                    }
                    else if (tar.useBackColor == true)
                    {
                        backgroundcolor.Checked = true;
                    }

                    if (tar.log == true)
                    {
                        checkBox1.Checked = true;
                    }

                    if (tar.mail == true)
                    {
                        checkBox2.Checked = true;
                    }

                    if (tar.SMS == true)
                    {
                        checkBox3.Checked = true;
                    }
                    //load group contact list
                    for (int g = 0; g < memoryData.GroupContact2.Count; g++)
                    {
                        ContactGroup2 gc = (ContactGroup2)memoryData.GroupContact2[g];
                        GroupContact.Items.Add(gc.groupname);
                    }

                    GroupContact.SelectedIndex = 0;
                }
            }
        }
        private void CMDApply_Click(object sender, EventArgs e)
        {
            if (inputVal.Text != "")
            {
                if (target != "")
                {
                    string[] path = target.Split('@');
                    //SmartServer.SOAP ss = new SmartServer.SOAP();
                    SOAP20_DLL.SOAP ws = new SOAP20_DLL.SOAP();
                    //ss.writeNV(ip, path[2], inputVal.Text);
                    string requestVal          = ws.writeNV(ip, path[2], inputVal.Text);
                    OutputPopObjectstruct edit = (OutputPopObjectstruct)memoryData.OutputPopData[listIndex];

                    string formatForMySqlDate = DateTime.Now.ToString("yyyy-MM-dd");
                    string formatForMySqlTime = DateTime.Now.ToString("HH:mm:ss");
                    //save to database
                    if (memoryData.database.Count != 0)
                    {
                        database SQLstr = (database)memoryData.database[0];

                        //save to database
                        //open database   ///////////////////////////////////////////////////////////////////////
                        string          connStr = "server=" + SQLstr.ip + ";port=" + SQLstr.port + ";uid=" + SQLstr.user + ";pwd=" + SQLstr.password + ";database=" + SQLstr.DBname;
                        MySqlConnection conn    = new MySqlConnection(connStr);
                        MySqlCommand    addList = conn.CreateCommand();
                        conn.Open();

                        string sql = @"SELECT * FROM output_list WHERE site='" + edit.site + "' and fab='" + edit.fab + "' and area='" + edit.area
                                     + "' and device='" + edit.device + "' and function='" + edit.function + "' and NVname='" + edit.NV + "' ";

                        MySqlCommand    cmdCHK  = new MySqlCommand(sql, conn);
                        MySqlDataReader dataCHK = cmdCHK.ExecuteReader();
                        int             listid  = 0;

                        if (dataCHK.HasRows == true)
                        {
                            dataCHK.Read();
                            //有查到資料
                            listid = int.Parse(dataCHK.GetString(0));
                            dataCHK.Close();

                            addList.CommandText = @"update nico_db.output_list set description = '" + edit.description + "' where id = " + listid;
                            addList.ExecuteNonQuery();

                            MySqlCommand addValue = conn.CreateCommand();

                            addValue.CommandText = @"Insert into output_value(list_id,NVvalue_txt,date,time) values('" + listid + "','"
                                                   + inputVal.Text + "','" + formatForMySqlDate + "','" + formatForMySqlTime + "')";

                            addValue.ExecuteNonQuery();
                        }
                        else
                        {
                            dataCHK.Close();
                            // MySqlCommand addList = conn.CreateCommand();

                            //沒有查到資料
                            addList.CommandText = @"Insert into output_list(site,fab,area,device,function,NVname,NVtype,description,ip) values('"
                                                  + edit.site + "','" + edit.fab + "','" + edit.area + "','" + edit.device + "','" + edit.function + "','"
                                                  + edit.NV + "','" + edit.NVtype + "','" + edit.description + "','" + edit.ip + "');";

                            addList.ExecuteNonQuery();
                            //get list_id
                            dataCHK = cmdCHK.ExecuteReader();
                            dataCHK.Read();
                            if (dataCHK.HasRows == true)
                            {
                                listid = int.Parse(dataCHK.GetString(0));
                                dataCHK.Close();
                            }

                            //write to output_value
                            MySqlCommand addValue = conn.CreateCommand();

                            addValue.CommandText = @"Insert into output_value(list_id,NVvalue_txt,date,time) values('" + listid + "','"
                                                   + inputVal.Text + "','" + formatForMySqlDate + "','" + formatForMySqlTime + "')";

                            addValue.ExecuteNonQuery();
                        }

                        conn.Close();
                        //close database    ////////////////////////////////////////////////////////////////////////
                    }


                    //send email
                    if (edit.mail == true)
                    {
                        for (int m = 0; m < memoryData.GroupContact2.Count; m++)
                        {
                            ContactGroup2 mg = (ContactGroup2)memoryData.GroupContact2[m];
                            if (edit.contactGroup == mg.groupname)
                            {
                                using (FileStream input = new FileStream(Application.StartupPath + @"\Resources\SMTP.dat", FileMode.Open))
                                {   // 讀取整數值
                                    BinaryReader reader = new BinaryReader(input);
                                    string       data   = reader.ReadString();

                                    int    numOfBytes = data.Length / 8;
                                    byte[] bytes      = new byte[numOfBytes];
                                    for (int ri = 0; ri < numOfBytes; ++ri)
                                    {
                                        bytes[ri] = Convert.ToByte(data.Substring(8 * ri, 8), 2);
                                    }
                                    //File.WriteAllBytes(fileName, bytes);
                                    string   val          = GetString(bytes);
                                    string[] SpStr        = val.Split('$');
                                    string   SMTPhost     = SpStr[1];
                                    string   SMTPport     = SpStr[2];
                                    Boolean  SSL          = Boolean.Parse(SpStr[3]);
                                    string   userName     = SpStr[4];
                                    string   userPassword = SpStr[5];

                                    string targetpath = edit.site + "/" + edit.fab + "/" + edit.area + "/" + edit.device + "/" + edit.function + "/" + edit.NV;


                                    for (int sg = 0; sg < mg.groupmember.Count; sg++)
                                    {
                                        Contactstruct sgm = (Contactstruct)mg.groupmember[sg];
                                        if (sgm.mail != null && sgm.mail != "")
                                        {
                                            email.From    = new MailAddress(userName);                                                     //寄件人
                                            email.Subject = "IO trigger!  target : " + targetpath;                                         //標題
                                            email.Body    = "trigger time = " + formatForMySqlDate + " " + formatForMySqlTime + Environment.NewLine
                                                            + "trigger value = " + inputVal.Text + Environment.NewLine + edit.description; //內容
                                            email.To.Add(sgm.mail);                                                                        //收件人
                                            SMTP.EnableSsl   = true;
                                            SMTP.Port        = int.Parse(SMTPport);                                                        //smtp port
                                            SMTP.Host        = SMTPhost;                                                                   //smtp host(主機ip)
                                            SMTP.Credentials = new System.Net.NetworkCredential(userName, userPassword);                   //寄件人,密碼
                                            SMTP.Send(email);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("not target!");
                }
            }
        }