Exemplo n.º 1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            switch (model)
            {
            case 1:

                if (operate == 1)
                {
                    if (RecordSearch.IsRecordExists("TcpIPConfig", "IPAddress", tempip, DataType.String))
                    {
                        //刷新
                        Control c1 = panel1.Parent;
                        Control c2 = c1.Controls["ipmain"];
                        panel1.Visible = false;
                        c2.Visible     = true;
                        Control      cc  = c2.Controls[1];
                        Control      cc1 = cc.Controls["splitContainer3"];
                        Control      cc2 = cc1.Controls[0];
                        DataGridView c3  = new DataGridView();
                        c3 = (DataGridView)cc2.Controls["dataGridViewKJ128_ip"];


                        Control      cc5 = cc1.Controls[1];
                        DataGridView c33 = new DataGridView();
                        c33 = (DataGridView)cc5.Controls["dataGridViewKJ128_station"];

                        c3.DataSource  = myipbal.iplist();
                        c33.DataSource = myipbal.Getstationlist();

                        //dataipbind();
                        //datastationbind();
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                    else
                    {
                        if (times < maxTimes)
                        {
                            times++;
                            timer1.Stop();
                            timer1.Start();
                        }
                        else
                        {
                            times = 0;
                            //关闭timer1
                            timer1.Stop();
                        }
                    }
                }
                break;
            }
        }
Exemplo n.º 2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (address == "" || address == String.Empty)
            {
                return;
            }

            //增加
            if (operated == 1)
            {
                string value = address;

                if (RecordSearch.IsRecordExists("CodeSender_Info", "CodeSenderAddress", value, DataType.Int))
                {
                    //刷新

                    getInfo(1);

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        timer1.Stop();
                        timer1.Start();
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
            //删除
            else if (operated == 2)
            {
                //string value = dgvCodeSenderInfo.CurrentRow.Cells["发码器编号"].Value.ToString();
                //if (!RecordSearch.IsRecordExists("CodeSender_Info", "CodeSenderAddress", value, DataType.Int))
                //{
                //    //刷新

                //    getInfo(int.Parse(txtPage.CaptionTitle));

                //    times = 0;
                //    //关闭timer1
                //    timer1.Stop();
                //}
                //else
                //{
                //    if (times < maxTimes)
                //    {
                //        times++;
                //        timer1_Tick(sender, e);
                //    }
                //    else
                //    {
                //        times = 0;
                //        //关闭timer1
                //        timer1.Stop();
                //    }
                //}

                if (times < maxTimes)
                {
                    getInfo(int.Parse(txtPage.CaptionTitle));

                    times++;

                    timer1.Interval = 1000;
                    timer1.Stop();
                    timer1.Start();
                }
                else
                {
                    times = 0;

                    timer1.Interval = 400;
                    //关闭timer1
                    timer1.Stop();
                }
            }
            //修改
            else
            {
                string add      = address;
                string strWhere = "CodeSenderStateID=" + cmdAddCodeSenderState.SelectedValue.ToString()
                                  + " and Remark='" + txtAddNewCodeSenderRemark.Text
                                  + "' and CodeSenderAddress=" + add;

                if (RecordSearch.IsRecordExists("CodeSender_Info", strWhere))
                {
                    //刷新

                    getInfo(int.Parse(txtPage.CaptionTitle));

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        timer1_Tick(sender, e);
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            //增加
            if (operated == 1)
            {
                string value = ddlAdd.SelectedValue.ToString();

                if (RecordSearch.IsRecordExists("UnitPrice", "DeptID", value, DataType.Int))
                {
                    //刷新

                    BindDataGridView();

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        timer1.Stop();
                        timer1.Start();
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
            //删除
            else if (operated == 2)
            {
                string value = dgrd.CurrentRow.Cells[2].Value.ToString();

                if (!RecordSearch.IsRecordExists("UnitPrice", "DeptID", value, DataType.Int))
                {
                    //刷新

                    BindDataGridView();

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        timer1.Stop();
                        timer1.Start();
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
            //修改
            else
            {
                string strWhere = "DeptID=" + ddlAdd.SelectedValue.ToString()
                                  + "and UnitPrice=" + txtUnit.Text
                                  + " and Remark ='" + txtRemark.Text + "'";

                if (RecordSearch.IsRecordExists("UnitPrice", strWhere))
                {
                    //刷新
                    BindDataGridView();

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        timer1.Stop();
                        timer1.Start();
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (operated == 1)
            {
                if (RecordSearch.IsRecordExists("Path_Info", "PathNo", pathnum, DataType.String))
                {
                    //刷新

                    InitializeTreeView("");

                    InitializeGridView("");

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        timer1_Tick(sender, e);
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
            else
            {
                string value = dgvMain.CurrentRow.Cells["PathNo"].Value.ToString();

                if (!RecordSearch.IsRecordExists("Path_Info", "PathNo", value, DataType.String))
                {
                    //刷新

                    InitializeTreeView("");

                    InitializeGridView("");

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        timer1_Tick(sender, e);
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void bCPl_save_Click(object sender, EventArgs e)
        {
            if (m_type == 0)//新增环网IP地址
            {
                if (!Check())
                {
                    return;
                }
                string ipid      = comboBox_ip.SelectedValue.ToString();
                string stationid = comboBox_station.SelectedValue.ToString();

                if (RecordSearch.IsRecordExists("station_info", "IPAddressID <>0 and stationid=" + stationid))
                {
                    SetShowInfo("该传输分站已配置进环网", Color.Red);
                    return;
                }

                int i = myipbal.updatestation(Convert.ToInt32(stationid), Convert.ToInt32(ipid));
                if (i == 1)
                {
                    SetShowInfo("添加成功", Color.Black);
                    frmipadd.Save = true;

                    //Czlt-2011-12-10 修改时间
                    myipbal.UpdateTime();

                    //刷新
                    if (!New_DBAcess.IsDouble)          //单机版,直接刷新
                    {
                        frmipadd.BindGirdview();
                        frmipadd.LoadTcpTree();
                    }
                    else                                //热备版,启用定时器
                    {
                        frmipadd.HostBackRefresh(true);
                    }
                    #region [保存环网信息]
                    //Czlt-2012-3-28 热备配置文件
                    ConfigXmlWiter.Write("TCPIP.xml");
                    //Czlt-2012-3-28 刷新分站列表
                    DataTable dt = myipbal.GetTcpIpConfig();
                    frmipadd.ReplaceNetXml(dt, Application.StartupPath + "\\TcpServer.xml");
                    dt = frmipadd.GetStationTable();
                    frmipadd.ReplaceStationXml(dt, Application.StartupPath + "\\Station.xml");
                    #endregion
                }
                else
                {
                    SetShowInfo("添加失败", Color.Black);
                }
            }
            else//修改环网IP地址
            {
                if (!Check())
                {
                    return;
                }

                string ipid      = comboBox_ip.SelectedValue.ToString();
                string stationid = comboBox_station.SelectedValue.ToString();

                int i = myipbal.updatestation(Convert.ToInt32(stationid), Convert.ToInt32(ipid));
                if (i == 1)
                {
                    SetShowInfo("修改成功", Color.Black);
                    frmipadd.Save = true;

                    //Czlt-2011-12-10 修改时间
                    myipbal.UpdateTime();

                    if (!New_DBAcess.IsDouble)          //单机版,直接刷新
                    {
                        frmipadd.BindGirdview();
                        frmipadd.LoadTcpTree();
                    }
                    else                                //热备版,启用定时器
                    {
                        frmipadd.HostBackRefresh(true);
                    }
                    #region [保存环网信息]
                    //Czlt-2012-3-28 热备配置文件
                    ConfigXmlWiter.Write("TCPIP.xml");
                    //Czlt-2012-3-28 刷新分站列表
                    DataTable dt = myipbal.GetTcpIpConfig();
                    frmipadd.ReplaceNetXml(dt, Application.StartupPath + "\\TcpServer.xml");
                    dt = frmipadd.GetStationTable();
                    frmipadd.ReplaceStationXml(dt, Application.StartupPath + "\\Station.xml");
                    #endregion
                }
                else
                {
                    SetShowInfo("修改失败", Color.Red);
                }
            }
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (operated == 1)
            {
                // 构造方向性
                string tmpd1 = lblFromStation.Tag.ToString() + "," + lblFromHead.Tag.ToString();
                string tmpd2 = lblToStation.Tag.ToString() + "," + lblToHead.Tag.ToString();

                string value = tmpd1 + ":" + tmpd2;

                if (RecordSearch.IsRecordExists("CodeSender_DirectionalAntenna", "DetectionInfo", value, DataType.String))
                {
                    //刷新

                    getInfo(int.Parse(txtPage.CaptionTitle), "");

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        timer1_Tick(sender, e);
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
            else if (operated == 2)
            {
                if (strDelete != string.Empty)
                {
                    string value = strDelete; //dgvData.CurrentRow.Cells["标识"].Value.ToString();

                    if (!RecordSearch.IsRecordExists("CodeSender_DirectionalAntenna", "CodeSenderDirlID", value, DataType.String))
                    {
                        //刷新

                        getInfo(int.Parse(txtPage.CaptionTitle), "");

                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                    else
                    {
                        if (times < maxTimes)
                        {
                            times++;
                            timer1_Tick(sender, e);
                        }
                        else
                        {
                            times = 0;
                            //关闭timer1
                            timer1.Stop();
                        }
                    }
                }
            }
            else
            {
                string strWhere = "CodeSenderDirlID='" + vsPanel.Tag + "'"
                                  + " and Directional='" + txtUpdateD.Text + "'";

                if (RecordSearch.IsRecordExists("CodeSender_DirectionalAntenna", strWhere))
                {
                    //刷新

                    getInfo(int.Parse(txtPage.CaptionTitle), "");

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        // timer1_Tick(sender, e);
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void buttonCaptionPanel2_Click(object sender, EventArgs e)
        {
            if (label4.Text.Length > 0)
            {
                #region 修改
                //添加前先验证
                string ip      = textBox_ip.Text.Trim();
                string port    = textBox_ipport.Text.Trim();
                string address = textBox_azwz.Text.Trim();
                if (checkaddress(address))
                {
                }
                else
                {
                    MessageBox.Show("安装位置格式不正确,请重新输入", "安装位置格式", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }
                if (ip.Length > 0)
                {
                    if (!checkIpAddress(ip))
                    {
                        MessageBox.Show("IP地址不正确,请重新输入", "IP地址", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("IP不能为空,请重新输入", "IP地址", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (!Check())
                {
                    return;
                }
                if (RecordSearch.IsRecordExists("TcpIPConfig", "IPAddress", ip, DataType.String))
                {
                    MessageBox.Show("IP不能为重复,请重新输入", "IP地址", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                tempip = textBox_ip.Text.Trim();
                int i = myipbal.updateip(ip, port, address, Convert.ToInt32(label4.Text));
                if (i == 1)
                {
                    MessageBox.Show("修改成功", "修改成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Control c1 = panel1.Parent;
                    Control c2 = c1.Controls["ipmain"];
                    panel1.Visible = false;
                    c2.Visible     = true;
                    Control      cc  = c2.Controls[1];
                    Control      cc1 = cc.Controls["splitContainer3"];
                    Control      cc2 = cc1.Controls[0];
                    DataGridView c3  = new DataGridView();
                    c3 = (DataGridView)cc2.Controls["dataGridViewKJ128_ip"];


                    Control      cc5 = cc1.Controls[1];
                    DataGridView c33 = new DataGridView();
                    c33 = (DataGridView)cc5.Controls["dataGridViewKJ128_station"];
                    if (tempip != null)
                    {
                        if (tempip.Length > 0)
                        {
                            if (!New_DBAcess.IsDouble)
                            {
                                c3.DataSource  = myipbal.iplist();
                                c33.DataSource = myipbal.Getstationlist();
                            }
                            else
                            {
                                //model = 1;
                                //operate = 1;

                                //timer1.Start();
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("修改失败", "修改失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                #endregion
            }
            else
            {
                #region 添加IP
                //添加前先验证
                string ip      = textBox_ip.Text.Trim();
                string port    = textBox_ipport.Text.Trim();
                string address = textBox_azwz.Text.Trim();
                if (checkaddress(address))
                {
                }
                else
                {
                    MessageBox.Show("安装位置格式不正确,请重新输入", "安装位置格式", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }
                if (ip.Length > 0)
                {
                    if (!checkIpAddress(ip))
                    {
                        MessageBox.Show("IP地址不正确,请重新输入", "IP地址", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("IP不能为空,请重新输入", "IP地址", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (!Check())
                {
                    return;
                }
                if (RecordSearch.IsRecordExists("TcpIPConfig", "IPAddress", ip, DataType.String))
                {
                    MessageBox.Show("IP不能为重复,请重新输入", "IP地址", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                int i = myipbal.addip(ip, port, address);
                tempip = textBox_ip.Text.Trim();
                if (i == 1)
                {
                    MessageBox.Show("添加成功", "添加成功", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    //Control c1 = panel1.Parent;
                    //Control c2 = c1.Controls["ipmain"];
                    //panel1.Visible = false;
                    //c2.Visible = true;
                    //Control cc = c2.Controls[1];
                    //Control cc1 = cc.Controls["splitContainer3"];
                    //Control cc2 = cc1.Controls[0];
                    //DataGridView c3 = new DataGridView();
                    //c3 = (DataGridView)cc2.Controls["dataGridViewKJ128_ip"];


                    //Control cc5 = cc1.Controls[1];
                    //DataGridView c33 = new DataGridView();
                    //c33 = (DataGridView)cc5.Controls["dataGridViewKJ128_station"];
                    //if (tempip != null)
                    //{
                    //    if (tempip.Length > 0)
                    //    {
                    //        if (!New_DBAcess.IsDouble)
                    //        {
                    //            c3.DataSource = myipbal.iplist();
                    //            c33.DataSource = myipbal.Getstationlist();
                    //        }
                    //        else
                    //        {

                    //            model = 1;
                    //            operate = 1;

                    //            timer1.Start();

                    //        }
                    //    }
                    //}
                }
                else
                {
                    MessageBox.Show("添加失败", "添加失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                #endregion
            }
        }
Exemplo n.º 8
0
        private void buttonCaptionPanel_save_Click(object sender, EventArgs e)
        {
            if (label4.Text.Length > 0)
            {
                #region 修改
                //添加前先验证
                string ip      = textBox_ip.Text.Trim();
                string port    = textBox_ipport.Text.Trim();
                string address = textBox_azwz.Text.Trim();
                if (checkaddress(address))
                {
                }
                else
                {
                    MessageBox.Show("安装位置格式不正确,请重新输入", "安装位置格式", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }
                if (ip.Length > 0)
                {
                    if (!checkIpAddress(ip))
                    {
                        MessageBox.Show("IP地址不正确,请重新输入", "IP地址", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("IP不能为空,请重新输入", "IP地址", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (!Check())
                {
                    return;
                }

                if (RecordSearch.IsRecordExists("TcpIPConfig", "IPAddress", ip, DataType.String))
                {
                    MessageBox.Show("IP不能为重复,请重新输入", "IP地址", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                tempip = textBox_ip.Text.Trim();
                int i = myipbal.updateip(ip, port, address, Convert.ToInt32(label4.Text));
                if (i == 1)
                {
                    MessageBox.Show("修改成功", "修改成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("修改失败", "修改失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                #endregion
            }
            else
            {
                #region 添加IP
                //添加前先验证
                string ip      = textBox_ip.Text.Trim();
                string port    = textBox_ipport.Text.Trim();
                string address = textBox_azwz.Text.Trim();
                if (checkaddress(address))
                {
                }
                else
                {
                    MessageBox.Show("安装位置格式不正确,请重新输入", "安装位置格式", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }
                if (ip.Length > 0)
                {
                    if (!checkIpAddress(ip))
                    {
                        MessageBox.Show("IP地址不正确,请重新输入," + "\r\n" + " 输入格式:192.168.1.1", "IP地址", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("IP不能为空,请重新输入", "IP地址", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (!Check())
                {
                    return;
                }
                if (RecordSearch.IsRecordExists("TcpIPConfig", "IPAddress", ip, DataType.String))
                {
                    MessageBox.Show("IP不能为重复,请重新输入", "IP地址", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }


                int i = myipbal.addip(ip, port, address);
                if (i == 1)
                {
                    tempip = textBox_ip.Text.Trim();
                    MessageBox.Show("添加成功", "添加成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //清空内容
                    textBox_ip.Text     = "";
                    textBox_ipport.Text = "";
                    textBox_azwz.Text   = "";
                }
                else
                {
                    MessageBox.Show("添加失败", "添加失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                #endregion
            }
        }
Exemplo n.º 9
0
        public void timer1_Tick(object sender, EventArgs e)
        {
            switch (model)
            {
            //IP
            case 1:

                if (operate == 2)

                {
                    if (!RecordSearch.IsRecordExists("TcpIPConfig", "ipid", id.ToString(), DataType.Int))
                    {
                        //刷新

                        dataipbind();
                        datastationbind();
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                    else
                    {
                        if (times < maxTimes)
                        {
                            times++;
                            //timer1_Tick(sender, e);
                            timer1.Stop();
                            timer1.Start();
                        }
                        else
                        {
                            times = 0;
                            //关闭timer1
                            timer1.Stop();
                        }
                    }
                }

                break;

            //address
            case 2:

                if (operate == 2)
                {
                    if (!RecordSearch.IsRecordExists("Station_Info", "ipaddressid", statid.ToString(), DataType.Int))
                    {
                        //刷新

                        dataipbind();
                        datastationbind();
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                    else
                    {
                        if (times < maxTimes)
                        {
                            times++;
                            //timer1_Tick(sender, e);
                            timer1.Stop();
                            timer1.Start();
                        }
                        else
                        {
                            times = 0;
                            //关闭timer1
                            timer1.Stop();
                        }
                    }
                }



                break;

            default:
                break;
            }
        }
Exemplo n.º 10
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            //增加
            if (operated == 1)
            {
                if (RecordSearch.IsRecordExists("Admins", "Account", txtUser.Text, DataType.String))
                {
                    //刷新

                    adminInfo_Load(null, null);

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        timer1_Tick(sender, e);
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
            //删除
            else if (operated == 2)
            {
                string value = dtgAccount1.CurrentRow.Cells["ids"].Value.ToString();
                if (!RecordSearch.IsRecordExists("Admins", "ID", value, DataType.Int))
                {
                    //刷新

                    adminInfo_Load(null, null);

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        timer1_Tick(sender, e);
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
            //修改
            else
            {
                string strPassWord = MD5.GetPassword16(txtPassword1.Text.Trim());

                string strWhere = "Account='" + txtUserName.Text
                                  + "' and Password='******' and Remark='" + txtRemark1.Text
                                  + "'";

                if (RecordSearch.IsRecordExists("Admins", strWhere))
                {
                    //刷新

                    adminInfo_Load(null, null);

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        timer1_Tick(sender, e);
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
        }
Exemplo n.º 11
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            //增加
            if (operated == 1)
            {
                timer1.Interval = 400;

                //刷最大次数(两次)
                if (times < maxTimes)
                {
                    times++;

                    //刷新
                    InitialzeDataGridView();
                }
                else
                {
                    times = 0;
                    timer1.Stop();
                }
            }
            //删除
            else if (operated == 2)
            {
                if (times < maxTimes)
                {
                    timer1.Interval = 1000;
                    times++;

                    InitialzeDataGridView();

                    timer1.Stop();

                    timer1.Start();
                }
                else
                {
                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
            }
            //修改
            else
            {
                timer1.Interval = 400;

                string ID       = dgvMain.CurrentRow.Cells["Id"].Value.ToString();
                string strWhere = "PathNo='" + tbPathNum.Text
                                  + "' and StationAddress=" + cbstation.SelectedValue.ToString()
                                  + " and StationHeadAddress=" + cbPiont.SelectedValue.ToString()
                                  + " and Id=" + ID;

                if (RecordSearch.IsRecordExists("Path_Detail", strWhere))
                {
                    //刷新

                    InitialzeDataGridView();

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        timer1.Stop();
                        timer1.Start();
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
        }
Exemplo n.º 12
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            //增加
            if (operated == 1)
            {
                timer1.Interval = 400;

                string strWhere = "PathNo='" + tbPathNo.Text
                                  + "' and EmpNo='" + cbEmp.SelectedValue.ToString() + "'";

                if (RecordSearch.IsRecordExists("Path_Emp_Relation", strWhere))
                {
                    //刷新

                    InitialzeDataGridView();

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        timer1_Tick(sender, e);
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
            //删除
            else if (operated == 2)
            {
                timer1.Interval = 1000;

                string value = dgvMain.CurrentRow.Cells["Id"].Value.ToString();
                if (!RecordSearch.IsRecordExists("Path_Emp_Relation", "Id", value, DataType.String))
                {
                    //刷新

                    InitialzeDataGridView();

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        timer1_Tick(sender, e);
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
            //修改
            else
            {
                timer1.Interval = 400;

                string ID       = dgvMain.CurrentRow.Cells["Id"].Value.ToString();
                string strWhere = "PathNo='" + tbPathNo.Text
                                  + "' and EmpNo='" + cbEmp.SelectedValue.ToString()
                                  + "' and Id=" + ID;

                if (RecordSearch.IsRecordExists("Path_Emp_Relation", strWhere))
                {
                    //刷新

                    InitialzeDataGridView();

                    times = 0;
                    //关闭timer1
                    timer1.Stop();
                }
                else
                {
                    if (times < maxTimes)
                    {
                        times++;
                        timer1_Tick(sender, e);
                    }
                    else
                    {
                        times = 0;
                        //关闭timer1
                        timer1.Stop();
                    }
                }
            }
        }
Exemplo n.º 13
0
        private void buttonCaptionPanel_save_Click(object sender, EventArgs e)
        {
            if (m_type == 0)//新增环网IP地址
            {
                if (!Check())
                {
                    return;
                }
                if (RecordSearch.IsRecordExists("TcpIPConfig", "IPAddress ='" + textBox_ip.Text.Trim() + "'"))
                {
                    SetShowInfo("IP不能为重复,请重新输入", Color.Red);
                    return;
                }

                int i = myipbal.addip(textBox_ip.Text.Trim(), textBox_ipport.Text.Trim(), textBox_azwz.Text.Trim());
                if (i == 1)
                {
                    SetShowInfo("添加成功", Color.Black);
                    frmipadd.Save = true;
                    //刷新
                    if (!New_DBAcess.IsDouble)          //单机版,直接刷新
                    {
                        frmipadd.BindGirdview();
                        frmipadd.LoadTcpTree();
                    }
                    else                                //热备版,启用定时器
                    {
                        frmipadd.HostBackRefresh(true);
                    }
                    #region [保存环网信息]
                    DataTable dt = myipbal.GetTcpIpConfig();
                    frmipadd.ReplaceNetXml(dt, Application.StartupPath + "\\TcpServer.xml");
                    dt = frmipadd.GetStationTable();
                    frmipadd.ReplaceStationXml(dt, Application.StartupPath + "\\Station.xml");
                    #endregion
                }
                else
                {
                    SetShowInfo("添加失败", Color.Black);
                }
            }
            else//修改环网IP地址
            {
                string ip      = textBox_ip.Text.Trim();
                string port    = textBox_ipport.Text.Trim();
                string address = textBox_azwz.Text.Trim();

                if (!Check())
                {
                    return;
                }
                if (RecordSearch.IsRecordExists("TcpIPConfig", "ipid<>" + ipid + " and ipaddress='" + textBox_ip.Text.Trim() + "'"))
                {
                    SetShowInfo("IP不能为重复,请重新输入", Color.Red);
                    return;
                }
                int i = myipbal.updateip(ip, port, address, int.Parse(ipid));
                if (i == 1)
                {
                    SetShowInfo("修改成功", Color.Black);
                    frmipadd.Save = true;
                    if (!New_DBAcess.IsDouble)          //单机版,直接刷新
                    {
                        frmipadd.BindGirdview();
                        frmipadd.LoadTcpTree();
                    }
                    else                                //热备版,启用定时器
                    {
                        frmipadd.HostBackRefresh(true);
                    }
                    #region [保存环网信息]
                    DataTable dt = myipbal.GetTcpIpConfig();
                    frmipadd.ReplaceNetXml(dt, Application.StartupPath + "\\TcpServer.xml");
                    dt = frmipadd.GetStationTable();
                    frmipadd.ReplaceStationXml(dt, Application.StartupPath + "\\Station.xml");
                    #endregion
                }
                else
                {
                    SetShowInfo("修改失败", Color.Red);
                }
            }
        }