Esempio n. 1
0
 public void EditDataRowSV(SV s)
 {
     foreach (DataRow item in DTSV.Rows)
     {
         if (item["MSSV"].ToString() == s.MSSV)
         {
             item["NameSV"] = s.NameSV;
             item["Gender"] = s.Gender;
             item["NS"]     = s.NS;
             item["ID_Lop"] = s.ID_LopSH;
             break;
         }
     }
 }
Esempio n. 2
0
 public static void Sort(List <SV> arr, Compare cmp)
 {
     for (int i = 0; i < arr.Count - 1; i++)
     {
         for (int j = i + 1; j < arr.Count; j++)
         {
             if (cmp(arr[i], arr[j]))
             {
                 SV temp = arr[i];
                 arr[i] = arr[j];
                 arr[j] = temp;
             }
         }
     }
 }
Esempio n. 3
0
        public void ExecuteDB(SV s)
        {
            bool check = false;

            foreach (SV item in GetAllSV())
            {
                if (item.MSSV == s.MSSV)
                {
                    check = true;
                    break;
                }
            }
            if (check)
            {
                CSDL.Instance.EditDataRowSV(s);
            }
            else
            {
                CSDL.Instance.AddDataRowSV(s);
            }
        }
Esempio n. 4
0
 private void btOK_Click(object sender, EventArgs e)
 {
     if (!CheckData())
     {
         MessageBox.Show("Mời nhập đủ thông tin!!");
     }
     else
     {
         SV s = new SV
         {
             MSSV     = txbMSSV.Text.Trim(),
             NameSV   = txbName.Text.Trim(),
             Gender   = (rbtMale.Checked) ? true : false,
             NS       = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day),
             ID_LopSH = ((CBBIteam)cbLopSH.SelectedItem).Value
         };
         if (chucNang == "add")
         {
             if (CSDL_OOP.Instance.GetSVByMSSV(s.MSSV) == null)
             {
                 CSDL_OOP.Instance.ExecuteDB(s);
                 d(0, "", txbMSSV.Text);
                 XoaRong();
             }
             else
             {
                 MessageBox.Show("MSSV này đã tồn tại!!");
             }
         }
         //Đang dùng chức năng Edit
         else
         {
             CSDL_OOP.Instance.ExecuteDB(s);
             d(0, "", this.MSSV);
         }
     }
 }
Esempio n. 5
0
        public static bool Compare_Name_tang(SV s1, SV s2)
        {
            string HoTenSV1 = " " + s1.NameSV;
            string HoTenSV2 = " " + s2.NameSV;

            //Chuyển Tên lên trước, rồi dùng hàm để so sánh
            string str1 = "";
            string str2 = "";
            int    x    = HoTenSV1.LastIndexOf(" "); //vị trí bắt đầu tên của SV1
            int    y    = HoTenSV2.LastIndexOf(" ");

            str1  = HoTenSV1.Substring(x, HoTenSV1.Length - x);
            str2  = HoTenSV2.Substring(y, HoTenSV2.Length - y);
            str1 += HoTenSV1.Substring(0, x);
            str2 += HoTenSV2.Substring(0, y);
            if (string.Compare(str1, str2) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 6
0
 public static bool Compare_NS_giam(SV s1, SV s2)
 {
     return(!Compare_NS_tang(s1, s2));
 }