//thêm, sửa, xoá xuống csdl
        public static void saveCauThu(CauThuDTO ct, string method)
        {
            SqlParameter[] sqlP = new SqlParameter[12];
            sqlP[0]  = new SqlParameter("@MaCauThu", ct.MaCauThu);
            sqlP[1]  = new SqlParameter("@MaDoi", ct.MaDoi);
            sqlP[2]  = new SqlParameter("@TenCauThu", ct.TenCauThu);
            sqlP[3]  = new SqlParameter("@MaViTri", ct.MaViTri);
            sqlP[4]  = new SqlParameter("@NgaySinh", ct.NgaySinh);
            sqlP[5]  = new SqlParameter("@SoAo", ct.SoAo);
            sqlP[6]  = new SqlParameter("@SoBanThang", ct.SoBanThang);
            sqlP[7]  = new SqlParameter("@SoTheVang", ct.SoTheVang);
            sqlP[8]  = new SqlParameter("@SoTheDo", ct.SoTheDo);
            sqlP[9]  = new SqlParameter("@MaQuocTich", ct.MaQuocTich);
            sqlP[10] = new SqlParameter("@SoLanRaSan", ct.SoLanRaSan);
            sqlP[11] = new SqlParameter("@Anh", ct.Anh);

            if (method == sys.INSERT)
            {
                GenericDAO.execNonQuery("sp_InsertCauThu", sqlP, Conn);
            }
            else if (method == sys.UPDATE)
            {
                GenericDAO.execNonQuery("sp_UpdateCauThu", sqlP, Conn);
            }
        }
        public static void saveCauThu_SoLanRaSan(CauThuDTO ct, string method)
        {
            SqlParameter[] sqlP = new SqlParameter[3];
            sqlP[0] = new SqlParameter("@MaCauThu", ct.MaCauThu);
            sqlP[1] = new SqlParameter("@SoLanRaSan", ct.SoLanRaSan);
            sqlP[2] = new SqlParameter("@SoBanThang", ct.SoBanThang);

            if (method == sys.UPDATE)
            {
                GenericDAO.execNonQuery("sp_UpdateCauThu_SoLanRaSanVaSBT", sqlP, Conn);
            }
        }
Пример #3
0
        public CauThuDTO send_data(string madoibong)
        {
            CauThuDTO ct = new CauThuDTO()
            {
                MaCauThu   = textBox1.Text,
                TenCauThu  = textBox2.Text,
                NgaySinh   = dateTimePicker1.Value,
                TuoiCauThu = 1,
                MaLoaiCT   = "12",
                GhiChu     = textBox3.Text,
                MaDoiBong  = madoibong
            };

            return(ct);
        }
Пример #4
0
        public bool them(CauThuDTO ct)
        {
            string query = string.Empty;

            query += "INSERT INTO [cauthu] ([MaCauThu], [TenCauThu], [NgaySinh], [GhiChu], [TongSoBT],[TuoiCauThu],[MaLoaiCT],[MaDoiBong])";
            query += "VALUES (@MaCauThu,@TenCauThu,@NgaySinh,@GhiChu,@TongSoBT,@TuoiCauThu,@MaLoaiCT,@MaDoiBong)";
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@MaCauThu", ct.MaCauThu);
                    cmd.Parameters.AddWithValue("@TenCauThu", ct.TenCauThu);
                    cmd.Parameters.AddWithValue("@NgaySinh", ct.NgaySinh);
                    cmd.Parameters.AddWithValue("@GhiChu", ct.GhiChu);
                    cmd.Parameters.AddWithValue("@TongSoBT", ct.TongSoBT);
                    cmd.Parameters.AddWithValue("@TuoiCauThu", ct.TuoiCauThu);
                    cmd.Parameters.AddWithValue("@MaLoaiCT", ct.MaLoaiCT);
                    cmd.Parameters.AddWithValue("@MaDoiBong", ct.MaDoiBong);
                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(false);
                    }
                }
            }
            return(true);
        }
Пример #5
0
        private void button9_Click(object sender, EventArgs e)
        {
            ///
            DoiBongDTO dbDTO = new DoiBongDTO();

            dbDTO.MaDoiBong     = textBox3.Text;
            dbDTO.TenDoiBong    = textBox1.Text;
            dbDTO.SoLuongCauThu = int.Parse(textBox4.Text);
            dbDTO.TenSanNha     = textBox2.Text;
            //add data
            bool kt = dbBUS.them(dbDTO);

            if (kt == false)
            {
                MessageBox.Show("loi");
            }
            else
            {
                MessageBox.Show("ok");
            }

            //add cầu thủ
            for (int i = 0; i < ListCauThuSTO.Count; i++)
            {
                CauThuDTO ctDTO = ListCauThuSTO[i];
                bool      kt1   = ctBUS.them(ctDTO);
                if (kt1 == false)
                {
                    MessageBox.Show("loi them ct");
                }
                else
                {
                    MessageBox.Show("ok");
                }
            }
        }
Пример #6
0
        public bool them(CauThuDTO ct)
        {
            bool re = ctDAL.them(ct);

            return(re);
        }
Пример #7
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);
            }
        }
Пример #8
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);
            }
        }