Ejemplo n.º 1
0
        private static void checkAllMultiAlarmTempFields(TextBox tbA1Temp, TextBox tbA3Temp, TextBox tbA4Temp, TextBox tbA5Temp, TextBox tbA6Temp, PictureBox pbA1, PictureBox pbA2, PictureBox pbA4, PictureBox pbA5, PictureBox pbA6
                                                         , ToolTip wrongTip, SuperDevice Tag, string configUnit, CheckBox cbA6, CheckBox cbA5, CheckBox cbA1)
        {
            string pattern = "^[-+]?[0-9]+[/.]?[0-9]?$";

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(pattern);

            if (cbA1.Checked)
            {
                if (!regex.IsMatch(tbA1Temp.Text))
                {
                    pbA1.Visible = true;
                    Common.SetToolTip(wrongTip, pbA1, Messages.TemperatureValueInvalid);
                }
                else
                {
                    pbA1.Visible = false;
                }
            }

            if (!regex.IsMatch(tbA3Temp.Text))
            {
                pbA2.Visible = true;
                Common.SetToolTip(wrongTip, pbA2, Messages.TemperatureValueInvalid);
            }
            else
            {
                pbA2.Visible = false;
            }

            if (!regex.IsMatch(tbA4Temp.Text))
            {
                pbA4.Visible = true;
                Common.SetToolTip(wrongTip, pbA4, Messages.TemperatureValueInvalid);
            }
            else
            {
                pbA4.Visible = false;
            }


            if (cbA5.Checked)
            {
                if (!regex.IsMatch(tbA5Temp.Text))
                {
                    pbA5.Visible = true;
                    Common.SetToolTip(wrongTip, pbA5, Messages.TemperatureValueInvalid);
                }
                else
                {
                    pbA5.Visible = false;
                }
            }


            if (cbA6.Checked)
            {
                if (!regex.IsMatch(tbA6Temp.Text))
                {
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA6, Messages.TemperatureValueInvalid);
                }
                else
                {
                    pbA6.Visible = false;
                }
            }

            if (cbA6.Checked)
            {
                if (!regex.IsMatch(tbA6Temp.Text))
                {
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA6, Messages.TemperatureValueInvalid);
                }
                else
                {
                    pbA6.Visible = false;
                }
            }


            if (cbA1.Checked && !pbA1.Visible)
            {
                ResultForCheckTempWhetherExceedDefinedRange result = ConnectionController.IsOverTemp(Tag.DeviceID, tbA1Temp.Text, configUnit);
                if (result == ResultForCheckTempWhetherExceedDefinedRange.TooHigh)
                {
                    pbA1.Visible = true;
                    Common.SetToolTip(wrongTip, pbA1, Messages.AlarmHighLimitInvalid);
                }
                else if (result == ResultForCheckTempWhetherExceedDefinedRange.TooLow)
                {
                    pbA1.Visible = true;
                    Common.SetToolTip(wrongTip, pbA1, Messages.AlarmLowLimitInvalid);
                }
                else
                {
                    // nothing
                }
            }

            if (!pbA2.Visible)
            {
                ResultForCheckTempWhetherExceedDefinedRange result = ConnectionController.IsOverTemp(Tag.DeviceID, tbA3Temp.Text, configUnit);
                if (result == ResultForCheckTempWhetherExceedDefinedRange.TooHigh)
                {
                    pbA2.Visible = true;
                    Common.SetToolTip(wrongTip, pbA2, Messages.AlarmHighLimitInvalid);
                }
                else if (result == ResultForCheckTempWhetherExceedDefinedRange.TooLow)
                {
                    pbA2.Visible = true;
                    Common.SetToolTip(wrongTip, pbA2, Messages.AlarmLowLimitInvalid);
                }
                else
                {
                    // nothing
                }
            }


            if (!pbA4.Visible)
            {
                ResultForCheckTempWhetherExceedDefinedRange result = ConnectionController.IsOverTemp(Tag.DeviceID, tbA4Temp.Text, configUnit);
                if (result == ResultForCheckTempWhetherExceedDefinedRange.TooHigh)
                {
                    pbA4.Visible = true;
                    Common.SetToolTip(wrongTip, pbA4, Messages.AlarmHighLimitInvalid);
                }
                else if (result == ResultForCheckTempWhetherExceedDefinedRange.TooLow)
                {
                    pbA4.Visible = true;
                    Common.SetToolTip(wrongTip, pbA4, Messages.AlarmLowLimitInvalid);
                }
                else
                {
                    // nothing
                }
            }


            if (cbA5.Checked && !pbA5.Visible)
            {
                ResultForCheckTempWhetherExceedDefinedRange result = ConnectionController.IsOverTemp(Tag.DeviceID, tbA5Temp.Text, configUnit);
                if (result == ResultForCheckTempWhetherExceedDefinedRange.TooHigh)
                {
                    pbA5.Visible = true;
                    Common.SetToolTip(wrongTip, pbA5, Messages.AlarmHighLimitInvalid);
                }
                else if (result == ResultForCheckTempWhetherExceedDefinedRange.TooLow)
                {
                    pbA5.Visible = true;
                    Common.SetToolTip(wrongTip, pbA5, Messages.AlarmLowLimitInvalid);
                }
                else
                {
                    // nothing
                }
            }

            if (cbA6.Checked && !pbA6.Visible)
            {
                ResultForCheckTempWhetherExceedDefinedRange result = ConnectionController.IsOverTemp(Tag.DeviceID, tbA6Temp.Text, configUnit);
                if (result == ResultForCheckTempWhetherExceedDefinedRange.TooHigh)
                {
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA6, Messages.AlarmHighLimitInvalid);
                }
                else if (result == ResultForCheckTempWhetherExceedDefinedRange.TooLow)
                {
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA6, Messages.AlarmLowLimitInvalid);
                }
                else
                {
                    // nothing
                }
            }

            if (cbA1.Checked && !pbA1.Visible)
            {
                if (!pbA2.Visible && !string.IsNullOrEmpty(tbA1Temp.Text) && !string.IsNullOrEmpty(tbA3Temp.Text) &&
                    Convert.ToDouble(tbA1Temp.Text) >= Convert.ToDouble(tbA3Temp.Text))
                {
                    pbA1.Visible = true;
                    pbA2.Visible = true;
                    Common.SetToolTip(wrongTip, pbA1, string.Format("A{0} >= A{1}: {2}", "5", "4", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA2, string.Format("A{0} >= A{1}: {2}", "5", "4", Messages.HighLimitMoreThanLowLimit));
                }
                else if (!pbA4.Visible && !string.IsNullOrEmpty(tbA4Temp.Text) && Convert.ToDouble(tbA1Temp.Text) >= Convert.ToDouble(tbA4Temp.Text))
                {
                    pbA1.Visible = true;
                    pbA4.Visible = true;
                    Common.SetToolTip(wrongTip, pbA1, "Alarm limit over A3");
                    Common.SetToolTip(wrongTip, pbA1, string.Format("A{0} >= A{1}: {2}", "5", "3", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA4, string.Format("A{0} >= A{1}: {2}", "5", "3", Messages.HighLimitMoreThanLowLimit));
                }
                else if (!pbA5.Visible && cbA5.Checked && !string.IsNullOrEmpty(tbA5Temp.Text) && Convert.ToDouble(tbA1Temp.Text) >= Convert.ToDouble(tbA5Temp.Text))
                {
                    pbA1.Visible = true;
                    pbA5.Visible = true;
                    Common.SetToolTip(wrongTip, pbA1, "Alarm limit over A2");
                    Common.SetToolTip(wrongTip, pbA1, string.Format("A{0} >= A{1}: {2}", "5", "2", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA5, string.Format("A{0} >= A{1}: {2}", "5", "2", Messages.HighLimitMoreThanLowLimit));
                }
                else if (!pbA6.Visible && cbA6.Checked && !string.IsNullOrEmpty(tbA6Temp.Text) && Convert.ToDouble(tbA1Temp.Text) >= Convert.ToDouble(tbA6Temp.Text))
                {
                    pbA1.Visible = true;
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA1, "Alarm limit over A1");
                    Common.SetToolTip(wrongTip, pbA1, string.Format("A{0} >= A{1}: {2}", "5", "1", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA6, string.Format("A{0} >= A{1}: {2}", "5", "1", Messages.HighLimitMoreThanLowLimit));
                }
            }

            if (!pbA2.Visible)
            {
                if (!pbA4.Visible && !string.IsNullOrEmpty(tbA5Temp.Text) && Convert.ToDouble(tbA3Temp.Text) >= Convert.ToDouble(tbA4Temp.Text))
                {
                    pbA2.Visible = true;
                    pbA4.Visible = true;
                    Common.SetToolTip(wrongTip, pbA2, "Alarm limit over A3");
                    Common.SetToolTip(wrongTip, pbA2, string.Format("A{0} >= A{1}: {2}", "4", "3", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA4, string.Format("A{0} >= A{1}: {2}", "4", "3", Messages.HighLimitMoreThanLowLimit));
                }
                else if (!pbA5.Visible && cbA5.Checked && !string.IsNullOrEmpty(tbA5Temp.Text) && Convert.ToDouble(tbA3Temp.Text) >= Convert.ToDouble(tbA5Temp.Text))
                {
                    pbA2.Visible = true;
                    pbA5.Visible = true;
                    Common.SetToolTip(wrongTip, pbA2, "Alarm limit over A2");
                    Common.SetToolTip(wrongTip, pbA2, string.Format("A{0} >= A{1}: {2}", "4", "2", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA5, string.Format("A{0} >= A{1}: {2}", "4", "2", Messages.HighLimitMoreThanLowLimit));
                }
                else if (!pbA6.Visible && cbA6.Checked && !string.IsNullOrEmpty(tbA6Temp.Text) && Convert.ToDouble(tbA3Temp.Text) >= Convert.ToDouble(tbA6Temp.Text))
                {
                    pbA2.Visible = true;
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA2, "Alarm limit over A1");
                    Common.SetToolTip(wrongTip, pbA2, string.Format("A{0} >= A{1}: {2}", "4", "1", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA6, string.Format("A{0} >= A{1}: {2}", "4", "1", Messages.HighLimitMoreThanLowLimit));
                }
            }

            if (!pbA4.Visible)
            {
                if (!pbA5.Visible && cbA5.Checked && !string.IsNullOrEmpty(tbA5Temp.Text) && Convert.ToDouble(tbA4Temp.Text) >= Convert.ToDouble(tbA5Temp.Text))
                {
                    pbA4.Visible = true;
                    pbA5.Visible = true;
                    Common.SetToolTip(wrongTip, pbA4, "Alarm limit over A2");
                    Common.SetToolTip(wrongTip, pbA4, string.Format("A{0} >= A{1}: {2}", "3", "2", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA5, string.Format("A{0} >= A{1}: {2}", "3", "2", Messages.HighLimitMoreThanLowLimit));
                }
                else if (!pbA6.Visible && cbA6.Checked && !string.IsNullOrEmpty(tbA6Temp.Text) && Convert.ToDouble(tbA4Temp.Text) >= Convert.ToDouble(tbA6Temp.Text))
                {
                    pbA4.Visible = true;
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA4, "Alarm limit over A1");
                    Common.SetToolTip(wrongTip, pbA4, string.Format("A{0} >= A{1}: {2}", "3", "1", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA6, string.Format("A{0} >= A{1}: {2}", "3", "1", Messages.HighLimitMoreThanLowLimit));
                }
            }

            if (cbA5.Checked && !pbA5.Visible)
            {
                if (!pbA6.Visible && cbA6.Checked && !string.IsNullOrEmpty(tbA6Temp.Text) && Convert.ToDouble(tbA5Temp.Text) >= Convert.ToDouble(tbA6Temp.Text))
                {
                    pbA5.Visible = true;
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA5, "Alarm limit below A1");
                    Common.SetToolTip(wrongTip, pbA5, string.Format("A{0} >= A{1}: {2}", "2", "1", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA6, string.Format("A{0} >= A{1}: {2}", "2", "1", Messages.HighLimitMoreThanLowLimit));
                }
            }
        }
Ejemplo n.º 2
0
        private void InitEvent()
        {
            this.Load += new EventHandler(delegate(object sender, EventArgs args) {
                this.tbUserName.Focus();
                if (FirstCreate)
                {
                    this.parentForm.FormTitleText = InputBoxTitle.WizardCreateAdmin;
                }
                this.rbUser.Enabled  = !FirstCreate;
                this.rbAdmin.Checked = FirstCreate;
                this.rbUser.Checked  = !FirstCreate;
            });
            #region username
            this.tbUserName.Leave += new EventHandler(delegate(object sender, EventArgs args)
            {
                ((TextBox)sender).Text = ((TextBox)sender).Text.Trim();
                if (Common.TextBoxChecked((TextBox)sender))
                {
                    //判断用户名是否使用过
                    UserInfo user = processor.QueryOne <UserInfo>("select * from userinfo where username=@username COLLATE NOCASE", delegate()
                    {
                        Dictionary <string, object> dic = new Dictionary <string, object>();
                        dic.Add("username", tbUserName.Text.Trim().ToLower());
                        return(dic);
                    });
                    if (user.Userid == 0)
                    {
                        Common.ClearToolTip(this.wrongTip, this.pbUserNameTip);
                    }
                    else
                    {
                        Common.SetToolTip(this.wrongTip, this.pbUserNameTip, Messages.UserNameOccupied);
                    }
                }
                else
                {
                    Common.SetToolTip(this.wrongTip, this.pbUserNameTip, Messages.EmptyContentError);
                }
            });
            #endregion
            #region fullname
            this.tbFullName.Leave += new EventHandler(delegate(object sender, EventArgs args)
            {
                if (Common.TextBoxChecked((TextBox)sender))
                {
                    Common.ClearToolTip(this.wrongTip, this.pbFullNameTip);
                }
                else
                {
                    Common.SetToolTip(this.wrongTip, this.pbFullNameTip, Messages.EmptyContentError);
                }
            });
            #endregion
            #region desc
            this.tbDescription.Leave += new EventHandler(delegate(object sender, EventArgs args)
            {
                if (Common.TextBoxChecked(tbDescription))
                {
                    Common.ClearToolTip(this.wrongTip, this.pbRoleTip);
                }
                else
                {
                    Common.SetToolTip(this.wrongTip, this.pbRoleTip, Messages.EmptyContentError);
                }
            });
            #endregion
            #region pwd
            this.tbPwd.Leave += new EventHandler(delegate(object sender, EventArgs args)
            {
                if (Common.TextBoxChecked(tbPwd))
                {
                    //判断密钥长度
                    if (Common.Policy == null)
                    {
                        Common.ClearToolTip(this.wrongTip, this.pbPasswordTip);
                    }
                    else
                    {
                        if (tbPwd.Text.TrimEnd().Length >= Common.Policy.MinPwdSize)
                        {
                            Common.ClearToolTip(this.wrongTip, this.pbPasswordTip);
                        }
                        else
                        {
                            Common.SetToolTip(this.wrongTip, this.pbPasswordTip, string.Format(Messages.PasswordShortThanDefined, Common.Policy.MinPwdSize));
                        }
                    }
                }
                else
                {
                    Common.SetToolTip(this.wrongTip, this.pbPasswordTip, Messages.EmptyContentError);
                }
            });
            #endregion
            #region confirm
            this.tbConfirm.Leave += new EventHandler(delegate(object sender, EventArgs args)
            {
                if (Common.TextBoxChecked(tbConfirm))
                {
                    if (Common.PasswordConfirmed(tbPwd, tbConfirm))
                    {
                        Common.ClearToolTip(this.wrongTip, this.pbConfirmPasswordTip);
                    }
                    else
                    {
                        Common.SetToolTip(this.wrongTip, this.pbConfirmPasswordTip, Messages.MismatchPassword);
                    }
                }
                else
                {
                    Common.SetToolTip(this.wrongTip, this.pbConfirmPasswordTip, Messages.EmptyContentError);
                }
            });
            #endregion

            this.initGroupRadioCheckEvent();
            //非法字符处理事件
            this.tbUserName.TextChanged += new EventHandler((sender, e) => {
                Utils.IsInputTextValid(this.tbUserName);
            });
            this.tbFullName.TextChanged += new EventHandler((sender, e) =>
            {
                Utils.IsInputTextValid(this.tbFullName);
            });
        }
Ejemplo n.º 3
0
        private static void checkAllSingleAlarmTempFields(TextBox tbHigh, TextBox tbLow, PictureBox pbHigh, PictureBox pbLow, ToolTip wrongTip, SuperDevice Tag, string configUnit, CheckBox cbHigh, CheckBox cbLow)
        {
            string pattern = "^[-+]?[0-9]+[/.]?[0-9]?$";

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(pattern);
            if (cbHigh.Checked)
            {
                if (!regex.IsMatch(tbHigh.Text))
                {
                    pbHigh.Visible = true;
                    Common.SetToolTip(wrongTip, pbHigh, Messages.TemperatureValueInvalid);
                }
                else
                {
                    pbHigh.Visible = false;
                }
            }

            if (cbLow.Checked)
            {
                if (!regex.IsMatch(tbLow.Text))
                {
                    pbLow.Visible = true;
                    Common.SetToolTip(wrongTip, pbLow, Messages.TemperatureValueInvalid);
                }
                else
                {
                    pbLow.Visible = false;
                }
            }

            if (cbHigh.Checked && !pbHigh.Visible)
            {
                ResultForCheckTempWhetherExceedDefinedRange result = ConnectionController.IsOverTemp(Tag.DeviceID, tbHigh.Text, configUnit);
                if (result == ResultForCheckTempWhetherExceedDefinedRange.TooHigh)
                {
                    pbHigh.Visible = true;
                    Common.SetToolTip(wrongTip, pbHigh, Messages.AlarmHighLimitInvalid);
                }
                else if (result == ResultForCheckTempWhetherExceedDefinedRange.TooLow)
                {
                    pbHigh.Visible = true;
                    Common.SetToolTip(wrongTip, pbHigh, Messages.AlarmLowLimitInvalid);
                }
                else
                {
                    // nothing
                }
            }

            if (cbLow.Checked && !pbLow.Visible)
            {
                ResultForCheckTempWhetherExceedDefinedRange result = ConnectionController.IsOverTemp(Tag.DeviceID, tbLow.Text, configUnit);
                if (result == ResultForCheckTempWhetherExceedDefinedRange.TooHigh)
                {
                    pbLow.Visible = true;
                    Common.SetToolTip(wrongTip, pbLow, Messages.AlarmHighLimitInvalid);
                }
                else if (result == ResultForCheckTempWhetherExceedDefinedRange.TooLow)
                {
                    pbLow.Visible = true;
                    Common.SetToolTip(wrongTip, pbLow, Messages.AlarmLowLimitInvalid);
                }
                else
                {
                    // nothing
                }
            }

            if (cbHigh.Checked && cbLow.Checked && !pbHigh.Visible && !pbLow.Visible)
            {
                if (!string.IsNullOrEmpty(tbHigh.Text) && Convert.ToDouble(tbLow.Text) >= Convert.ToDouble(tbHigh.Text))
                {
                    pbHigh.Visible = true;
                    pbLow.Visible  = true;
                    Common.SetToolTip(wrongTip, pbLow, Messages.HighLimitMoreThanLowLimit);
                    Common.SetToolTip(wrongTip, pbHigh, Messages.HighLimitMoreThanLowLimit);
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 初始化事件
 /// </summary>
 private void InitEvent()
 {
     /*新密码校验*/
     this.tbNewPwd.Leave += new EventHandler(delegate(object sender, EventArgs args)
     {
         if (Common.TextBoxChecked(tbNewPwd))
         {
             //判断密钥长度
             if (Common.Policy == null)
             {
                 Common.ClearToolTip(this.wrongTip, this.pbNewPasswordTip);
             }
             else
             {
                 if (tbNewPwd.Text.TrimEnd().Length >= Common.Policy.MinPwdSize)
                 {
                     if (tbNewPwd.Text.TrimEnd() != Common.User.Pwd)
                     {
                         Common.ClearToolTip(this.wrongTip, this.pbNewPasswordTip);
                     }
                     else
                     {
                         Common.SetToolTip(this.wrongTip, this.pbNewPasswordTip, Messages.NewSameOfOldWhenResetPassword);
                     }
                 }
                 else
                 {
                     Common.SetToolTip(this.wrongTip, this.pbNewPasswordTip, string.Format(Messages.PasswordShortThanDefined, Common.Policy.MinPwdSize));
                 }
             }
         }
         else if (!Common.TextBoxChecked(tbNewPwd))
         {
         }
     });
     /*密码确认*/
     this.tbConfirm.Leave += new EventHandler(delegate(object sender, EventArgs args)
     {
         if (Common.TextBoxChecked(tbConfirm))
         {
             if (Common.PasswordConfirmed(tbNewPwd, tbConfirm))
             {
                 Common.ClearToolTip(this.wrongTip, this.pbConfirmNewPasswordTip);
             }
             else
             {
                 Common.SetToolTip(this.wrongTip, this.pbConfirmNewPasswordTip, Messages.MismatchPassword);
             }
         }
         else
         {
         }
     });
     /*保存修改后的密码*/
     this.btnOK.Click += new EventHandler(delegate(object sender, EventArgs args)
     {
         OK();
     });
     /*确认密码回车*/
     this.tbConfirm.KeyPress += new KeyPressEventHandler(delegate(object sender, KeyPressEventArgs args)
     {
         if (args.KeyChar == 13)
         {
             OK();
         }
     });
     tbNewPwd.KeyPress += new KeyPressEventHandler((sender, args) =>
     {
         if (args.KeyChar == 13)
         {
             tbConfirm.Focus();
         }
     });
 }