Exemple #1
0
 private void btnSua_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(txtTen.Text) && txtTen.Text.Length < 50)
     {
         if (!string.IsNullOrWhiteSpace(txtCMND.Text) && txtCMND.Text.Length <= 15)
         {
             if (!string.IsNullOrWhiteSpace(txtTang.Text) && txtTang.Text.Length < 50)
             {
                 if (!string.IsNullOrWhiteSpace(txtPhong.Text) && txtPhong.Text.Length < 50)
                 {
                     if (!string.IsNullOrWhiteSpace(txtNgayvao.Text) && txtNgayvao.Text.Length < 50)
                     {
                         string gt = cbNam.Checked == true ? "nam" : "nữ";
                         this.CanHo = new CanHo(txtTen.Text, txtCMND.Text, txtTang.Text, txtPhong.Text, txtNgayvao.Text, gt, txtQueQuan.Text, txtNamSinh.Text);
                         if (dbAccess.SuaCanHo(CanHo, s.CMND))
                         {
                             MessageBox.Show("Thêm thành công");
                         }
                         else
                         {
                             MessageBox.Show("Không thể thêm thông tin vui lòng kiểm tra lại dữ liệu");
                         }
                         this.Close();
                     }
                 }
             }
         }
     }
 }
Exemple #2
0
        public bool ThemCanHo(CanHo ch)
        {
            if (ch == null)
            {
                return(false);
            }
            try
            {
                string sql = "insert into " + "CanHo(soCMNDChuHo, tenChuHo, tenPhong, tenTang,gioiTinh,queQuan,ngayVao,namSinh) "
                             + "values(@soCMNDChuHo, @tenChuHo, @tenPhong, @tenTang,@gioiTinh,@queQuan,@ngayVao,@namSinh)";
                using (SqlCommand insertCommand = new SqlCommand(sql, connection))
                {
                    insertCommand.Parameters.AddWithValue("@soCMNDChuHo", ch.CMND);
                    insertCommand.Parameters.AddWithValue("@tenChuHo", ch.Ten);
                    insertCommand.Parameters.AddWithValue("@tenPhong", ch.Phong);
                    insertCommand.Parameters.AddWithValue("@tenTang", ch.Tang);

                    insertCommand.Parameters.AddWithValue("@gioiTinh", ch.GT);
                    insertCommand.Parameters.AddWithValue("@queQuan", ch.QueQuan);
                    insertCommand.Parameters.AddWithValue("@ngayVao", ch.NgayVao);
                    insertCommand.Parameters.AddWithValue("@namSinh", ch.NamSinh);

                    if (insertCommand.ExecuteNonQuery() == 1)
                    {
                        return(true);
                    }
                }
            }
            catch
            {
                MessageBox.Show("lỗi thêm căn hộ:\n");
            }
            return(false);
        }
Exemple #3
0
 void SetCanHo(CanHo s)
 {
     txtTen.Text     = s.Ten;
     txtCMND.Text    = s.CMND;
     txtTang.Text    = s.Tang;
     txtPhong.Text   = s.Phong;
     txtNgayvao.Text = s.NgayVao;
     cbNam.Checked   = s.GT == "nam" ? true : false;
     txtQueQuan.Text = s.QueQuan;
     txtNamSinh.Text = s.NamSinh;
 }
 private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     try
     {
         s = new CanHo(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(),
                       dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(),
                       dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(),
                       dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(),
                       dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString(),
                       dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString(),
                       dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString(),
                       dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString());
     }
     catch
     {
     }
 }
Exemple #5
0
        public bool SuaCanHo(CanHo ch, string id)
        {
            if (ch == null)
            {
                return(false);
            }
            try
            {
                var s   = Convert.ToDateTime(ch.NgayVao);
                var x   = s.Day + "/" + s.Month + "/" + s.Year;
                var r   = Convert.ToDateTime(ch.NamSinh);
                var y   = r.Day + "/" + r.Month + "/" + r.Year;
                var sql = "update CanHo set soCMNDChuHo ='" +
                          @ch.CMND +
                          "', tenChuHo='" + @ch.Ten +
                          "', tenPhong='" + @ch.Phong +
                          "', tenTang='" + @ch.Tang +

                          "', gioiTinh='" + @ch.GT +
                          "', queQuan='" + @ch.QueQuan +
                          "', ngayVao='" + @x +
                          "', namSinh='" + @y +

                          "' where soCMNDChuHo='" + id + "'";
                using (SqlCommand updateCommand = new SqlCommand(sql, connection))
                {
                    if (updateCommand.ExecuteNonQuery() == 1)
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
Exemple #6
0
 private void detach_CanHos(CanHo entity)
 {
     this.SendPropertyChanging();
     entity.CuDan = null;
 }
Exemple #7
0
 private void attach_CanHos(CanHo entity)
 {
     this.SendPropertyChanging();
     entity.CuDan = this;
 }
Exemple #8
0
 partial void DeleteCanHo(CanHo instance);
Exemple #9
0
 partial void UpdateCanHo(CanHo instance);
Exemple #10
0
 partial void InsertCanHo(CanHo instance);
Exemple #11
0
 public SuaCanHo(CanHo s, DbAccess dbAccess) : this(s)
 {
     this.dbAccess = dbAccess;
 }
Exemple #12
0
 public SuaCanHo(CanHo s) : this()
 {
     this.s = s;
     SetCanHo(s);
 }