private void AddData(PhongObj hh) { hh.MaPhong = txtMaPhong.Text.Trim(); hh.TenPhong = txtTenPhong.Text.Trim(); hh.DonGia = int.Parse(txtDonGia.Text.Trim()); hh.SoLuong = int.Parse(txtSoLuong.Text.Trim()); }
private void GanDuLieu(PhongObj p1obj) { p1obj.MaPhong = txtMaPhong.Text.ToString().Trim(); p1obj.TenPhong = txtTenPhong.Text.ToString().Trim(); p1obj.TinhTrang = txtTinhTrang.Text.ToString().Trim(); p1obj.DonVi = txtDonVi.Text.ToString().Trim(); p1obj.GiaPhong = cbbGia.Text.ToString().Trim(); p1obj.MaPhanLoai = cbbMaPL.Text.ToString().Trim(); }
public bool UpdData(PhongObj pObj) { cmd.CommandText = " Update tb_Phong set TenPhong = N'" + pObj.TenPhong + "', SoLuong = " + pObj.SoLuong + ", DonGia = " + pObj.DonGia + " Where MaPhong = '" + pObj.MaPhong + "' "; cmd.CommandType = CommandType.Text; cmd.Connection = con.Connection; try { con.OpenConn(); cmd.ExecuteNonQuery(); return(true); } catch (Exception ex) { string mex = ex.Message; cmd.Dispose(); con.CloseConn(); } return(false); }
public bool AddData(PhongObj pObj) { cmd.CommandText = " Insert into tb_Phong values ('" + pObj.MaPhong + "', N'" + pObj.TenPhong + "'," + pObj.DonGia + ", 0 ) "; cmd.CommandType = CommandType.Text; cmd.Connection = con.Connection; try { con.OpenConn(); cmd.ExecuteNonQuery(); return(true); } catch (Exception ex) { string mex = ex.Message; cmd.Dispose(); con.CloseConn(); } return(false); }
/// <summary> /// Hàm sửa thông tin một nhân viên /// </summary> /// <param name="khobj"> đối tượng nhân viên cần sửa</param> public bool UpdatePhong(PhongObj pobj) { cmd.CommandText = " update Phong set TenPhong='" + pobj.TenPhong + "',TinhTrang='" + pobj.TinhTrang + "',GiaPhong='" + pobj.GiaPhong + "',MaPL='" + pobj.MaPhanLoai + "',DonVi='" + pobj.DonVi + "', where MaPhong='" + pobj.MaPhong + "'"; cmd.CommandType = CommandType.Text; cmd.Connection = con.strConn; try { con.OpenConnect(); cmd.ExecuteNonQuery(); con.CloseConnection(); return(true); } catch (Exception ex) { string mes = ex.Message; cmd.Dispose(); con.CloseConnection(); } return(true); }
/// <summary> /// Hàm Thêm nhân viên vào danh sách /// </summary> /// <param name="nvobj">đối tượng cần thêm vào ds</param> public bool AddPhong(PhongObj pobj) { cmd.CommandText = "Insert into Phong values ('" + pobj.MaPhong + "','" + pobj.TenPhong + "',N'" + pobj.TinhTrang + "','" + pobj.GiaPhong + "','" + pobj.MaPhanLoai + "','" + pobj.DonVi + "')"; cmd.CommandType = CommandType.Text; cmd.Connection = con.strConn; try { con.OpenConnect(); cmd.ExecuteNonQuery(); con.CloseConnection(); return(true); } catch (Exception ex) { string mes = ex.Message; cmd.Dispose(); con.CloseConnection(); } return(true); }
private void btnLuu_Click(object sender, EventArgs e) { PhongObj hhObj = new PhongObj(); AddData(hhObj); if (flagLuu == 0) { if (PCtr.AddData(hhObj)) { MessageBox.Show("Thêm thành công", "thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm không thành công", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (flagLuu == 1) { if (PCtr.UpdData(hhObj)) { MessageBox.Show("Sửa thành công", "thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Sửa không thành công", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (PCtr.UpdData(hhObj)) { MessageBox.Show("Nhập phòng thành công", "thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Nhập phòng không thành công", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } FrmPhong_Load(sender, e); }
public bool UpdSL(PhongObj hhObj) { DataTable dthh = new DataTable(); dthh = hhMod.GetData(); for (int i = 0; i < dthh.Rows.Count; i++) { for (int j = 0; j < dthh.Rows.Count; j++) { if (dthh.Rows[i][1].ToString() == dthh.Rows[j][0].ToString()) { int SLcu = int.Parse(dthh.Rows[j][3].ToString()); int SLmoi = int.Parse(dthh.Rows[j][3].ToString()) - int.Parse(dthh.Rows[i][3].ToString()); if (!hhMod.UpdSL(dthh.Rows[j][0].ToString(), SLmoi)) { return(false); } break; } } } return(true); }
public bool UpdData(PhongObj hhObj) { return(hhMod.UpdData(hhObj)); }
public bool AddData(PhongObj hhObj) { return(hhMod.AddData(hhObj)); }