Esempio n. 1
0
        //Click event
        //Chuyển lớp
        private void btnChuyen_Click(object sender, EventArgs e)
        {
            IEnumerator ie = lVLopCu.SelectedItems.GetEnumerator();

            while (ie.MoveNext())
            {
                ListViewItem olditem = (ListViewItem)ie.Current;
                HSChuyen = ie.Current.ToString().Split('{')[1].Split('}')[0];
                ListViewItem newitem = new ListViewItem();

                //Trạng thái học sinh đã được chuyển lớp hay chưa?
                bool state = false;

                foreach (ListViewItem item in lVLopMoi.Items)
                {
                    if (item.SubItems[0].Text == olditem.SubItems[0].Text)
                    {
                        MessageBoxEx.Show("Học sinh " + item.SubItems[1].Text + " hiện đang học trong lớp " + cmbLopMoi.Text, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        state = true;
                        goto Cont;
                    }
                }

                DataTable dT = new DataTable();
                if (cmbNamHocMoi.SelectedValue != null)
                {
                    dT = m_HocSinhCtrl.HienThiDsHocSinhTheoNamHoc(cmbNamHocMoi.SelectedValue.ToString());
                }

                //foreach (DataRow row in dT.Rows)
                //{
                //    //if (olditem.SubItems[0].Text.ToString() == row["MaHocSinh"].ToString())
                //    if (olditem.Text.ToString().Equals(row["MaHocSinh"].ToString()))
                //    {
                //        MessageBoxEx.Show("Học sinh " + row["HoTen"].ToString() + " hiện đang học trong lớp " + row["TenLop"].ToString(), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //        state = true;
                //        goto Cont;
                //    }
                //}

                newitem.SubItems.Add(olditem.SubItems[1].Text);
                newitem.Tag = olditem.Tag;

                lVLopMoi.Items.Add(newitem);
                lVLopMoi.Items[lVLopMoi.Items.IndexOf(newitem)].Text = olditem.SubItems[0].Text;
                lVLopCu.Items.Remove(olditem);

Cont:
                if (state == true)
                {
                    break;
                }
            }
        }