Пример #1
0
 private void button_ok_Click(object sender, EventArgs e)
 {
     if (them)
     {
         if (int.Parse(queries.CountSoCauThuCuaDoi(mamua, madoi).ToString()) >= sct_toida)
         {
             MessageBox.Show("Không thể thêm cầu thủ, Số Cầu thủ của đội đã đủ");
             return;
         }
         ngaysinh = Convert.ToDateTime(birthday.Value.ToString("MM-dd-yyyy"));
         if (!(TinhTuoi(ngaysinh) >= tuoitoithieu && TinhTuoi(ngaysinh) <= tuoitoida))
         {
             MessageBox.Show("Tuổi không đúng quy định, " + tuoitoithieu + "< tuoi <" + tuoitoida);
             return;
         }
         hoten = playerNameTextBox.Text.Trim();
         if (hoten == "")
         {
             MessageBox.Show("Nhập tên cầu thủ");
             return;
         }
         quoctich = nationalityTexBox.Text.Trim();
         if (quoctich == "")
         {
             MessageBox.Show("Nhập quốc tịch cầu thủ");
             return;
         }
         macauthu = SinhMaTuDong();
         ghichu   = noteTextBox.Text.Trim();
         this.cauthuTableAdapter1.Insert(macauthu, hoten, ngaysinh, quoctich, ghichu, maloaicauthu, null);
         clubComboBox.DisplayMember = "MaDoi";
         madoi = clubComboBox.Text.Trim();
         clubComboBox.DisplayMember   = "TenDoi";
         seasonComboBox.DisplayMember = "MaMua";
         mamua = seasonComboBox.Text.Trim();
         seasonComboBox.DisplayMember = "TenMua";
         this.cauthU_MUAGIAITableAdapter1.Insert(mamua, macauthu, madoi, 0);
         MessageBox.Show("Thêm thành công!", "Success !^^", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else if (sua)
     {
         Databinding();
         clubComboBox.DisplayMember = "MaDoi";
         madoi = clubComboBox.Text.Trim();
         clubComboBox.DisplayMember   = "TenDoi";
         seasonComboBox.DisplayMember = "MaMua";
         mamua = seasonComboBox.Text.Trim();
         seasonComboBox.DisplayMember = "TenMua";
         macauthu     = txt_macauthu.Text.Trim();
         hoten        = playerNameTextBox.Text.Trim();
         maloaicauthu = playerType.Text.Trim();
         if (hoten == "")
         {
             MessageBox.Show("Nhập tên cầu thủ");
             return;
         }
         quoctich = nationalityTexBox.Text.Trim();
         if (quoctich == "")
         {
             MessageBox.Show("Nhập tên cầu thủ");
             return;
         }
         ngaysinh = Convert.ToDateTime(birthday.Value.ToString("MM-dd-yyyy"));
         if (!(TinhTuoi(ngaysinh) >= tuoitoithieu && TinhTuoi(ngaysinh) <= tuoitoida))
         {
             MessageBox.Show("Tuổi không đúng quy định, " + tuoitoithieu + "< tuoi <" + tuoitoida);
             return;
         }
         quoctich = nationalityTexBox.Text.Trim();
         ghichu   = noteTextBox.Text.Trim();
         this.cauthuTableAdapter1.UpdateByMaCauThu(hoten, ngaysinh.ToString(), quoctich, ghichu, maloaicauthu, null, macauthu, macauthu);
         MessageBox.Show("Sửa thành công!", "Success !^^", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else if (xoa)
     {
         Databinding();
         if (MessageBox.Show("Bạn có muốn xoá", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
         {
             clubComboBox.DisplayMember = "MaDoi";
             madoi = clubComboBox.Text.Trim();
             clubComboBox.DisplayMember   = "TenDoi";
             seasonComboBox.DisplayMember = "MaMua";
             mamua = seasonComboBox.Text.Trim();
             seasonComboBox.DisplayMember = "TenMua";
             macauthu = txt_macauthu.Text.Trim();
             this.cauthU_MUAGIAITableAdapter1.DeleteBy_MaMua_MaDoi_MaCt(mamua, macauthu, madoi);
             this.cauthuTableAdapter1.DeleteByMaCauThu(macauthu);
         }
     }
     Cleartext();
     LoadDataGV();
     FilltextLoaiCauThu();
     LoadStatus(null);
 }
Пример #2
0
        private void button_ok_Click(object sender, System.EventArgs e)
        {
            if (them)
            {
                if (int.Parse(queries.CountSoCauThuCuaDoi(mamua, madoi).ToString()) >= sct_toida)
                {
                    MessageBox.Show("Không thể thêm cầu thủ, Số Cầu thủ của đội đã đủ");
                    return;
                }
                ngaysinh = Convert.ToDateTime(date_ngaysinh.Value.ToString("MM-dd-yyyy"));


                if (!(TinhTuoi(ngaysinh) >= tuoitoithieu && TinhTuoi(ngaysinh) <= tuoitoida))
                {
                    MessageBox.Show("Tuổi không đúng quy định, " + tuoitoithieu + "< tuoi <" + tuoitoida);
                    return;
                }

                hoten = txt_hoten.Text.Trim();

                if (hoten == "")
                {
                    MessageBox.Show("Nhập tên cầu thủ");
                    return;
                }
                quoctich = txt_quoctich.Text.Trim();

                if (quoctich == "")
                {
                    MessageBox.Show("Nhập quốc tịch cầu thủ");
                    return;
                }
                macauthu = SinhMaTuDong();
                ghichu   = txt_ghichu.Text.Trim();
                this.cAUTHUTableAdapter.Insert(macauthu, hoten, ngaysinh, maloaicauthu, quoctich, ghichu);
                this.dOIBONG_CAUTHUTableAdapter.Insert(mamua, madoi, macauthu, 0);
                MessageBox.Show("Thêm thành công!", "Success !^^", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (sua)
            {
                macauthu = txt_macauthu.Text.Trim();
                hoten    = txt_hoten.Text.Trim();

                if (hoten == "")
                {
                    MessageBox.Show("Nhập tên cầu thủ");
                    return;
                }
                quoctich = txt_quoctich.Text.Trim();

                if (quoctich == "")
                {
                    MessageBox.Show("Nhập tên cầu thủ");
                    return;
                }
                ngaysinh = Convert.ToDateTime(date_ngaysinh.Value.ToString("MM-dd-yyyy"));

                if (!(TinhTuoi(ngaysinh) >= tuoitoithieu && TinhTuoi(ngaysinh) <= tuoitoida))
                {
                    MessageBox.Show("Tuổi không đúng quy định, " + tuoitoithieu + "< tuoi <" + tuoitoida);
                    return;
                }
                quoctich = txt_quoctich.Text.Trim();
                ghichu   = txt_ghichu.Text.Trim();

                this.cAUTHUTableAdapter.UpdateByMaCauThu(hoten, ngaysinh, maloaicauthu, quoctich, ghichu, macauthu);
                MessageBox.Show("Sửa thành công!", "Success !^^", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (xoa)
            {
                if (MessageBox.Show("Bạn có muốn xoá", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    macauthu = txt_macauthu.Text.Trim();
                    this.dOIBONG_CAUTHUTableAdapter.DeleteBy_MaMua_MaDoi_MaCt(mamua, madoi, macauthu);
                    this.cAUTHUTableAdapter.DeleteByMaCauThu(macauthu);
                }
            }
            Cleartext();
            LoadDataGV();
            FilltextLoaiCauThu();
        }