コード例 #1
0
 public string search_2(string txtbox, string txtbox2)
 {
     if (txtbox == "TENSACH")
     {
         if (txtbox2.Length - 1 > 50)
         {
             MessageBox.Show("Tên sách không hợp lệ");
             return("Tên sách không hợp lệ");
         }
     }
     else if (txtbox == "TENTG")
     {
         if (txtbox2.Length - 1 > 30)
         {
             MessageBox.Show("Tên tác giả không hợp lệ");
             return("Tên tác giả không hợp lệ");
         }
     }
     else if (txtbox == "TENNXB")
     {
         if (txtbox2.Length - 1 > 30)
         {
             MessageBox.Show("Tên NXB không hợp lệ");
             return("Tên NXB không hợp lệ");
         }
     }
     else if (txtbox == "MALINHVUC")
     {
         if (txtbox2.Length - 1 > 10)
         {
             MessageBox.Show("Mã lĩnh vực không hợp lệ");
             return("Mã lĩnh vực không hợp lệ");
         }
     }
     else if (txtbox == "NAMXB")
     {
         CheckDate year = new CheckDate();
         if (year.Check_Year(txtbox2) == "Năm không hợp lệ")
         {
             MessageBox.Show(year.Check_Year(txtbox2));
             return(year.Check_Year(txtbox2));
         }
     }
     else if (txtbox == "NGAYNHAP")
     {
         CheckDate date = new CheckDate();
         if (date.Check_Year(txtbox2) == "Ngày không hợp lệ")
         {
             MessageBox.Show(date.Check_Year(txtbox2));
             return(date.Check_Year(txtbox2));
         }
     }
     return("");
 }
コード例 #2
0
ファイル: Update_BookInf.cs プロジェクト: nguyendat090897/dat
 public bool Update_Bookinfs(string MASACH, string TENSACH, string MATG, string MANXB, string MALv, string NAMXB, string SOTRANG, string SOLUONG, string NGAYNHAP, string GHICHU)
 {
     try
     {
         if (MASACH.Length < 5)
         {
             MessageBox.Show("Mã sách quá ngắn");
             return(false);
         }
         else if (MASACH == "")
         {
             MessageBox.Show("Mã sách không hợp lệ");
             return(false);
         }
         else if (MASACH.Length > 11)
         {
             MessageBox.Show("Mã sách quá dài");
             return(false);
         }
         else if (TENSACH.Length < 5)
         {
             MessageBox.Show("Tên sách quá ngắn");
             return(false);
         }
         else if (TENSACH.Length > 100)
         {
             MessageBox.Show("Tên sách quá dài");
             return(false);
         }
         else if (TENSACH == "")
         {
             MessageBox.Show("Tên sách không hợp lệ");
             return(false);
         }
         else if (date.Check_Year(NAMXB) == "Năm không hợp lệ")
         {
             MessageBox.Show("Năm không hợp lệ");
             return(false);
         }
         else if (Convert.ToInt16(NAMXB) < 1900)
         {
             MessageBox.Show("Sách đã quá hạn");
             return(false);
         }
         else if (Convert.ToInt16(NAMXB) > 2019)
         {
             MessageBox.Show("Sách quá hư cấu");
             return(false);
         }
         else if (Convert.ToInt16(SOTRANG) <= 0)
         {
             MessageBox.Show("Sách không đọc được phát lào");
             return(false);
         }
         string strInsert = "Insert Into tblSach(MASACH,TENSACH,MATG,MANXB,MALv,NAMXB,SOTRANG,SOLUONG,NGAYNHAP,GHICHU) values ('" + MASACH + "','" + TENSACH + "','" + MATG + "','" + MANXB + "','" + MALv + "','" + NAMXB + "','" + SOTRANG + "','" + SOLUONG + "','" + NGAYNHAP + "','" + GHICHU + "')";
         cls.ThucThiSQLTheoPKN(strInsert);
         MessageBox.Show("Thêm thành công");
         return(true);
     }
     catch
     {
         MessageBox.Show("Trùng mã");
         return(false);
     }
     MessageBox.Show("Trùng mã");
     return(false);
 }
コード例 #3
0
        public string search_1(string cbbox, string txtbox)
        {
            string d;

            d = " select * from tblSach";
            if (cbbox == "TENSACH")
            {
                if (txtbox.Length - 1 > 50)
                {
                    d = " select * from tblSach";
                }
                else if (txtbox == "")
                {
                    d = " select * from tblSach";
                }
                else
                {
                    d = "select*from tblSach where (TENSACH like '%" + txtbox + "%' OR MASACH LIKE '%" + txtbox + "%')";
                }
            }
            else if (cbbox == "TENTG")
            {
                if (txtbox.Length - 1 > 30)
                {
                    d = " select * from tblSach";
                }
                else if (txtbox.Length == 0)
                {
                    d = " select * from tblSach";
                }
                else
                {
                    d = "select*from tblSach where (TENTG like '%" + txtbox + "%' OR MATG LIKE '%" + txtbox + "%')";
                }
            }
            else if (cbbox == "TENNXB")
            {
                if (txtbox.Length - 1 > 30)
                {
                    d = " select * from tblSach";
                }
                else if (txtbox.Length == 0)
                {
                    d = " select * from tblSach";
                }
                else
                {
                    d = "select*from tblSach where (MANXB like '%" + txtbox + "%' OR TENNXB LIKE '%" + txtbox + "%')";
                }
            }
            else if (cbbox == "MALINHVUC")
            {
                if (txtbox.Length - 1 > 10)
                {
                    d = " select * from tblSach";
                }
                else if (txtbox.Length == 0)
                {
                    d = " select * from tblSach";
                }
                else
                {
                    d = "select*from tblSach where (MaLv like '%" + txtbox + "%')";
                }
            }
            else if (cbbox == "NAMXB")
            {
                CheckDate year = new CheckDate();
                if (txtbox == "")
                {
                    d = " select * from tblSach";
                }
                else if (year.Check_Year(txtbox) == "Năm không hợp lệ")
                {
                    MessageBox.Show("Năm không hợp lệ");
                    d = " select * from tblSach";
                    return(d);
                }
                else
                {
                    d = "select*from tblSach where " + cbbox + " like '%" + txtbox + "%'";
                }
                d = "select*from tblSach where " + cbbox + " like '%" + txtbox + "%'";
            }

            else if (cbbox == "NGAYNHAP")
            {
                CheckDate date = new CheckDate();
                if (txtbox == "")
                {
                    d = " select * from tblSach";
                }
                else if (date.Check_Date(txtbox) == "Ngày không hợp lệ")
                {
                    MessageBox.Show("Ngày không hợp lệ");
                    d = " select * from tblSach";
                    return(d);
                }
                else
                {
                    d = "select*from tblSach where " + cbbox + " like '%" + txtbox + "%'";
                }
            }
            return(d);
        }