Exemplo n.º 1
0
        private bool CheckEditData()
        {
            AddDuLieuVaoList();

            if (TxtHo.Text.Trim() == "")
            {
                MessageBox.Show("Vui lòng bạn nhập Họ và Tên.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtHo.Clear();
                TxtHo.Focus();
                return(false);
            }
            else
            if (!_kiemtrathem.KiemTraLop(TxtLop.Text.ToString(), _lop, TxtKhoa1.Text.ToString() + "-" + TxtKhoa2.Text.ToString(), _khoa))
            {
                MessageBox.Show("Bạn vừa nhập lớp bị lỗi !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtLop.Clear();
                TxtLop.Focus();
                return(false);
            }
            else
            if (!_kiemtrathem.KiemTraTuoi(date.Value))
            {
                MessageBox.Show("Bạn vừa nhập ngày sinh bị lỗi !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtLop.Clear();
                TxtLop.Focus();
                return(false);
            }
            else
            if (TxtTen.Text.Trim() == "")
            {
                MessageBox.Show("Bạn vừa nhập tên bị lỗi !.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtTen.Clear();
                TxtTen.Focus();
                return(false);
            }
            else
            if (!_kiemtrathem.KiemTraKhoi(TxtKhoi.Text.ToString()))
            {
                MessageBox.Show("Bạn vừa nhập khối bị lỗi !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtKhoi.Clear();
                TxtKhoi.Focus();
                return(false);
            }
            else
            if (!_kiemtrathem.KiemTraKhoa(TxtKhoa1.Text.ToString(), TxtKhoa2.Text.ToString()))
            {
                MessageBox.Show("Bạn vừa nhập khóa bị lỗi !.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtKhoa1.Clear();
                TxtKhoa1.Focus();
                TxtKhoa2.Clear();
                TxtKhoa2.Focus();
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
 //Xoá các ô và đặt trỏ chuột vào ô Họ Tên
 private void button2_Click(object sender, EventArgs e)
 {
     TxtHo.Clear();
     TxtMaHS.Clear();
     TxtLop.Clear();
     TxtTen.Clear();
     TxtKhoi.Clear();
     TxtKhoa1.Clear();
     TxtKhoa2.Clear();
     TxtHo.Focus();
 }
Exemplo n.º 3
0
        //chọn thông qua bàn phím và mặc định
        private void dataSinhVien_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                g_ImagePath  = null;
                TxtHo.Text   = dataSinhVien.CurrentRow.Cells[2].Value.ToString(); //họ
                TxtMaHS.Text = dataSinhVien.CurrentRow.Cells[1].Value.ToString(); //mshs
                TxtLop.Text  = dataSinhVien.CurrentRow.Cells[6].Value.ToString(); //lớp
                TxtTen.Text  = dataSinhVien.CurrentRow.Cells[3].Value.ToString(); // tên
                TxtKhoi.Text = dataSinhVien.CurrentRow.Cells[7].Value.ToString(); //khối

                TxtKhoa1.Clear();
                TxtKhoa2.Clear();
                string ikhoa = dataSinhVien.CurrentRow.Cells[8].Value.ToString().Trim();
                for (int i = 0; i < 4; i++)
                {
                    TxtKhoa1.Text += ikhoa[i];
                    TxtKhoa2.Text += ikhoa[ikhoa.Count() - 4 + i];
                }

                string gt = dataSinhVien.CurrentRow.Cells[4].Value.ToString();
                if (gt == "Nam")
                {
                    radioButton1.Checked = true;
                }
                else
                if (gt == "Nữ")
                {
                    radioButton2.Checked = true;
                }
                else
                {
                    radioButton3.Checked = true;
                }
                date.Value = DateTime.ParseExact(dataSinhVien.CurrentRow.Cells[5].Value.ToString(), "dd/mm/yyyy", System.Globalization.CultureInfo.InvariantCulture);
                bool     IsImageExist = false;
                String[] extension    = { ".jpg", ".png", ".bmp" };
                string   temp         = TxtKhoa1.Text + "-" + TxtKhoa2.Text + "\\" + TxtKhoi.Text + "\\" + TxtLop.Text + "\\" + TxtMaHS.Text;
                for (int i = 0; i < extension.Count(); i++)
                {
                    if (File.Exists(Path.Combine(g_path, temp + extension[i])))
                    {
                        FileStream fs = new FileStream(Path.Combine(g_path, temp + extension[i]), FileMode.Open);
                        pictureBox1.Image = Image.FromStream(fs);
                        fs.Flush();
                        fs.Close();
                        IsImageExist = true;
                        break;
                    }
                }
                if (!IsImageExist)
                {
                    if (gt == "Nam")
                    {
                        pictureBox1.Image = Image.FromFile("Icon//boy.png");
                    }
                    else
                    if (gt == "Nữ")
                    {
                        pictureBox1.Image = Image.FromFile("Icon//girl.png");
                    }
                    else
                    {
                        pictureBox1.Image = Image.FromFile("Icon//nosex.png");
                    }
                }
            }
            catch { }
        }