Exemplo n.º 1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtTen.Text == "")
            {
                error.SetError(txtTen, "Vui lòng điền thông tin !");
            }
            else
            {
                error.SetError(txtTen, string.Empty);
            }

            if (lePhanLoai.Text == "")
            {
                error.SetError(lePhanLoai, "Vui lòng điền thông tin !");
            }
            else
            {
                error.SetError(lePhanLoai, string.Empty);
            }

            if (leDonVi.Text == "")
            {
                error.SetError(leDonVi, "Vui lòng điền thông tin !");
            }
            else
            {
                error.SetError(leDonVi, string.Empty);
            }

            if (txtMa.Text == "")
            {
                error.SetError(txtMa, "Vui lòng điền thông tin !");
            }
            else if (add == true && BUS_HangHoa.KiemTraHH(txtMa.Text))
            {
                error.SetError(txtMa, "Mã đã tồn tại, vui lòng chọn mã khác !");
            }
            else
            {
                error.SetError(txtMa, string.Empty);
            }

            if (error.GetError(txtMa) == "" && error.GetError(txtTen) == "" &&
                error.GetError(leDonVi) == "" && error.GetError(lePhanLoai) == "")
            {
                if (add == true)
                {
                    xlThem();
                }
                else
                {
                    xlSua();
                }
            }
        }
Exemplo n.º 2
0
        internal static bool ValidarMascara(TextEdit textEdit, DXErrorProvider dXErrorProvider)
        {
            dXErrorProvider.ClearErrors();

            eMascara mascara = textEdit.RetornarValorPropriedade <eMascara>("Mascara");

            if (mascara != eMascara.Default &&
                !textEdit.Text.NuloOuVazio())
            {
                switch (mascara)
                {
                case eMascara.Email:
                {
                    if (textEdit.Text.IndexOf("@").Equals(-1))
                    {
                        dXErrorProvider.SetError(textEdit, "Entre com um e-mail válido.", ErrorType.Critical);
                    }

                    break;
                }
                }

                if (dXErrorProvider.HasErrors)
                {
                    textEdit.Focus();
                }
            }

            dXErrorProvider.GetError(textEdit);

            return(!dXErrorProvider.HasErrors);
        }
Exemplo n.º 3
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtTen.Text == "")
            {
                error.SetError(txtTen, "Vui lòng điền thông tin !");
            }
            else
            {
                error.SetError(txtTen, string.Empty);
            }

            if (txtMa.Text == "")
            {
                error.SetError(txtMa, "Vui lòng điền thông tin !");
            }
            else if (add == true && BUS_KhachHang.KiemTraKH(txtMa.Text))
            {
                error.SetError(txtMa, "Mã đã tồn tại, vui lòng chọn mã khác !");
            }
            else
            {
                error.SetError(txtMa, string.Empty);
            }

            if (leKhuVuc.Text == "")
            {
                error.SetError(leKhuVuc, "Vui lòng chọn khu vực !");
            }
            else
            {
                error.SetError(txtMa, string.Empty);
            }

            if (error.GetError(txtMa) == "" && error.GetError(txtTen) == "")
            {
                if (add == true)
                {
                    xlThem();
                }
                else
                {
                    xlSua();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Hàm xử lý việc sửa thông tin
        /// </summary>
        private void xlSua()
        {
            if (txtTen.Text == "")
            {
                error.SetError(txtTen, "Vui lòng điền thông tin !");
            }
            else
            {
                error.SetError(txtTen, string.Empty);
            }

            if (error.GetError(txtTen) == string.Empty)
            {
                switch (flag)
                {
                case 0:
                {
                    SuaKV(); break;
                }

                case 1:
                {
                    SuaDV(); break;
                }

                case 2:
                {
                    SuaNH(); break;
                }

                case 3:
                {
                    SuaBP(); break;
                }
                }
                ;
            }
        }
Exemplo n.º 5
0
        private string ValidarValorConformeMascara(CancelEventArgs e = null)
        {
            this._dXErrorProvider.ClearErrors();

            if (_mascara == eMascara.Email && !String.IsNullOrEmpty(base.Text))  // E-mail
            {
                if (this.Text.IndexOf("@").Equals(-1))
                {
                    this._dXErrorProvider.SetError(this, "Entre com um e-mail válido", ErrorType.Critical);
                    this.Focus();
                }
            }
            else if (e != null)
            {
                base.OnValidating(e);
            }

            return(_dXErrorProvider.GetError(this));
        }