Example #1
0
        //Chọn mã đội khách
        private void cbxMaDoiKhach_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbxMaDoiKhach.SelectedIndex == -1)
            {
                DataTable dt = CauThuDAO.getData();
                dgvDoiKhach.DataSource = dt;
            }
            else if (cbxMaDoiNha.Text == cbxMaDoiKhach.Text)
            {
                MessageBox.Show("Mã đội khách không được trùng với mã đội nhà!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cbxMaDoiKhach.SelectedIndex = -1;
                imgDoiKhach.Image           = null;
                return;
            }
            else
            {
                DataTable dt = DoiBongDAO.getData();
                AddMultipleColumn(dt, "NameAndCode", "MaDoi", "TenDoi");
                KeyToValueOfTextWithPic(dt, cbxMaDoiKhach, "NameAndCode", "Logo", imgDoiKhach);

                string mdb = cbxMaDoiKhach.SelectedValue.ToString();
                dtDoiKhach             = CauThuDAO.getDatabyID(mdb); //hiển thị danh sách theo cầu thủ tương ứng
                dgvDoiKhach.DataSource = CauThuDAO.getDatabyID(mdb);
            }
        }
Example #2
0
        //Chọn mã đội nhà
        private void cbxMaDoiNha_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbxMaDoiNha.SelectedIndex == -1) //hiển thị tất cả
            {
                DataTable dt = CauThuDAO.getData();
                dgvDoiNha.DataSource = dt;
            }
            else if (cbxMaDoiNha.Text == cbxMaDoiKhach.Text)
            {
                MessageBox.Show("Mã đội nhà không được trùng với mã đội khách!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cbxMaDoiNha.SelectedIndex = -1;
                imgDoiNha.Image           = null;
                return;
            }
            else
            {
                DataTable dt = DoiBongDAO.getData();

                AddMultipleColumn(dt, "NameAndCode", "MaDoi", "TenDoi");
                KeyToValueOfTextWithPic(dt, cbxMaDoiNha, "NameAndCode", "Logo", imgDoiNha);

                string    mdb            = cbxMaDoiNha.SelectedValue.ToString();
                DataTable cauThuThuocDoi = CauThuDAO.getDatabyID(mdb);
                dtDoiNha = cauThuThuocDoi;
                foreach (DataRow item in cauThuThuocDoi.Rows)
                {
                    item["SoLanRaSan"] = (int.Parse(item["SoLanRaSan"].ToString()) + 1).ToString();
                }

                dgvDoiNha.DataSource = cauThuThuocDoi;
            }
        }
        private void btnFind_Click(object sender, EventArgs e)
        {
            DataTable tk     = CauThuDAO.getDataForSearch();
            DataView  dv     = tk.DefaultView;
            string    filter = "";
            int       check  = 0;

            string tenCT = txtTen.Text;

            if (!string.IsNullOrEmpty(tenCT))
            {
                filter = filter + "TenCauThu like '%" + tenCT + "%' and";
                check  = 1;
            }

            if (cbxDoiBong.SelectedIndex != -1)
            {
                string madb = cbxDoiBong.SelectedValue.ToString();
                if (!string.IsNullOrEmpty(madb))
                {
                    filter = filter + " TenDoi like '%" + madb + "%' and";
                    check  = 1;
                }
            }

            int sbt;

            if (int.TryParse(txtSoBanThang.Text, out sbt) == true)
            {
                if (!string.IsNullOrEmpty(sbt.ToString()))
                {
                    filter = filter + " SoBanThang = '" + sbt + "' and";
                    check  = 1;
                }
            }
            else if (int.TryParse(txtSoBanThang.Text, out sbt) == false && txtSoBanThang.Text != "")
            {
                MessageBox.Show("Số bàn thắng không hợp lệ!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                reset();
                txtSoBanThang.Focus();
            }

            if (filter.Length > 0 && check == 1)
            {
                string final = filter.Remove(filter.Length - 3, 3);
                dv.RowFilter = final;
            }

            DataTable s = dv.ToTable();

            dgvTimKiemCauThu.DataSource = s;
            if (dgvTimKiemCauThu.Rows.Count < 2)
            {
                MessageBox.Show("Không có kết quả!");
                reset();
                return;
            }
        }
        private void UC_TimKiemCauThu_Load(object sender, EventArgs e)
        {
            DataTable dt = CauThuDAO.getDataForSearch();

            tb = dt;
            dgvTimKiemCauThu.DataSource = dt;

            DataTable doi = DoiBongDAO.getData();

            FillCbo(doi, cbxDoiBong, "TenDoi");
        }
Example #5
0
 //Hiển thị combobox
 private void cbxDoiBong_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbxDoiBong.SelectedIndex == -1) //hiển thị tất cả danh sách
     {
         DataTable dt = CauThuDAO.getData();
         dgvCauThu.DataSource = dt;
     }
     else
     {
         string mdb = cbxDoiBong.SelectedValue.ToString();  //mã đội bóng được chọn
         dgvCauThu.DataSource = CauThuDAO.getDatabyID(mdb); //Gọi proc dưới sql
     }
 }
Example #6
0
 //Xoá cầu thủ
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (rowid >= 0 && rowid < dgvCauThu.Rows.Count - 1)
     {
         DialogResult h = MessageBox.Show("Bạn có muốn xoá không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (h == DialogResult.Yes)
         {
             string id = dgvCauThu.Rows[rowid].Cells[0].Value.ToString();
             CauThuDAO.DeleteCT(id);
             MessageBox.Show("Xoá thành công!");
             UC_CauThu_Load(sender, e);
             reset();
         }
     }
     else
     {
         MessageBox.Show("Bạn phải chọn cầu thủ để xoá.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #7
0
        private void UC_CauThu_Load(object sender, EventArgs e)
        {
            DataTable dt = CauThuDAO.getData(); //Lấy dữ liệu từ database

            dgvCauThu.DataSource = dt;          //Cho vào datagridview


            DataTable doi = DoiBongDAO.getData();        //Lấy dữ liệu từ database DoiBong

            FillCbo(doi, cbxDoiBong, "MaDoi", "TenDoi"); //Cho vào combobox


            DataTable vitri = ViTriDAO.getData();

            FillCbo(vitri, cbxViTri, "MaViTri", "TenViTri");

            DataTable quoctich = QuocTichDAO.getData();

            FillCbo(quoctich, cbxQuocTich, "MaQuocTich", "TenQuocTich");
            //txtImageSource.Text = @"E:\IT\C#\LapTrinhTrucQuan\Nhom06\Doc\unnamed.jpg";
        }
Example #8
0
        //Thêm cầu thủ
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int soao;

            try
            {
                if (txtMaCT.Text == "")
                {
                    MessageBox.Show("Bạn chưa tạo mã cầu thủ!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtMaCT.Focus();
                }
                else if (txtTenCT.Text == "")
                {
                    MessageBox.Show("Bạn chưa nhập tên cầu thủ!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtTenCT.Focus();
                }
                else if (cbxDoiBong.SelectedIndex == -1)
                {
                    MessageBox.Show("Bạn chưa chọn đội bóng!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (cbxViTri.SelectedIndex == -1)
                {
                    MessageBox.Show("Bạn chưa chọn vị trí!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (txtSoAo.Text == "")
                {
                    MessageBox.Show("Bạn chưa nhập số áo!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtSoAo.Focus();
                }
                else if (int.TryParse(txtSoAo.Text, out soao) == false)
                {
                    MessageBox.Show("Số áo không hợp lệ!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtSoAo.Text = "";
                    txtSoAo.Focus();
                }
                else if (cbxQuocTich.SelectedIndex == -1)
                {
                    MessageBox.Show("Bạn chưa chọn quốc tịch!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (txtImageSource.Text == "")
                {
                    MessageBox.Show("Bạn chưa chọn ảnh!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    if (soao <= 0 || soao > 99)
                    {
                        MessageBox.Show("Số áo không hợp lệ!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtSoAo.Text = "";
                        txtSoAo.Focus();
                        return;
                    }

                    string   maCT       = txtMaCT.Text;
                    string   maDoi      = cbxDoiBong.SelectedValue.ToString();
                    string   tenCT      = txtTenCT.Text;
                    string   viTri      = cbxViTri.SelectedValue.ToString();
                    DateTime ngaySinh   = dtpNgaySinh.Value;
                    string   soAo       = txtSoAo.Text;
                    string   soBanThang = txtSoBanThang.Text;
                    string   soTheVang  = txtSoTheVang.Text;
                    string   soTheDo    = txtSoTheDo.Text;
                    string   maQuocTich = cbxQuocTich.SelectedValue.ToString();
                    string   soLanRaSan = txtSoLanRaSan.Text;

                    soBanThang = soTheVang = soTheDo = soLanRaSan = "0";

                    //Khởi tạo 1 cầu thủ
                    CauThuDTO dto = new CauThuDTO(maCT,
                                                  maDoi,
                                                  tenCT,
                                                  viTri,
                                                  ngaySinh,
                                                  int.Parse(soAo),
                                                  int.Parse(soBanThang),
                                                  int.Parse(soTheVang),
                                                  int.Parse(soTheDo),
                                                  maQuocTich,
                                                  int.Parse(soLanRaSan),
                                                  convertImageToBytes());

                    //Insert xuống database
                    CauThuDAO.saveCauThu(dto, sys.INSERT);
                    MessageBox.Show("Thêm cầu thủ thành công.");

                    UC_CauThu_Load(sender, e);
                    reset();
                }
            }
            catch
            {
                MessageBox.Show("Lỗi dữ liệu!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #9
0
        //Sửa cầu thủ
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (rowid >= 0 && rowid < dgvCauThu.Rows.Count - 1) //Nếu đã chọn cầu thủ để sửa
            {
                try
                {
                    if (txtMaCT.Text == "")
                    {
                        MessageBox.Show("Bạn chưa tạo mã cầu thủ!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtMaCT.Focus();
                    }
                    else if (txtTenCT.Text == "")
                    {
                        MessageBox.Show("Bạn chưa nhập tên cầu thủ!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtTenCT.Focus();
                    }
                    else if (cbxDoiBong.SelectedIndex == -1)
                    {
                        MessageBox.Show("Bạn chưa chọn đội bóng!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (cbxViTri.SelectedIndex == -1)
                    {
                        MessageBox.Show("Bạn chưa chọn vị trí!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (txtSoAo.Text == "")
                    {
                        MessageBox.Show("Bạn chưa nhập số áo!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtSoAo.Focus();
                    }
                    else if (cbxQuocTich.SelectedIndex == -1)
                    {
                        MessageBox.Show("Bạn chưa chọn quốc tịch!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (txtImageSource.Text == "")
                    {
                        MessageBox.Show("Bạn chưa chọn ảnh!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        string   maCT       = txtMaCT.Text;
                        string   maDoi      = cbxDoiBong.SelectedValue.ToString();
                        string   tenCT      = txtTenCT.Text;
                        string   viTri      = cbxViTri.SelectedValue.ToString();
                        DateTime ngaySinh   = dtpNgaySinh.Value;
                        string   soAo       = txtSoAo.Text;
                        string   soBanThang = txtSoBanThang.Text;
                        string   soTheVang  = txtSoTheVang.Text;
                        string   soTheDo    = txtSoTheDo.Text;
                        string   maQuocTich = cbxQuocTich.SelectedValue.ToString();
                        string   soLanRaSan = txtSoLanRaSan.Text;

                        soBanThang = soTheVang = soTheDo = soLanRaSan = "0";
                        try
                        {
                            currentImg = convertImageToBytes();
                        }
                        catch
                        {
                            MessageBox.Show("Lỗi dữ liệu!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        CauThuDTO dto = new CauThuDTO(maCT,
                                                      maDoi,
                                                      tenCT,
                                                      viTri,
                                                      ngaySinh,
                                                      int.Parse(soAo),
                                                      int.Parse(soBanThang),
                                                      int.Parse(soTheVang),
                                                      int.Parse(soTheDo),
                                                      maQuocTich,
                                                      int.Parse(soLanRaSan),
                                                      currentImg);

                        CauThuDAO.saveCauThu(dto, sys.UPDATE);
                        MessageBox.Show("Sửa cầu thủ thành công!");

                        UC_CauThu_Load(sender, e);
                        reset();
                    }
                }
                catch
                {
                    MessageBox.Show("Lỗi dữ liệu!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Bạn phải chọn cầu thủ để sửa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }