Exemplo n.º 1
0
 private void cmbNha_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbNha.SelectedIndex != -1)
     {
         string sql, sql1;
         if (cmbNha.Text == "")
         {
             txtTiendatcoc.Text = "";
             return;
         }
         sql = "SELECT Dongiathue FROM tblDanhMucNha WHERE Manha = '" + cmbNha.Text + "'";
         DataTable table = DAO.DocBang(sql);
         if (table.Rows.Count > 0)
         {
             txtTiendatcoc.Text = table.Rows[0][0].ToString();
         }
         if (cmbNha.Text == "")
         {
             txtDoituong.Text = "";
             return;
         }
         sql1 = "SELECT b.TenDTSD FROM tblDanhMucNha as a join tblDoiTuongSuDung as b on a.MaDTSD = b.MaDTSD WHERE a.Manha = '" + cmbNha.Text + "'";
         DataTable table1 = DAO.DocBang(sql1);
         if (table1.Rows.Count > 0)
         {
             txtDoituong.Text = table1.Rows[0][0].ToString();
         }
     }
 }
Exemplo n.º 2
0
        private void btnTim_Click(object sender, EventArgs e)
        {
            if (cmbMasothue.Text == "")
            {
                txtTongtienthu.Text = "";
                return;
            }
            string sql = "select Sum(a.TongTien) from tblThuTienNha as a join tblThueNha as b on a.Masothue=b.Masothue where b.Masothue='"
                         + cmbMasothue.SelectedValue.ToString() + "'";
            DataTable table = DAO.DocBang(sql);

            if (table.Rows.Count > 0)
            {
                txtTongtienthu.Text = table.Rows[0][0].ToString();
            }
        }
Exemplo n.º 3
0
        private void cmbManha_SelectedIndexChanged(object sender, EventArgs e)
        {
            string sql;

            if (cmbManha.Text == "")
            {
                txtTenchunha.Text = "";
                return;
            }
            sql = "SELECT Tenchunha FROM tblDanhMucNha WHERE Manha = '" + cmbManha.Text + "'";
            DataTable table = DAO.DocBang(sql);

            if (table.Rows.Count > 0)
            {
                txtTenchunha.Text = table.Rows[0][0].ToString();
            }
        }
Exemplo n.º 4
0
        private void cmbMasothue_SelectedIndexChanged(object sender, EventArgs e)
        {
            string sql, sql1;

            if (cmbMasothue.SelectedIndex != -1)
            {
                txtNgaybatdau.Text = DAO.GetFieldValues("select NgayBD from tblThueNha where Masothue = '" + cmbMasothue.SelectedValue.ToString() + "'");
            }

            if (cmbMasothue.Text == "")
            {
                txtDongiathue.Text = "";
                return;
            }
            sql = "SELECT Tiendatcoc FROM tblThueNha WHERE Masothue = '" + cmbMasothue.Text + "'";
            DataTable table = DAO.DocBang(sql);

            if (table.Rows.Count > 0)
            {
                txtDongiathue.Text = table.Rows[0][0].ToString();
            }
            if (cmbMasothue.SelectedIndex != -1)
            {
                if (cmbMasothue.Text == "")
                {
                    txtHinhThuc.Text = "";
                    return;
                }
                sql1 = "SELECT b.TenhinhthucTT FROM tblThueNha as a join tblHinhThucThanhToan as b on a.MahinhthucTT=b.MahinhthucTT WHERE a.Masothue = '" + cmbMasothue.Text + "'";
                DataTable tbl = DAO.DocBang(sql1);
                if (tbl.Rows.Count > 0)
                {
                    txtHinhThuc.Text = tbl.Rows[0][0].ToString();
                }

                double dg, ht, tt;
                dg = Convert.ToDouble(txtDongiathue.Text);
                ht = Convert.ToDouble(txtHinhThuc.Text);
                tt = dg * ht;
                txtTongtien.Text = tt.ToString();
            }
        }
Exemplo n.º 5
0
 private void cmbMasothue_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbMasothue.SelectedIndex != -1)
     {
         string sql, sql1, sql2;
         if (cmbMasothue.Text == "")
         {
             txtManha.Text = "";
             return;
         }
         sql = "SELECT Manha FROM tblThueNha WHERE Masothue = '" + cmbMasothue.Text + "'";
         DataTable table = DAO.DocBang(sql);
         if (table.Rows.Count > 0)
         {
             txtManha.Text = table.Rows[0][0].ToString();
         }
         if (cmbMasothue.Text == "")
         {
             txtTenkhach.Text = "";
             return;
         }
         sql1 = "SELECT b.Tenkhach FROM tblThueNha as a join tblKhachThue as b on a.Makhach=b.Makhach WHERE a.Masothue = '" + cmbMasothue.Text + "'";
         DataTable table1 = DAO.DocBang(sql1);
         if (table1.Rows.Count > 0)
         {
             txtTenkhach.Text = table1.Rows[0][0].ToString();
         }
         if (cmbMasothue.Text == "")
         {
             txtDiachi.Text = "";
             return;
         }
         sql2 = "SELECT b.Diachi FROM tblThueNha as a join tblDanhMucNha as b on a.Manha=b.Manha WHERE Masothue = '" + cmbMasothue.Text + "'";
         DataTable table2 = DAO.DocBang(sql2);
         if (table2.Rows.Count > 0)
         {
             txtDiachi.Text = table2.Rows[0][0].ToString();
         }
     }
 }
Exemplo n.º 6
0
        private void cmbMasothue_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbMasothue.SelectedIndex != -1)
            {
                txtNgayketthuc.Text = DAO.GetFieldValues("select NgayKT from tblThueNha where Masothue = '" + cmbMasothue.SelectedValue.ToString() + "'");
            }

            string sql, sql1;

            if (cmbMasothue.Text == "")
            {
                txtBoithuong.Text = "";
                return;
            }
            sql = "select sum(Thanhtien) from tblTraNha_MatTaiSan where Masothue='" + cmbMasothue.SelectedValue + "'";
            DataTable table = DAO.DocBang(sql);

            if (table.Rows.Count > 0)
            {
                txtBoithuong.Text = table.Rows[0][0].ToString();
            }


            if (cmbMasothue.Text == "")
            {
                txtTiendatcoc.Text = "";
                return;
            }
            sql1 = "SELECT Tiendatcoc FROM tblThueNha WHERE Masothue = '" + cmbMasothue.Text + "'";
            DataTable tbl = DAO.DocBang(sql1);

            if (tbl.Rows.Count > 0)
            {
                txtTiendatcoc.Text = tbl.Rows[0][0].ToString();
            }
        }
Exemplo n.º 7
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            double gt1, gt2, ss;

            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 (cmbTaisan.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn tài sản!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtSoluong.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập số lượng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSoluong.Focus();
                return;
            }
            if (txtGiatri.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập giá trị!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtGiatri.Focus();
                return;
            }
            //
            string sql = "select * from tblTraNha_MatTaiSan where Masothue='" + cmbMasothue.SelectedValue.ToString() + "' and Mataisan='" + cmbTaisan.SelectedValue.ToString() + "'";

            DAO.OpenConnection();
            if (DAO.CheckKeyExit(sql))
            {
                MessageBox.Show("Tài sản này đã được kê khai trong nhà bạn chọn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DAO.CloseConnection();
                cmbMasothue.Focus();
                return;
            }
            string    str   = "select a.Giatri from tblNha_TaiSan as a join tblThueNha as b on a.Manha=b.Manha where a.Mataisan = '" + cmbTaisan.SelectedValue.ToString() + "' and b.Masothue= '" + cmbMasothue.SelectedValue.ToString() + "'";
            DataTable table = DAO.DocBang(str);

            if (table.Rows.Count > 0)
            {
                txtGiatribandau.Text = table.Rows[0][0].ToString();
            }
            gt1 = Convert.ToDouble(txtGiatribandau.Text);
            gt2 = Convert.ToDouble(txtGiatri.Text);
            ss  = gt2 - gt1;

            if (ss > 0)
            {
                MessageBox.Show("Giá trị không hợp lệ vì lớn hơn giá trị ban đầu, mời nhập lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtGiatri.Focus();
                return;
            }
            else
            {
                sql = "insert into tblTraNha_MatTaiSan (Masothue,Mataisan,Soluong,Giatri,Thanhtien) " +
                      " values ('" + cmbMasothue.SelectedValue.ToString() + "','" + cmbTaisan.SelectedValue.ToString() + "',"
                      + txtSoluong.Text.Trim() + "," + txtGiatri.Text.Trim() + "," + txtThanhtien.Text.Trim() + ")";
                DAO.con.Open();
                SqlCommand cmd = new SqlCommand(sql, DAO.con);

                cmd.ExecuteNonQuery();
                DAO.CloseConnection();
                loadDataGridView();
            }
        }