Exemplo n.º 1
0
        public bool CheckFieldNumber(Control control)
        {
            bool check = true;

            // field number
            if (control.Name == "txtPhone" || control.Name == "txtNumberID" || control.Name == "txtSalary")
            {
                rule r = new rule();
                if (control.Name == "txtPhone")
                {
                    if (r.CheckPhone(control.Text) == false)
                    {
                        check = false;
                        this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Red;
                    }
                    else
                    {
                        this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Green;
                    }
                }
                else
                {
                    if (control.Name == "txtNumberID")
                    {
                        if (r.CheckNumberID(control.Text) == false)
                        {
                            check = false;
                            this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Red;
                        }
                        else
                        {
                            this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Green;
                        }
                    }
                    else
                    {
                        if (r.CheckNumber(control.Text) == false)
                        {
                            check = false;
                            this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Red;
                        }
                        else
                        {
                            this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Green;
                        }
                    }
                }
            }
            return(check);
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            rule r = new rule();

            if (txtPositionID.Text.Trim().Length > 0 && txtPositionName.Text.Trim().Length > 0 && r.CheckNumber(txtSalary.Text.Trim()) == true)
            {
                try
                {
                    positionBLL.Save(txtPositionID.Text, txtPositionName.Text, txtSalary.Text, txtPositionID.Text);
                    //update control

                    //
                    btnSave.Enabled = false;
                    DisplayNotify("Lưu dữ liệu thành công", 1);
                }
                catch (Exception ex)
                {
                    DisplayNotify("Lỗi Lưu  dữ liệu không thành công", -1);
                }
            }
            else
            {
                DisplayNotify("Lỗi nhập sai các ô nhập liệu hoặc nhập thiếu", -1);
            }
        }