private void btndangngay_Click(object sender, EventArgs e) { if (Kiemtranhapfrm(sender, e)) { Boolean li; if (rdoban.Checked == true) { li = true; } else { li = false; } string diachi = txtdcnha.Text + "/" + cboxa.Text + "/" + cbohuyen.Text + "/" + cbotinh.Text; string madt = busdtin.TaoMa(); DTO_Dangtin dtodt = new DTO_Dangtin(madt, FDangnhap.matk, li, txtmota.Text, Convert.ToSingle(txtgia.Text), txtgioithieu.Text, txtdientich.Text, cbolch.Text, Convert.ToInt32(txtsotang.Text), Convert.ToInt32(txtphongngu.Text), Convert.ToInt32(txtwc.Text), diachi); if (busdtin.Them(dtodt)) { Xulyanh(madt); MessageBox.Show("Thành công", "Thông báo"); } else { MessageBox.Show("Không thành công.", "Thông báo"); } } else { MessageBox.Show("Vui lòng nhập đủ thông tin."); } // MessageBox.Show(txtgioithieu.Text); //MessageBox.Show(diachi); }
//sua public bool Sua(DTO_Dangtin dt) { string ud = "update Dangtin set ID='" + dt.ID + "',Loai='" + dt.Loai + "',Mota=N'" + dt.Mota + "',Gia='" + dt.Gia + "',Motachitiet=N'" + dt.MTCT + "',Dientich='" + dt.Dientich + "',Loaicanho=N'" + dt.Lch + "',Sotang='" + dt.Tang + "',Sophongngu='" + dt.Phongngu + "',Vs='" + dt.VS + "',Diachi='" + dt.DC + "' where DT='" + dt.DT + "'"; if (daotv.NonQuery(ud)) { return(true); } return(false); }
public bool Them(DTO_Dangtin dtin) { string insert = string.Format("INSERT INTO Dangtin([DT], [ID], [Loai], [Mota], [Gia], [Motachitiet], [Dientich], [Loaicanho], [Sotang], [Sophongngu], [Vs], [Diachi]) VALUES('{0}','{1}','{2}',N'{3}','{4}',N'{5}','{6}',N'{7}','{8}','{9}','{10}',N'{11}')", dtin.DT, dtin.ID, dtin.Loai, dtin.Mota, dtin.Gia, dtin.MTCT, dtin.Dientich, dtin.Lch, dtin.Tang, dtin.Phongngu, dtin.VS, dtin.DC); if (daotv.NonQuery(insert)) { return(true); } return(false); }