Exemplo n.º 1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtMaTran.Text == "")
            {
                MessageBox.Show("bạn chưa nhập mã trận đấu ");
                txtMaTran.Focus();
                return;
            }
            if (txtLuotDau.Text == "")
            {
                MessageBox.Show("bạn chưa nhập lượt đấu");
                txtLuotDau.Focus();
                return;
            }
            if (txtVongDau.Text == "")
            {
                MessageBox.Show("bạn chưa nhập vòng đấu");
                txtVongDau.Focus();
                return;
            }
            if (cmbMaDoiNha.Text == "")
            {
                MessageBox.Show("bạn chưa chọn mã đội nhà");
                cmbMaDoiNha.Focus();
                return;
            }
            if (cmbMaDoiKhach.Text == "")
            {
                MessageBox.Show("bạn chưa chọn mã đội khách");
                cmbMaDoiKhach.Focus();
                return;
            }
            string sqlCheckKey = "Select * from trandau Where matrandau = '"
                                 + txtMaTran.Text.Trim() + "'";

            DAO.OpenConnection();

            if (DAO.checkKeyExit(sqlCheckKey))
            {
                MessageBox.Show("Mã trận đấu đã tồn tại");
                DAO.CloseConnetion();
                txtMaTran.Focus();
                return;
            }
            else
            {
                string sql = "insert into trandau (matrandau,luotdau,vongdau,madoinha," +
                             "madoikhach,sobanthangdoinha,sobanthuadoinha," +
                             "sothevangdoinha,sothedodoinha,sothevangdoikhach,sothedodoikhach,ghichu)" +
                             " values ('" + txtMaTran.Text.Trim() + "',N'" + txtLuotDau.Text.Trim() + "',N'"
                             + txtVongDau.Text.Trim() + "','" + cmbMaDoiNha.SelectedValue.ToString() + "','"
                             + cmbMaDoiKhach.SelectedValue.ToString() + "',null,null,null,null,null,null,'"
                             + txtGhiChu.Text.Trim() + "')";

                DAO.LoadDataTable(sql);
                LoadDataToGrivew();
            }
        }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtMatran.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập mã trận đấu");
                txtMatran.Focus();
                return;
            }
            if (txtMacauthu.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập mã cầu thủ");
                txtMacauthu.Focus();
                return;
            }
            if (cmbMadoi.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập mã đội");
                cmbMadoi.Focus();
                return;
            }
            if (txtVitri.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập vị trí");
                txtVitri.Focus();
                return;
            }

            string sqlCheckKey = "select * from trandau_cauthu where matrandau='" +
                                 txtMatran.Text.Trim() + "'";

            DAO.OpenConnection();
            if (DAO.checkKeyExit(sqlCheckKey))
            {
                MessageBox.Show("Mã trận đấu đã tồn tại");
                DAO.CloseConnetion();
                txtMatran.Focus();
                return;
            }
            string sql = "insert into trandau_cauthu values ('" +
                         txtMatran.Text.Trim() + "','" +
                         cmbMadoi.SelectedValue.ToString() + "', '" +
                         txtMacauthu.Text.Trim() + "',N'" +
                         txtVitri.Text.Trim() + "')";

            DAO.RunSqlDel(sql);   //Thực hiện câu lệnh sql
            LoadDataToGridView(); //Nạp lại DataGridView
        }
Exemplo n.º 3
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            DAO.OpenConnection();
            string sql;

            if (cmbMaDoi.Text.Length == 0)
            {
                MessageBox.Show("Ban chua nhap ma doi");
                cmbMaDoi.Focus();
                return;
            }
            if (txtMaSan.Text == "")
            {
                MessageBox.Show("Ban chua nhap ma san");
                txtMaSan.Focus();
                return;
            }

            if (txtTenDoi.Text == "")
            {
                MessageBox.Show("Ban chua nhap ten doi");
                txtTenDoi.Focus();
                return;
            }

            if (txtHLV.Text == "")
            {
                MessageBox.Show("Ban chua nhap ten HLV");
                txtHLV.Focus();
                return;
            }

            if (txtMaTinh.Text == "")
            {
                MessageBox.Show("Ban chua nhap ma tinh");
                txtMaTinh.Focus();
                return;
            }

            /*if (txtLogo.Text.Trim().Length == 0)
             * {
             *  MessageBox.Show("Ban chua nhap Logo");
             *  txtLogo.Focus();
             *  return;
             * }*/
            /*if (txtLogo.Text == "")
             * {
             *  MessageBox.Show("Bạn cần nhập logo!");
             *  txtLogo.Focus();
             *  return;
             * }*/

            sql = "Select madoi from doibong where madoi = '"
                  + cmbMaDoi.Text + " ' ";


            if (DAO.checkKeyExit(sql))
            {
                MessageBox.Show("Ma doi da ton tai");

                cmbMaDoi.Focus();
                cmbMaDoi.Text = "";
                return;
            }
            else
            {
                sql = "insert into doibong (madoi,tendoi,masan,HLV,matinh,diem,sobanthang,sobanthua,soluongcauthu) " +
                      "values (' " +
                      cmbMaDoi.Text + "', N'" +
                      txtTenDoi.Text.Trim() + "', N'" +
                      txtMaSan.Text.Trim() + "' , N'" +
                      txtHLV.Text.Trim() + "', N'" +
                      txtMaTinh.Text.Trim() + "',null,null,null,null)";
                /*txtLogo.Text + "', N'" + ")"*/
                MessageBox.Show(sql);

                DAO.LoadDataToTable(sql);
                DAO.CloseConnetion();
                LoadDataToGriview();
            }
        }
Exemplo n.º 4
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            DAO.OpenConnection();
            string sql;

            if (txtMaCT.Text == "")
            {
                MessageBox.Show("bạn chưa nhập mã cầu thủ");
                txtMaCT.Focus();
                return;
            }
            if (cmbMaDoi.Text == "")
            {
                MessageBox.Show("bạn chưa chọn mã đội");
                cmbMaDoi.Focus();
                return;
            }
            if (txtTenCT.Text == "")
            {
                MessageBox.Show("bạn chưa nhập tên cầu thủ");
                txtTenCT.Focus();
                return;
            }
            if (txtViTri.Text == "")
            {
                MessageBox.Show("bạn chưa nhập vị trí của cầu thủ");
                txtViTri.Focus();
                return;
            }
            if (txtNgaySinh.Text == "")
            {
                MessageBox.Show("bạn chưa nhập ngày sinh");
                txtNgaySinh.Focus();
                return;
            }
            if (txtSoAo.Text == "")
            {
                MessageBox.Show("bạn chưa nhập số áo");
                txtSoAo.Focus();
                return;
            }
            if (txtMaQuocTich.Text == "")
            {
                MessageBox.Show("bạn chưa nhập mã quốc tịch");
                txtMaQuocTich.Focus();
                return;
            }

            /*if (txtAnh.Text == "")
             * {
             *  MessageBox.Show("bạn chưa chọn ảnh minh họa");
             *  txtAnh.Focus();
             *  return;
             * }*/
            sql = "select * from cauthu where macauthu = '" + txtMaCT.Text.Trim() + "'";

            if (DAO.checkKeyExit(sql))
            {
                MessageBox.Show("mã cầu thủ đã tồn tại");

                txtMaCT.Focus();
                return;
            }
            else
            {
                sql = " insert into cauthu (macauthu,madoi,tencauthu,vitri,ngaysinh,soao,sobanthang,sothevang,sothedo,maquoctich,solanrasan) " +
                      " values('"
                      + txtMaCT.Text.Trim() + "',N'"
                      + cmbMaDoi.SelectedValue + "',N'"
                      + txtTenCT.Text.Trim() + "',N'"
                      + txtViTri.Text.Trim() + "',N'"
                      + txtNgaySinh.Text.Trim() + "',N'"
                      + txtSoAo.Text.Trim() + "',null,null,null,'"
                      + txtMaQuocTich.Text.Trim() + "',null)";

                MessageBox.Show(sql);

                DAO.LoadDataToTable(sql);
                DAO.CloseConnetion();
                LoadDataToGrivew();
            }
        }