// public bool Them(DocGiaDAO docGiaDAO, object dg) // { // throw new NotImplementedException(); // } public bool Sua(DocGiaDAOcs dg) { try { string query = @" UPDATE dbo.DocGia set HoTen = N'" + dg.HoTen + "',NgaySinh = CONVERT(DATE,'" + dg.NgaySinh + "',103) ,GioiTinh=N'" + dg.GioiTinh + "', DiaChi= N'" + dg.DiaChi + "', SDT='" + dg.SDT + "' where SoThe ='" + dg.SoThe + "'"; OpenConection(); ExecuteQueries(query); CloseConnection(); return(true); } catch (Exception ex) { SetEx(ex); return(false); } }
public bool Them(DocGiaDAOcs dg) { try { string query = @"INSERT INTO dbo.DocGia( SoThe,HoTen , NgaySinh ,GioiTinh,DiaChi,SDT) VALUES ( '" + dg.SoThe + "',N'" + dg.HoTen + "', CONVERT(DATE,'" + dg.NgaySinh + "',103),N'" + dg.GioiTinh + "', N'" + dg.DiaChi + "', '" + dg.SDT + "')"; OpenConection(); ExecuteQueries(query); CloseConnection(); return(true); } catch (Exception ex) { SetEx(ex); return(false); } }
private void btsua_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Bạn có muốn sửa không?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { if (txtsothe.Text != "" && txthoten.Text != "" && txtsdt.Text != "" && txtdiachi.Text != "") { string gioitinh = ""; if (rdnam.Checked) { gioitinh = "Nam"; } else { gioitinh = "Nữ"; } DocGiaDAOcs dg = new DocGiaDAOcs(txtsothe.Text.ToString().Trim(), txthoten.Text.ToString().Trim(), dtngaysinh.Text.Trim(), gioitinh, txtdiachi.Text.ToString().Trim(), txtsdt.Text.ToString().Trim()); if (dg1.Sua(dg) == true) { FormatData(); ShowData(); MessageBox.Show("Sửa thành công"); } else { Exception ex = dg1.GetEx(); MessageBox.Show(ex.Message); MessageBox.Show("Có lỗi xảy ra"); } } else MessageBox.Show("Bạn cần nhập đủ thông tin độc giả"); } }
private void btthem_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Bạn có muốn thêm không ?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { if (txtsothe.Text != "" && txthoten.Text != "" && txtsdt.Text != "" && txtdiachi.Text != "") { string gioitinh = ""; if (rdnam.Checked) { gioitinh = "Nam"; } else { gioitinh = "Nữ"; } DocGiaDAOcs dg = new DocGiaDAOcs(txtsothe.Text.ToString().Trim(), txthoten.Text.ToString().Trim(), dtngaysinh.Text.Trim(), gioitinh, txtdiachi.Text.ToString().Trim(), txtsdt.Text.ToString()); //(txtMaNV.Text.ToString().Trim(), txtTen.Text.ToString().Trim(), txtMaPhong.Text.ToString().Trim(),DateTime.Parse(dtNgaySinh.Text.ToString()),gioitinh,int.Parse(txtLuong.Text.ToString()), txtDiaChi.Text.ToString().Trim()); if (dg1.Them(dg) == true) { // FormatData(); ShowData(); MessageBox.Show("Thêm thành công"); } else { Exception ex = dg1.GetEx(); MessageBox.Show(ex.Message); MessageBox.Show("Có lỗi xảy ra"); } } else MessageBox.Show("Bạn cần nhập đủ thông tin độc giả"); } }
public bool Sua(DocGiaDAOcs dg) { return(dg1.Sua(dg)); }
public bool Them(DocGiaDAOcs dg) { return(dg1.Them(dg)); }