private void tt_dienthoai_Leave(object sender, EventArgs e)
 {
     if (tt_dienthoai.Text.Length == 10)
     {
         if (tt_dienthoai.Text[0] == '0')
         {
             for (int i = 0; i < 10; i++)
             {
                 if (!(48 <= (int)tt_dienthoai.Text[i] && (int)tt_dienthoai.Text[i] <= 57))
                 {
                     Tick.Clear();
                     errorProvider1.SetError(tt_dienthoai, "Có ký tự không phải số trong số điện thoại");
                     dt = false;
                     return;
                 }
             }
         }
         else
         {
             Tick.Clear();
             errorProvider1.SetError(tt_dienthoai, "Số điện thoại phải bắt đầu số 0 ");
             dt = false;
         }
         errorProvider1.Clear();
         Tick.SetError(tt_dienthoai, "Xong");
         dt = true;
     }
     else
     {
         Tick.Clear();
         errorProvider1.SetError(tt_dienthoai, "Số điện thoại không đủ 10 chữ số");
         dt = false;
     }
 }
 private void tt_Matkhau_Leave(object sender, EventArgs e)
 {
     if (tt_Matkhau.Text.Length == 0)
     {
         Tick.Clear();
         errorProvider1.SetError(this.tt_Matkhau, "Bạn chưa nhập mật khẩu! ");
         mk = false;
     }
     else if (tt_Matkhau.Text.Length < 9)
     {
         Tick.Clear();
         errorProvider1.SetError(tt_Matkhau, "Mật khẩu quá ngắn");
         mk = false;
     }
     else if (Regex.IsMatch(tt_Matkhau.Text, "^[!-~]*$"))
     {
         errorProvider1.Clear();
         Tick.SetError(tt_Matkhau, "xong");
         mk = true;
     }
     else
     {
         Tick.Clear();
         errorProvider1.SetError(tt_Matkhau, "Không đúng dữ liệu nhập");
         mk = false;
     }
 }
Beispiel #3
0
 public void Set_false()
 {
     Tick.Clear();
     pname    = false;
     paddress = false;
     pmail    = false;
     pdate    = false;
     er.SetError(f2Name, null);
     buttonSua.Enabled = false;
 }
 private void Kho_NamXuatBan_Validating(object sender, CancelEventArgs e)
 {
     if (DateTime.Now.Year - Kho_NamXuatBan.Value <= 8 && DateTime.Now.Year >= Kho_NamXuatBan.Value)
     {
         e.Cancel = false;
         errorProvider1.SetError(Kho_NamXuatBan, null);
         Tick.SetError(Kho_NamXuatBan, "xong");
     }
     else
     {
         e.Cancel = true;
         Tick.Clear();
         errorProvider1.SetError(Kho_NamXuatBan, "Yêu cầu sách xuất bản trong 8 năm đổi lại");
     }
 }
 private void Kho_NhaXuatBan_Validating(object sender, CancelEventArgs e)
 {
     if (!Only_letter(Kho_NhaXuatBan.Text) || Kho_NhaXuatBan.Text.Length == 0)
     {
         e.Cancel = true;
         errorProvider1.SetError(Kho_NhaXuatBan, "Vui lòng nhập đúng yêu cầu");
         Tick.Clear();
     }
     else
     {
         e.Cancel = false;
         errorProvider1.SetError(Kho_NhaXuatBan, null);
         Tick.SetError(Kho_NhaXuatBan, "xong");
     }
 }
 private void Kho_TheLoai_Validating(object sender, CancelEventArgs e)
 {
     if (Kho_TheLoai.SelectedIndex == -1)
     {
         Tick.Clear();
         errorProvider1.SetError(Kho_TheLoai, "Vui lòng chọn thể loại sách");
         e.Cancel = true;
     }
     else
     {
         errorProvider1.Clear();
         Tick.SetError(Kho_TheLoai, "xong");
         e.Cancel = false;
     }
 }
        /* private void QuanLyKho_FormClosing(object sender, FormClosingEventArgs e)
         * {
         *       AutoValidate = AutoValidate.Disable;
         *       e.Cancel = true;
         *     //  con.Close();
         * }*/

        private void Kho_Gia_Validating(object sender, CancelEventArgs e)
        {
            if (Kho_Gia.Value - Kho_Gia.Minimum <= 0)
            {
                Tick.Clear();
                e.Cancel = true;
                errorProvider1.SetError(Kho_MenhGia, "Chưa nhập giá sách");
            }
            else
            {
                e.Cancel = false;
                errorProvider1.SetError(Kho_MenhGia, null);
                Tick.SetError(Kho_MenhGia, "xong");
            }
        }
Beispiel #8
0
 private void f2Email_Leave(object sender, EventArgs e)
 {
     if (Regex.IsMatch(f2Email.Text, @"^([a-zA-Z0-9]+)@([a-zA-Z0-9]+)\.(([a-zA-Z0-9])+)$"))
     {
         er.Clear();
         Tick.SetError(f2Email, "xong");
         pmail = true;
     }
     else
     {
         pmail = false;
         Tick.Clear();
         er.SetError(this.f2Email, "Bạn nhập sai định dạng  email! ");
     }
 }
Beispiel #9
0
 private void f2Address_Leave(object sender, EventArgs e)
 {
     if (f2Address.Text.Length == 0)
     {
         Tick.Clear();
         er.SetError(this.f2Address, "Bạn chưa nhập địa chỉ! ");
         paddress = false;
     }
     else
     {
         er.Clear();
         Tick.SetError(f2Address, "xong");
         paddress = true;
     }
 }
Beispiel #10
0
 private void f2NgaySinh_Leave(object sender, EventArgs e)
 {
     if (DateTime.Now.Year - f2NgaySinh.Value.Year >= 18 && DateTime.Now.Year - f2NgaySinh.Value.Year <= 55)
     {
         pdate = true;
         er.Clear();
         Tick.SetError(f2NgaySinh, "xong");
     }
     else
     {
         Tick.Clear();
         er.SetError(f2NgaySinh, "Độ tuổi yêu cầu từ 18 đến 55!!");
         pdate = false;
     }
 }
 private void Kho_TacGia_Validating(object sender, CancelEventArgs e)
 {
     try
     {
         if (Kho_TacGia.Text.Length != 0)
         {
             char[] trimChars = { '\\', '|', '\'', ' ', '@', ' ', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', '_', '+', '[', '{', ']', '}', ';', ':', '"', ',', '<', '.', '>', '/', '?' };
             Kho_TacGia.Text = Kho_TacGia.Text.Trim(trimChars);
             int  slc = 0;
             bool c   = false;
             for (int i = 0; i < Kho_TacGia.Text.Length; i++)
             {
                 if (Kho_TacGia.Text[i] >= 33 && Kho_TacGia.Text[i] <= 57 || Kho_TacGia.Text[i] >= 58 && Kho_TacGia.Text[i] <= 64 || Kho_TacGia.Text[i] >= 91 && Kho_TacGia.Text[i] <= 96 || Kho_TacGia.Text[i] >= 123 && Kho_TacGia.Text[i] <= 126)
                 {
                     Kho_TacGia.Text = Kho_TacGia.Text.Remove(i, 1);
                     i = -1;
                 }
             }
             for (int i = 0; i < Kho_TacGia.Text.Length; i++)
             {
                 if (c != true && Kho_TacGia.Text[i] >= 'a' && Kho_TacGia.Text[i] <= 'z' || c != true && Kho_TacGia.Text[i] >= 'A' && Kho_TacGia.Text[i] <= 'Z')
                 {
                     slc++;
                     c = true;
                 }
                 if (Kho_TacGia.Text[i] == ' ' && c == true)
                 {
                     c = false;
                 }
             }
             for (int i = 0; i < Kho_TacGia.Text.Length; i++)
             {
                 if (Kho_TacGia.Text[i] == ' ' && Kho_TacGia.Text[i + 1] == ' ')
                 {
                     Kho_TacGia.Text = Kho_TacGia.Text.Remove(i, 1);
                 }
             }
             c = false;
             string x  = "";
             string xx = "";
             for (int i = 0; i < Kho_TacGia.Text.Length; i++)
             {
                 if (c == false && Kho_TacGia.Text[i] >= 127 || c == false && Kho_TacGia.Text[i] >= 'a' && Kho_TacGia.Text[i] <= 'z' || c == false && Kho_TacGia.Text[i] >= 'A' && Kho_TacGia.Text[i] <= 'Z')
                 {
                     x += Kho_TacGia.Text[i];
                 }
                 if (Kho_TacGia.Text[i] == ' ')
                 {
                     c = true;
                 }
                 if (c == true || i + 1 == Kho_TacGia.Text.Length)
                 {
                     x = x.Substring(0, 1).ToUpper() + x.Substring(1, x.Length - 1).ToLower();
                     slc--;
                     xx += x + " ";
                     x   = "";
                     c   = false;
                 }
             }
             Kho_TacGia.Text = xx.Trim();
         }
         if (Kho_TacGia.Text.Length == 0)
         {
             Tick.Clear();
             errorProvider1.SetError(this.Kho_TacGia, "Vui lòng nhập lại!!");
             e.Cancel = true;
         }
         else
         {
             errorProvider1.Clear();
             Tick.SetError(Kho_TacGia, "You passed!");
             e.Cancel = false;
         }
     }
     catch
     {
         Tick.Clear();
         errorProvider1.SetError(this.Kho_TacGia, "Vui lòng nhập lại!");
         e.Cancel = true;
     }
 }
Beispiel #12
0
 //=========================================== Xử lý =================
 private void f2Name_Leave(object sender, EventArgs e)
 {
     if (f2Name.Text.Length != 0)
     {
         char[] trimChars = { '\\', '|', '\'', ' ', '@', ' ', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', '_', '+', '[', '{', ']', '}', ';', ':', '"', ',', '<', '.', '>', '/', '?' };
         f2Name.Text = f2Name.Text.Trim(trimChars);
         int  slc = 0;
         bool c   = false;
         for (int i = 0; i < f2Name.Text.Length; i++)
         {
             if (f2Name.Text[i] >= 33 && f2Name.Text[i] <= 57 || f2Name.Text[i] >= 58 && f2Name.Text[i] <= 64 || f2Name.Text[i] >= 91 && f2Name.Text[i] <= 96 || f2Name.Text[i] >= 123 && f2Name.Text[i] <= 126)
             {
                 f2Name.Text = f2Name.Text.Remove(i, 1);
                 i           = -1;
             }
         }
         for (int i = 0; i < f2Name.Text.Length; i++)
         {
             if (c != true && f2Name.Text[i] >= 'a' && f2Name.Text[i] <= 'z' || c != true && f2Name.Text[i] >= 'A' && f2Name.Text[i] <= 'Z')
             {
                 slc++;
                 c = true;
             }
             if (f2Name.Text[i] == ' ' && c == true)
             {
                 c = false;
             }
         }
         for (int i = 0; i < f2Name.Text.Length; i++)
         {
             if (f2Name.Text[i] == ' ' && f2Name.Text[i + 1] == ' ')
             {
                 f2Name.Text = f2Name.Text.Remove(i, 1);
             }
         }
         c = false;
         string x  = "";
         string xx = "";
         for (int i = 0; i < f2Name.Text.Length; i++)
         {
             if (c == false && f2Name.Text[i] >= 127 || c == false && f2Name.Text[i] >= 'a' && f2Name.Text[i] <= 'z' || c == false && f2Name.Text[i] >= 'A' && f2Name.Text[i] <= 'Z')
             {
                 x += f2Name.Text[i];
             }
             if (f2Name.Text[i] == ' ')
             {
                 c = true;
             }
             if (c == true || i + 1 == f2Name.Text.Length)
             {
                 x = x.Substring(0, 1).ToUpper() + x.Substring(1, x.Length - 1).ToLower();
                 slc--;
                 xx += x + " ";
                 x   = "";
                 c   = false;
             }
         }
         f2Name.Text = xx.Trim();
     }
     if (f2Name.Text.Length == 0)
     {
         Tick.Clear();
         er.SetError(this.f2Name, "Vui lòng nhập lại!!");
         pname = false;
     }
     else
     {
         er.Clear();
         Tick.SetError(f2Name, "You passed!");
         pname = true;
     }
 }