private void switchBtn_Click(object sender, EventArgs e)
        {
            string section = "CurOpProduct";    //当前操作的产品信息
            string key     = "ProductName";

            //只有当产品数大于0时才能切换
            if (productCombo.Items.Count > 0)
            {
                CurOpProduct = productCombo.SelectedItem.ToString();
                iniFileOp.WriteString(section, key, CurOpProduct);
                //this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("请先输入产品名称", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Beispiel #2
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            torsionUp    = torsionUpLimit.Text.Trim().TrimEnd('0');
            torsionDown  = torsionDownLimit.Text.Trim().TrimEnd('0');
            torsion2Up   = torsion2UpLimit.Text.Trim().TrimEnd('0');
            torsion2Down = torsion2DownLimit.Text.Trim().TrimEnd('0');

            if (string.IsNullOrEmpty(torsionUp) || string.IsNullOrEmpty(torsionDown) || string.IsNullOrEmpty(torsion2Up) || string.IsNullOrEmpty(torsion2Down))
            {
                MessageBox.Show("检测到有参数未设置,请重新输入", "参数为空", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                iniFileOp.WriteString(section, key1Up, torsionUp);
                iniFileOp.WriteString(section, key1Down, torsionDown);
                iniFileOp.WriteString(section, key2Up, torsion2Up);
                iniFileOp.WriteString(section, key2Down, torsion2Down);
                string reScrew = checkBox1.Checked ? "true" : "false";
                iniFileOp.WriteString(section, reDo, reScrew);
                iniFileOp.WriteString(section, baudRate, curBaudRate.ToString());
                byte[] baud = new byte[2];
                baud[0] = 0;
                baud[1] = (byte)curBaudRate;
                rtuCom.WriteSingleReg(1, 2, 1, baud);
                MessageBox.Show("参数已保存,需重启软件生效", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Close();
            }
        }
Beispiel #3
0
        private bool CheckInputInfo()
        {
            bool   res  = false;
            string user = userTb.Text.Trim();
            string pass = passTb.Text.Trim();

            //判断输入是否为空
            if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(pass))
            {
                MessageBox.Show("用户密码不能为空,请输入...", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            iniFileOp.WriteString(section, ukey, user);
            iniFileOp.WriteString(section, pkey, pass);

            //如果不为空,则检查是否正确
            if (mysql.OpenMysql())
            {
                string queryStr = string.Format("select * from User where name='{0}';", user);
                string restr    = mysql.QueryOneRow(queryStr);

                if (!string.IsNullOrEmpty(restr.TrimEnd(',')))
                {
                    string[] userInfo = restr.Split(',');

                    if (pass == userInfo[1])
                    {
                        res = true;
                    }
                }

                label2.Text = restr;
            }
            else
            {
                MessageBox.Show("数据库打开失败", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            return(res);
        }
Beispiel #4
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            torsionUp    = torsionUpLimit.Text.Trim().TrimEnd('0');
            torsionDown  = torsionDownLimit.Text.Trim().TrimEnd('0');
            torsion2Up   = torsion2UpLimit.Text.Trim().TrimEnd('0');
            torsion2Down = torsion2DownLimit.Text.Trim().TrimEnd('0');

            if (string.IsNullOrEmpty(torsionUp) || string.IsNullOrEmpty(torsionDown) || string.IsNullOrEmpty(torsion2Up) || string.IsNullOrEmpty(torsion2Down))
            {
                MessageBox.Show("检测到有参数未设置,请重新输入", "参数为空", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                iniFileOp.WriteString(section, key1Up, torsionUp);
                iniFileOp.WriteString(section, key1Down, torsionDown);
                iniFileOp.WriteString(section, key2Up, torsion2Up);
                iniFileOp.WriteString(section, key2Down, torsion2Down);
                string reScrew = checkBox1.Checked ? "true" : "false";
                iniFileOp.WriteString(section, reDo, reScrew);
                Close();
            }
        }
Beispiel #5
0
        private void switchBtn_Click(object sender, EventArgs e)
        {
            string section = "CurOpProduct";    //当前操作的产品信息
            string key     = "ProductName";

            //只有当产品数大于0时才能切换
            if (productCombo.Items.Count > 0)
            {
                CurOpProduct = productCombo.SelectedItem.ToString();
                iniFileOp.WriteString(section, key, CurOpProduct);
                iniFileOp.WriteString(section, "CurProIndex", productCombo.SelectedIndex.ToString());
                //this.DialogResult = DialogResult.OK;
                #if WriteToPlc
                curPointList  = GetPointInfoByProduct(curProductName);
                sendToPlcFlag = true;   //切换产品后要重新发送点位信息到PLC
                //MessageBox.Show("产品切换完成,请回到主界面以完成写入!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                #endif
            }
            else
            {
                MessageBox.Show("请先输入产品名称", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }