Esempio n. 1
0
        private void editDgvMain_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (dgvEX1.ReadOnly || dgvEX1.CurrentCell == null || !dgvEX1.CurrentCell.IsInEditMode)
            {
                return;
            }
            string str = dgvEX1.CurrentCell.EditedFormattedValue.ToString();

            if (str == "")
            {
                return;
            }
            switch (dgvEX1.Columns[e.ColumnIndex].Name)
            {
            case "Column3":
                if (UserProc.IsNumeric(str) && !(Convert.ToDecimal(str) < new Decimal(0)))
                {
                    break;
                }
                int num1 = (int)MessageBox.Show((IWin32Window)this, "请输入正确 <比例>( >= 0数值 )!!!", "提示");
                e.Cancel = true;
                break;

            case "Column4":
                if (!(str != "owf") || !(str != "g/L") || !(str != "mL/L"))
                {
                    break;
                }
                int num2 = (int)MessageBox.Show((IWin32Window)this, "请输入正确 <浓度单位>!!!", "提示");
                e.Cancel = true;
                break;
            }
        }
Esempio n. 2
0
        private void getVal_AND()
        {
            string str1 = this.ReadExisting();

            this.DiscardInBuffer();
            this.DiscardOutBuffer();
            int num        = str1.LastIndexOf('g');
            int startIndex = num - 13;

            if (num >= 0 && startIndex >= 0)
            {
                string str2 = str1.Substring(startIndex, 13);
                this.WenDing = !str2.StartsWith("SD");
                string str3 = str2.Trim('S', 'D', ' ');
                if (str3 != "" && UserProc.IsNumeric(str3))
                {
                    this.showVal = new Decimal?(Convert.ToDecimal(str3) / new Decimal(1000));
                }
                else
                {
                    this.showVal = new Decimal?();
                    this.WenDing = false;
                }
            }
            else
            {
                this.showVal = new Decimal?();
                this.WenDing = false;
            }
        }
Esempio n. 3
0
 private void Txt_Validating(object sender, CancelEventArgs e)
 {
     this.txt.Text = this.txt.Text.Trim();
     if (this.txt.Text.Length > 0)
     {
         if (this.txt.Text.Length > this._txtLen)
         {
             e.Cancel = true;
             this.errP.SetError(this, "字数不能大于:" + this._txtLen.ToString());
             return;
         }
         if (this._txtISid && !Regex.IsMatch(this.txt.Text, "[A-Z0-9-]{" + this.txt.Text.Length.ToString() + "}"))
         {
             e.Cancel = true;
             this.errP.SetError(this, "大写字母、数字、- 的组合");
             return;
         }
         if (this._txtISint && !UserProc.IsInt(this.txt.Text))
         {
             e.Cancel = true;
             this.errP.SetError(this, "整数");
             return;
         }
         if (this._txtISmoney && !UserProc.IsNumeric(this.txt.Text))
         {
             e.Cancel = true;
             this.errP.SetError(this, "数值");
             return;
         }
     }
     this.errP.SetError(this, "");
 }
Esempio n. 4
0
        private void getVal_Tscale_QHW()
        {
            string str1 = this.ReadExisting();

            this.DiscardInBuffer();
            this.DiscardOutBuffer();
            int num        = str1.LastIndexOf('g');
            int startIndex = num - 16;

            if (num >= 0 && startIndex >= 0)
            {
                string str2 = str1.Substring(startIndex, 17);
                string str3 = str2.Substring(6, 8);
                bool   flag = !str3.StartsWith("-");
                string str4 = str3.Trim('-', ' ');
                if (UserProc.IsNumeric(str4))
                {
                    this.showVal = new Decimal?(Convert.ToDecimal(str4));
                    Decimal?showVal;
                    if (!flag)
                    {
                        showVal      = this.showVal;
                        this.showVal = showVal.HasValue ? new Decimal?(-showVal.GetValueOrDefault()) : new Decimal?();
                    }
                    if (str2.Substring(15, 2) == "kg")
                    {
                        showVal      = this.showVal;
                        this.showVal = showVal.HasValue ? new Decimal?(showVal.GetValueOrDefault() * new Decimal(1000)) : new Decimal?();
                    }
                    if (str2.StartsWith("ST,"))
                    {
                        this.WenDing = true;
                    }
                    else
                    {
                        this.WenDing = false;
                    }
                }
                else
                {
                    this.showVal = new Decimal?();
                    this.WenDing = false;
                }
            }
            else
            {
                this.showVal = new Decimal?();
                this.WenDing = false;
            }
        }
Esempio n. 5
0
 private void this_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Prior)
     {
         int rowIndex = this.dgvRL.CurrentCell.RowIndex;
         if (rowIndex <= 0)
         {
             return;
         }
         this.dgvRL.CurrentCell = this.dgvRL.Rows[rowIndex - 1].Cells[0];
     }
     else if (e.KeyCode == Keys.Next)
     {
         int rowIndex = this.dgvRL.CurrentCell.RowIndex;
         if (rowIndex >= this.dgvRL.RowCount - 1)
         {
             return;
         }
         this.dgvRL.CurrentCell = this.dgvRL.Rows[rowIndex + 1].Cells[0];
     }
     else if (e.KeyCode == this.cancelKey)
     {
         this.DialogResult = DialogResult.Cancel;
     }
     else
     {
         if (e.KeyCode != Keys.Return)
         {
             return;
         }
         if (this.lblCheng.Text == "" || this.lblDT.Text == "")
         {
             frmError frmError = new frmError("请选择正确滴头!!!");
             int      num      = (int)frmError.ShowDialog((IWin32Window)this);
             frmError.Close();
             this.txtZL.Focus();
         }
         else if (this.txtZL.Text == "" || !UserProc.IsNumeric(this.txtZL.Text) || Convert.ToDecimal(this.txtZL.Text) <= new Decimal(0))
         {
             frmError frmError = new frmError("请输入正确重量( >=0 )!!!");
             int      num      = (int)frmError.ShowDialog((IWin32Window)this);
             frmError.Close();
             this.txtZL.Focus();
         }
         else
         {
             this.DialogResult = DialogResult.OK;
         }
     }
 }
Esempio n. 6
0
        private void getVal_Tscale_T2000()
        {
            this.DiscardInBuffer();
            this.DiscardOutBuffer();
            this.Write("R");
            Thread.Sleep(100);
            string str1 = this.ReadExisting();

            if (str1.Length == 17)
            {
                string str2 = str1.Substring(5, 8);
                bool   flag = !str2.StartsWith("-");
                string str3 = str2.Trim('-', ' ');
                if (UserProc.IsNumeric(str3))
                {
                    this.showVal = new Decimal?(Convert.ToDecimal(str3));
                    Decimal?showVal;
                    if (!flag)
                    {
                        showVal      = this.showVal;
                        this.showVal = showVal.HasValue ? new Decimal?(-showVal.GetValueOrDefault()) : new Decimal?();
                    }
                    if (str1.Substring(13, 2) == "kg")
                    {
                        showVal      = this.showVal;
                        this.showVal = showVal.HasValue ? new Decimal?(showVal.GetValueOrDefault() * new Decimal(1000)) : new Decimal?();
                    }
                    if (str1.StartsWith("ST,"))
                    {
                        this.WenDing = true;
                    }
                    else
                    {
                        this.WenDing = false;
                    }
                }
                else
                {
                    this.showVal = new Decimal?();
                    this.WenDing = false;
                }
            }
            else
            {
                this.showVal = new Decimal?();
                this.WenDing = false;
            }
        }
Esempio n. 7
0
        private void getVal_ZHUOJING()
        {
            string str1 = this.ReadExisting();

            if (str1.Length == 0)
            {
                this.WenDing = true;
                if (isFrist)
                {
                    this.showVal = new Decimal?(Convert.ToDecimal("0.00"));
                }
                return;
            }
            isFrist = false;
            this.DiscardInBuffer();
            this.DiscardOutBuffer();
            int num        = str1.LastIndexOf("g");
            int startIndex = num - 10;

            if (num >= 0 && startIndex >= 0)
            {
                string str2 = str1.Substring(startIndex, 10);
                this.WenDing = UserProc.IsNumeric(str2); //str2.IndexOf("0.00") >= 0; // .StartsWith("S");
                string str3 = str2.Substring(1);
                bool   flag = !str3.StartsWith("-");
                string str4 = str3.Trim('-', ' ').Trim();
                if (str4 != "" && UserProc.IsNumeric(str4))
                {
                    this.showVal = new Decimal?(Convert.ToDecimal(str4));
                    if (flag)
                    {
                        return;
                    }
                    Decimal?showVal = this.showVal;
                    this.showVal = showVal.HasValue ? new Decimal?(-showVal.GetValueOrDefault()) : new Decimal?();
                }
                else
                {
                    this.showVal = new Decimal?();
                    this.WenDing = false;
                }
            }
            else
            {
                this.showVal = new Decimal?();
                this.WenDing = false;
            }
        }
Esempio n. 8
0
        private void getVal_OHAUS()
        {
            string str1 = this.ReadExisting();

            this.DiscardInBuffer();
            this.DiscardOutBuffer();
            int startIndex = -1;
            int num        = str1.LastIndexOf("g?");

            if (num >= 0)
            {
                this.WenDing = false;
            }
            else
            {
                num = str1.LastIndexOf("g\r");
                if (num >= 0)
                {
                    this.WenDing = true;
                }
            }
            if (num - 3 >= 0)
            {
                startIndex = str1.LastIndexOf(' ', num - 3);
            }
            if (num >= 0 && startIndex >= 0)
            {
                string str2 = str1.Substring(startIndex, num - startIndex).Trim();
                if (str2 != "" && UserProc.IsNumeric(str2))
                {
                    this.showVal = new Decimal?(Convert.ToDecimal(str2));
                }
                else
                {
                    this.showVal = new Decimal?();
                    this.WenDing = false;
                }
            }
            else
            {
                this.showVal = new Decimal?();
                this.WenDing = false;
            }
        }
Esempio n. 9
0
        private void getMao_XK3190C8()
        {
            byte[] buffer = new byte[7]
            {
                (byte)0,
                (byte)2,
                (byte)65,
                (byte)66,
                (byte)48,
                (byte)51,
                (byte)3
            };
            this.DiscardInBuffer();
            this.DiscardOutBuffer();
            this.Write(buffer, 0, 7);
            Thread.Sleep(150);
            string str1 = this.ReadExisting();

            if (str1.Length == 14)
            {
                string str2 = str1.Substring(3, 8);
                if (UserProc.IsNumeric(str2))
                {
                    this.maoVal  = new Decimal?(Convert.ToDecimal(str2) * new Decimal(1000));
                    this.WenDing = true;
                }
                else
                {
                    this.maoVal  = new Decimal?();
                    this.WenDing = false;
                }
            }
            else
            {
                this.maoVal  = new Decimal?();
                this.WenDing = false;
            }
        }
Esempio n. 10
0
 private void this_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Return)
     {
         this.txtZL.Text = this.txtZL.Text.Trim();
         if (this.txtZL.Text == "" || !UserProc.IsNumeric(this.txtZL.Text) || Convert.ToDecimal(this.txtZL.Text) < new Decimal(0) || Convert.ToDecimal(this.txtZL.Text) > this.CLmbzl)
         {
             this.txtZL.SelectAll();
             this.txtZL.Focus();
         }
         else
         {
             this.DialogResult = DialogResult.OK;
         }
     }
     else
     {
         if (e.KeyCode != this.cancelKey)
         {
             return;
         }
         this.DialogResult = DialogResult.Cancel;
     }
 }