Beispiel #1
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            string sql, dt;

            if (txtManha.Text == "")
            {
                MessageBox.Show("Bạn phải nhập mã nhà", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtManha.Focus();
                return;
            }
            if (txtTenchunha.Text.Trim() == "")
            {
                MessageBox.Show("Bạn phải nhập tên chủ nhà", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenchunha.Focus();
                return;
            }
            if (txtDienthoai.Text == "")
            {
                MessageBox.Show("Bạn phải nhập số điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDienthoai.Focus();
                return;
            }
            if (cmbLoainha.Text == "")
            {
                MessageBox.Show("Bạn phải chọn loại nhà", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cmbLoainha.Focus();
                return;
            }
            if (cmbDoituongsudung.Text == "")
            {
                MessageBox.Show("Bạn phải chọn đối tượng sử dụng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cmbDoituongsudung.Focus();
                return;
            }
            if (txtDiachi.Text == "")
            {
                MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDiachi.Focus();
                return;
            }
            if (txtDongiathue.Text == "")
            {
                MessageBox.Show("Bạn phải nhập đơn giá thuê", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDongiathue.Focus();
                return;
            }
            if (txtTinhtrang.Text == "")
            {
                MessageBox.Show("Bạn phải nhập tình trạng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTinhtrang.Focus();
                return;
            }
            if (chkDathue.Checked == true)
            {
                dt = "Chưa cho thuê";
            }
            else
            {
                dt = "Đã cho thuê";
            }
            if (txtGhichu.Text == "")
            {
                MessageBox.Show("Bạn phải nhập ghi chú", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtGhichu.Focus();
                return;
            }
            sql = "UPDATE tblDanhMucNha SET  Tenchunha=N'" + txtTenchunha.Text.Trim().ToString() +
                  "',Dienthoai ='" + txtDienthoai.Text.Trim() + "',Maloai='" + cmbLoainha.SelectedValue.ToString() + "',MaDTSD='"
                  + cmbDoituongsudung.SelectedValue.ToString() + "',Diachi=N'" + txtDiachi.Text.Trim() + "',Dongiathue='"
                  + txtDongiathue.Text.Trim() + "',Tinhtrang=N'" + txtTinhtrang.Text.Trim() + "',Dathue=N'" +
                  dt + "',Ghichu='" + txtGhichu.Text.Trim() + "' WHERE Manha='" + txtManha.Text.Trim() + "'";
            DAO.OpenConnection();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = sql;
            cmd.Connection  = DAO.con;
            cmd.ExecuteNonQuery();
            loadDataGridView();
            DAO.CloseConnection();
        }
Beispiel #2
0
 private void frmHinhthucthanhtoan_Load(object sender, EventArgs e)
 {
     DAO.OpenConnection();
     loadDataGridView();
     DAO.CloseConnection();
 }
Beispiel #3
0
 private void frmLoaiNha_Load(object sender, EventArgs e)
 {
     DAO.OpenConnection();
     loadDataGridView();
     DAO.CloseConnection();
 }
Beispiel #4
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string dt;

/*            if (txtManha.Text == "")
 *          {
 *              MessageBox.Show("Bạn không được để trống mã nhà");
 *              txtManha.Focus();
 *              return;
 *          }*/
            if (txtTenchunha.Text == "")
            {
                MessageBox.Show("Bạn không được để trống tên chủ nhà", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenchunha.Focus();
                return;
            }
            if (txtDienthoai.Text == "")
            {
                MessageBox.Show("Bạn không được để trống số điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDienthoai.Focus();
                return;
            }
            if (cmbLoainha.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn loại nhà ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cmbDoituongsudung.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn đối tượng sử dụng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtDiachi.Text == "")
            {
                MessageBox.Show("Bạn không được để trống địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDiachi.Focus();
                return;
            }
            if (txtDongiathue.Text == "")
            {
                MessageBox.Show("Bạn không được để trống đơn giá thuê", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDongiathue.Focus();
                return;
            }
            if (txtTinhtrang.Text == "")
            {
                MessageBox.Show("Bạn không được để trống tình trạng phòng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTinhtrang.Focus();
                return;
            }
            if (chkDathue.Checked == true)
            {
                dt = "Chưa cho thuê";
            }
            else
            {
                dt = "Đã cho thuê";
            }
            if (txtGhichu.Text == "")
            {
                MessageBox.Show("Bạn không được để trống ghi chú", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtGhichu.Focus();
                return;
            }


            string sql = "select * from tblDanhMucNha where Manha = '" +
                         txtManha.Text.Trim() + "'";
            string sq = "select * from tblDanhMucNha where Dienthoai = '" +
                        txtManha.Text.Trim() + "'";

            DAO.OpenConnection();
            if (DAO.CheckKeyExit(sql))
            {
                MessageBox.Show("Mã nhà đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtManha.Focus();
                DAO.CloseConnection();
                return;
            }
            if (DAO.CheckKeyExit(sq))
            {
                MessageBox.Show("Số điện thoại đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtManha.Focus();
                DAO.CloseConnection();
                return;
            }
            else
            {
                sql = "insert into  tblDanhMucNha (Manha, Tenchunha, Dienthoai,Maloai, " +
                      "MaDTSD, Diachi, Dongiathue, Tinhtrang,Dathue,Ghichu)" +
                      " values (N'" + txtManha.Text.Trim() + "',N'"
                      + txtTenchunha.Text.Trim() + "', '" + txtDienthoai.Text.Trim() + "','" +
                      cmbLoainha.SelectedValue.ToString() + "','" + cmbDoituongsudung.SelectedValue.ToString()
                      + "',N'" + txtDiachi.Text.Trim() + "','" + txtDongiathue.Text.Trim() + "',N'" + txtTinhtrang.Text.Trim()
                      + "',N'" + dt + "',N'" + txtGhichu.Text.Trim() + "')";
                SqlCommand cmd = new SqlCommand(sql, DAO.con);
                cmd.ExecuteNonQuery();
                loadDataGridView();
                fillDataToComboLoainha();
                fillDataToComboDoituongsudung();
                DAO.CloseConnection();
            }
        }
Beispiel #5
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            string sql, gt;

            if (txtMakhach.Text == "")
            {
                MessageBox.Show("Bạn chưa chọn bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMakhach.Focus();
                return;
            }
            if (txtTenkhach.Text.Trim() == "")
            {
                MessageBox.Show("Bạn phải nhập tên khách", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenkhach.Focus();
                return;
            }
            if (dtpNgaysinh.Text == "")
            {
                MessageBox.Show("Bạn phải nhập ngày sinh", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                dtpNgaysinh.Focus();
                return;
            }
            if (txtSoCMND.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập số CMND", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSoCMND.Focus();
                return;
            }
            if (txtDiachithuongtru.Text == "")
            {
                MessageBox.Show("Bạn phải nhập địa chỉ thường trú", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDiachithuongtru.Focus();
                return;
            }
            if (cmbManghe.Text == "")
            {
                MessageBox.Show("Bạn phải chọn nghề", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cmbManghe.Focus();
                return;
            }
            if (cmbMaCQ.Text == "")
            {
                MessageBox.Show("Bạn phải chọn cơ quan", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cmbMaCQ.Focus();
                return;
            }
            if (chkGioitinh.Checked == true)
            {
                gt = "Nam";
            }
            else
            {
                gt = "Nữ";
            }
            sql = "UPDATE tblKhachThue SET  Tenkhach=N'" + txtTenkhach.Text.Trim().ToString() +
                  "',Ngaysinh =N'" + DAO.ConvertDateTime(dtpNgaysinh.Value.ToString("MM/dd/yyyy")) + "',Gioitinh=N'" + gt +
                  "',SoCMND='" + txtSoCMND.Text.Trim() + "',Diachithuongtru=N'" + txtDiachithuongtru.Text.Trim() +
                  "',Manghe='" + cmbManghe.SelectedValue.ToString() + "',MaCQ='" + cmbMaCQ.SelectedValue.ToString() +
                  "' WHERE Makhach=N'" + txtMakhach.Text.Trim() + "'";
            DAO.OpenConnection();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = sql;
            cmd.Connection  = DAO.con;
            cmd.ExecuteNonQuery();
            loadDataGridView();
            DAO.CloseConnection();
        }
Beispiel #6
0
 private void frmMucdichsudung_Load(object sender, EventArgs e)
 {
     DAO.OpenConnection();
     loadDataGridView();
     DAO.CloseConnection();
 }
Beispiel #7
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string gt;

            if (txtMakhach.Text == "")
            {
                MessageBox.Show("Bạn không được để trống mã khách", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMakhach.Focus();
                return;
            }
            if (txtTenkhach.Text == "")
            {
                MessageBox.Show("Bạn không được để trống tên khách", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenkhach.Focus();
                return;
            }
            if (chkGioitinh.Checked == true)
            {
                gt = "Nam";
            }
            else
            {
                gt = "Nữ";
            }
            if (dtpNgaysinh.Text == "")
            {
                MessageBox.Show("Bạn phải nhập ngày sinh", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                dtpNgaysinh.Focus();
                return;
            }
            if (txtSoCMND.Text == "")
            {
                MessageBox.Show("Bạn không được để trống số CMND", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSoCMND.Focus();
                return;
            }
            if (txtDiachithuongtru.Text == "")
            {
                MessageBox.Show("Bạn không được để trống địa chỉ thường trú", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDiachithuongtru.Focus();
                return;
            }
            if (cmbManghe.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn nghề nghiệp ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cmbMaCQ.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn cơ quan", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string sql = "select * from tblKhachThue where Makhach = '" +
                         txtMakhach.Text.Trim() + "'";
            string sq = "select * from tblKhachThue where SoCMND = '" +
                        txtSoCMND.Text.Trim() + "'";

            DAO.OpenConnection();
            if (DAO.CheckKeyExit(sql))
            {
                MessageBox.Show("Mã khách này đã tồn tại, bạn phải nhập mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMakhach.Focus();
                DAO.CloseConnection();
                return;
            }
            if (DAO.CheckKeyExit(sq))
            {
                MessageBox.Show("Số CMND đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMakhach.Focus();
                DAO.CloseConnection();
                return;
            }
            else
            {
                sql = "insert into  tblKhachThue (Makhach, Tenkhach, Ngaysinh,Gioitinh, " +
                      "SoCMND, Diachithuongtru, Manghe, MaCQ)" +
                      " values ('" + txtMakhach.Text.Trim() + "',N'"
                      + txtTenkhach.Text.Trim() + "', N'" + DAO.ConvertDateTime(dtpNgaysinh.Text.ToString()) + "',N'" +
                      gt + "',N'" + txtSoCMND.Text.Trim() + "',N'" + txtDiachithuongtru.Text.Trim() +
                      "','" + cmbManghe.SelectedValue.ToString() + "','" + cmbMaCQ.SelectedValue.ToString() + "')";
                SqlCommand cmd = new SqlCommand(sql, DAO.con);
                cmd.ExecuteNonQuery();
                loadDataGridView();
                fillDataToComboNghenghiep();
                fillDataToComboCoquan();
                DAO.CloseConnection();
            }
        }
Beispiel #8
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtMasothue.Text == "")
            {
                MessageBox.Show("Bạn phải nhập mã số thuê", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMasothue.Focus();
                return;
            }
            if (cmbKhach.Text == "")
            {
                MessageBox.Show("Bạn phải chọn khách thuê ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cmbNha.Text == "")
            {
                MessageBox.Show("Bạn phải chọn nhà", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cmbNha.Focus();
                return;
            }
            if (cmbMucdich.Text == "")
            {
                MessageBox.Show("Bạn phải chọn mục đích sử dụng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cmbMucdich.Focus();
                return;
            }
            if (dtpNgaybatdau.Text == "")
            {
                MessageBox.Show("Bạn phải nhập ngày bắt đầu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                dtpNgaybatdau.Focus();
                return;
            }
            if (dtpNgayketthuc.Text == "")
            {
                MessageBox.Show("Bạn phải nhập ngày kết thúc", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                dtpNgayketthuc.Focus();
                return;
            }
            if (txtTiendatcoc.Text == "")
            {
                MessageBox.Show("Bạn phải nhập số tiền đặt cọc", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTiendatcoc.Focus();
                return;
            }
            if (cmbHinhthucthanhtoan.Text == "")
            {
                MessageBox.Show("Bạn phải chọn hình thức thanh toán", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cmbHinhthucthanhtoan.Focus();
                return;
            }
            sql = "UPDATE tblThueNha SET  Makhach='" + cmbKhach.SelectedValue.ToString() + "',Manha =N'" + cmbNha.SelectedValue.ToString() + "',MamucdichSD='"
                  + cmbMucdich.SelectedValue.ToString() + "',NgayBD=N'" + DAO.ConvertDateTime(dtpNgaybatdau.Value.ToString("MM/dd/yyyy")) +
                  "',NgayKT=N'" + DAO.ConvertDateTime(dtpNgayketthuc.Value.ToString("MM/dd/yyyy")) + "',Tiendatcoc='"
                  + txtTiendatcoc.Text.Trim() + "',MahinhthucTT='" + cmbHinhthucthanhtoan.SelectedValue.ToString() + "' WHERE Masothue='" + txtMasothue.Text + "'";
            DAO.OpenConnection();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = sql;
            cmd.Connection  = DAO.con;
            cmd.ExecuteNonQuery();
            loadDataGridView();
            DAO.CloseConnection();
        }
Beispiel #9
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtMasothue.Text == "")
            {
                MessageBox.Show("Bạn không được để trống mã số thuê", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMasothue.Focus();
                return;
            }
            if (cmbKhach.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn khách thuê ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cmbNha.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn nhà", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cmbMucdich.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn mục đích sử dụng ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (dtpNgaybatdau.Text == "")
            {
                MessageBox.Show("Bạn phải nhập ngày bắt đầu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                dtpNgaybatdau.Focus();
                return;
            }
            if (dtpNgayketthuc.Text == "")
            {
                MessageBox.Show("Bạn phải nhập ngày kết thúc", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                dtpNgayketthuc.Focus();
                return;
            }
            if (txtTiendatcoc.Text == "")
            {
                MessageBox.Show("Bạn không được để trống số tiền đặt cọc", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTiendatcoc.Focus();
                return;
            }
            if (cmbHinhthucthanhtoan.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn hình thức thanh toán ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string sql = "select * from tblThueNha where Masothue = '" +
                         txtMasothue.Text.Trim() + "'";

            DAO.OpenConnection();
            if (DAO.CheckKeyExit(sql))
            {
                MessageBox.Show("Mã số thuê đã tồn tại");
                txtMasothue.Focus();
                DAO.CloseConnection();
                return;
            }
            else
            {
                sql = "insert into  tblThueNha (Masothue, Makhach,Manha,MamucdichSD,NgayBD,NgayKT,Tiendatcoc,MahinhthucTT)" +
                      " values ('" + txtMasothue.Text.Trim() + "','" + cmbKhach.SelectedValue.ToString() + "', '"
                      + cmbNha.SelectedValue.ToString() + "','" + cmbMucdich.SelectedValue.ToString() + "',N'"
                      + DAO.ConvertDateTime(dtpNgaybatdau.Text.ToString()) + "',N'" + DAO.ConvertDateTime(dtpNgayketthuc.Text.ToString()) +
                      "','" + txtTiendatcoc.Text.Trim() + "','" + cmbHinhthucthanhtoan.SelectedValue.ToString() + "')";
                SqlCommand cmd = new SqlCommand(sql, DAO.con);
                cmd.ExecuteNonQuery();
                loadDataGridView();
                fillDataToComboKhachthue();
                fillDataToComboDanhmucnha();
                fillDataToComboMucdich();
                fillDataToComboHinhthuc();
                DAO.CloseConnection();
            }
        }
Beispiel #10
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtMasothu.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập mã số thu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMasothu.Focus();
                return;
            }
            if (cmbMasothue.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn mã thuê nhà!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtNam.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập năm!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtNam.Focus();
                return;
            }

            string strThang = "";

            if (chk1.Checked == true)
            {
                strThang += chk1.Text + "_";
            }
            if (chk2.Checked == true)
            {
                strThang += chk2.Text + "_";
            }
            if (chk3.Checked == true)
            {
                strThang += chk3.Text + "_";
            }
            if (chk4.Checked == true)
            {
                strThang += chk4.Text + "_";
            }
            if (chk5.Checked == true)
            {
                strThang += chk5.Text + "_";
            }
            if (chk6.Checked == true)
            {
                strThang += chk6.Text + "_";
            }
            if (chk7.Checked == true)
            {
                strThang += chk7.Text + "_";
            }
            if (chk8.Checked == true)
            {
                strThang += chk8.Text + "_";
            }
            if (chk9.Checked == true)
            {
                strThang += chk9.Text + "_";
            }
            if (chk10.Checked == true)
            {
                strThang += chk10.Text + "_";
            }
            if (chk11.Checked == true)
            {
                strThang += chk11.Text + "_";
            }
            if (chk12.Checked == true)
            {
                strThang += chk12.Text + "_";
            }
            if (strThang == "")
            {
                MessageBox.Show("Bạn chưa chọn tháng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtNguoithu.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập người thu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtNguoithu.Focus();
                return;
            }
            if (dtpNgaythu.Text == "")
            {
                MessageBox.Show("Bạn phải nhập ngày thu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                dtpNgaythu.Focus();
                return;
            }
            string sql = "select * from tblThuTienNha where Masothu = '" + txtMasothu.Text.Trim() + "'";

            DAO.OpenConnection();
            if (DAO.CheckKeyExit(sql))
            {
                MessageBox.Show("Mã số thu đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DAO.CloseConnection();
                txtMasothu.Focus();
                return;
            }
            else
            {
                sql = "insert into tblThuTienNha (Masothu,Masothue,Thang,Nam,Tongtien,Nguoithu,Ngaythu,Ghichu) " +
                      " values ('" + txtMasothu.Text.Trim() + "','" + cmbMasothue.SelectedValue.ToString() + "',N'"
                      + strThang.ToString() + "'," + txtNam.Text.Trim() + "," + txtTongtien.Text.Trim() + ",N'" + txtNguoithu.Text.Trim()
                      + "',N'" + DAO.ConvertDateTime(dtpNgaythu.Text.ToString()) + "',N'" + txtGhichu.Text.Trim() + "')";
                SqlCommand cmd = new SqlCommand(sql, DAO.con);
                cmd.ExecuteNonQuery();
                DAO.CloseConnection();
                loadDataGridView();
            }
        }
Beispiel #11
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (txtMasothu.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập mã số thu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMasothu.Focus();
                return;
            }
            if (cmbMasothue.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn mã thuê nhà!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string strThang = "";

            if (chk1.Checked == true)
            {
                strThang += chk1.Text + "_";
            }
            if (chk2.Checked == true)
            {
                strThang += chk2.Text + "_";
            }
            if (chk3.Checked == true)
            {
                strThang += chk3.Text + "_";
            }
            if (chk4.Checked == true)
            {
                strThang += chk4.Text + "_";
            }
            if (chk5.Checked == true)
            {
                strThang += chk5.Text + "_";
            }
            if (chk6.Checked == true)
            {
                strThang += chk6.Text + "_";
            }
            if (chk7.Checked == true)
            {
                strThang += chk7.Text + "_";
            }
            if (chk8.Checked == true)
            {
                strThang += chk8.Text + "_";
            }
            if (chk9.Checked == true)
            {
                strThang += chk9.Text + "_";
            }
            if (chk10.Checked == true)
            {
                strThang += chk10.Text + "_";
            }
            if (chk11.Checked == true)
            {
                strThang += chk11.Text + "_";
            }
            if (chk12.Checked == true)
            {
                strThang += chk12.Text + "_";
            }
            if (strThang == "")
            {
                MessageBox.Show("Bạn chưa chọn tháng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtNam.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập năm!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtNam.Focus();
                return;
            }
            if (txtNguoithu.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập người thu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtNguoithu.Focus();
                return;
            }
            if (dtpNgaythu.Text == "")
            {
                MessageBox.Show("Bạn phải nhập ngày thu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                dtpNgaythu.Focus();
                return;
            }

            string sql = "UPDATE tblThuTienNha SET  Masothue='" + cmbMasothue.SelectedValue.ToString() +
                         "',Thang =N'" + strThang + "',Nam=" + txtNam.Text.Trim() + ",Tongtien=" +
                         txtTongtien.Text.Trim() + ",Nguoithu=N'" + txtNguoithu.Text.Trim() +
                         "',Ngaythu=N'" + DAO.ConvertDateTime(dtpNgaythu.Value.ToString("MM/dd/yyyy")) +
                         "',Ghichu=N'" + txtGhichu.Text.Trim() + "' WHERE Masothu=N'" + txtMasothu.Text.Trim() + "'";

            DAO.OpenConnection();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = sql;
            cmd.Connection  = DAO.con;
            cmd.ExecuteNonQuery();
            loadDataGridView();
            DAO.CloseConnection();
        }