private PhongVO GetPhongVO() { PhongVO phongVO = new PhongVO(); phongVO.SoPhong = txt_SoPhong.Text; phongVO.MaLoaiPhong = Int32.Parse(cbo_LoaiPhong.SelectedValue.ToString()); phongVO.MaTinhTrang = Int32.Parse(cbo_TinhTrang.SelectedValue.ToString()); return(phongVO); }
//gan phong cho cac Lich Day trong 1 BUOI(sang or chieu). private void ganPhongChoNhom(List <LichDayVO> listLichDay) { List <LopVO> listLopHoc = new List <LopVO>(); // lay danh sach cac lop hoc tuong ung dua vao lich day // va sap xep lop hoc giam dan theo so luong sinh vien. listLopHoc = getListLopHoc(listLichDay); List <LichDayVO> lichDayCoPhongTemp = new List <LichDayVO>(); List <LichDayVO> lichDayTemp = new List <LichDayVO>(); lichDayTemp = listLichDay; // so luong lich day cua buoi dang can xep PHONG. int soluongLichDay = listLichDay.Count; PhongVO phongDuSoMay = new PhongVO(); while (listPhongTam.Count > 0 && listLichDay.Count > 0) { LichDayVO temp = new LichDayVO(); for (int i = 0; i < listLopHoc.Count; ++i) { temp = getLichDayByMaTrong1List(listLichDay, listLopHoc[i].MaLop); phongDuSoMay = kiemPhongDuSoMay(listLopHoc[i], temp); //kiem dc phong du so may if (phongDuSoMay != null)//? { // temp.MaPhong = phongDuSoMay.MaPhong; listPhongTam.Remove(phongDuSoMay); listLichDayCoPhong.Add(temp); listLichDay.Remove(temp); ////lichDayCoPhongTemp.Add(listLichDay[j]); //so lich day da dc xep phong tang len demSoLichDayDcXep++; } else { //tao 1 list bao gom cac phong duoc ghep List <PhongVO> listCacPhongDanhCho1LTH = new List <PhongVO>(); listCacPhongDanhCho1LTH = kiemThemPhongDuSoMay(listLopHoc[i], listPhongTam); demSoLichDayTaoThem = demSoLichDayTaoThem + listCacPhongDanhCho1LTH.Count - 1; if (listCacPhongDanhCho1LTH.Count > 1) { //gan nhieu phong cho 1 lichthucHanh addLichThucHanhCungThay(temp, listCacPhongDanhCho1LTH); lichThucHanhNonPhong.Remove(temp); removeInListPhongTam(listPhongTam, listCacPhongDanhCho1LTH); } listLichDay.Remove(temp); } } } }
public bool themPhong(PhongVO P) { bool a = _PhongDAO.InsertPhong(P); if (a == true) { return(true); } return(false); }
public int Update(PhongVO phongVO) { try { return(phongDAO.Update(phongVO)); } catch (Exception e) { throw e; } }
public int Insert(PhongVO phongVO) { try { return(phongDAO.Insert(phongVO)); } catch (Exception e) { throw e; } }
} //end method SelectAvailableRoom public int Insert(PhongVO phongVO) { try { String query = "INSERT INTO PHONG VALUES(@MA_LOAIPHONG,@MA_TINH_TRANG, '')"; SqlParameter[] sqlParameters = new SqlParameter[2]; sqlParameters[0] = new SqlParameter("@MA_LOAIPHONG", phongVO.MaLoaiPhong); sqlParameters[1] = new SqlParameter("@MA_TINH_TRANG", phongVO.MaTinhTrang); return(Program.DBConnection.ExecuteNonQuery(query, sqlParameters)); } catch (Exception e) { throw e; } }
public int Update(PhongVO phongVO) { try { String query = "UPDATE PHONG SET MA_LOAI_PHONG=@MA_LOAI_PHONG,MA_TINH_TRANG = @MA_TINH_TRANG WHERE SO_PHONG=@SO_PHONG"; SqlParameter[] sqlParameters = new SqlParameter[3]; sqlParameters[0] = new SqlParameter("@SO_PHONG", phongVO.SoPhong); sqlParameters[1] = new SqlParameter("@MA_LOAI_PHONG", phongVO.MaLoaiPhong); sqlParameters[2] = new SqlParameter("@MA_TINH_TRANG", phongVO.MaTinhTrang); return(Program.DBConnection.ExecuteNonQuery(query, sqlParameters)); } catch (Exception e) { throw e; } }
// get all Phong from database. private List <PhongVO> getListPhong() { List <PhongVO> listPhong = new List <PhongVO>(); System.Data.DataTable dt = new System.Data.DataTable(); dt = phongDao.GetAllPhong(); if (dt != null) { foreach (DataRow r in dt.Rows) { PhongVO phongVO = new PhongVO(); phongVO.MaPhong = r[0].ToString(); phongVO.TenPhong = r[1].ToString(); phongVO.SoMay = Convert.ToInt32(r[2]); listPhong.Add(phongVO); } } return(listPhong); }
public bool UpdatePhong(PhongVO P) { try { string query = string.Format("UPDATE Phong SET MaPhong = @MaPhong, TenPhong=@TenPhong, SoMay=@SoMay Where MaPhong = @MaPhong"); SqlParameter[] sqlParameters = new SqlParameter[3]; sqlParameters[0] = new SqlParameter("@MaPhong", SqlDbType.VarChar); sqlParameters[0].Value = Convert.ToString(P.MaPhong); sqlParameters[1] = new SqlParameter("@TenPhong", SqlDbType.NVarChar); sqlParameters[1].Value = Convert.ToString(P.TenPhong); sqlParameters[2] = new SqlParameter("@SoMay", SqlDbType.Int); sqlParameters[2].Value = Convert.ToString(P.SoMay); return(conn.executeInsertQuery(query, sqlParameters)); } catch { return(false); } }
public bool InsertPhong(PhongVO P) { try { string query = string.Format("insert into Phong(MaPhong,TenPhong,SoMay) Values(@MaPhong,@TenPhong,@SoMay)"); SqlParameter[] sqlParameters = new SqlParameter[3]; sqlParameters[0] = new SqlParameter("@MaPhong", SqlDbType.VarChar); sqlParameters[0].Value = Convert.ToString(P.MaPhong); sqlParameters[1] = new SqlParameter("@TenPhong", SqlDbType.NVarChar); sqlParameters[1].Value = Convert.ToString(P.TenPhong); sqlParameters[2] = new SqlParameter("@SoMay", SqlDbType.Int); sqlParameters[2].Value = Convert.ToString(P.SoMay); return(conn.executeInsertQuery(query, sqlParameters)); } catch { return(false); } }
public bool XoaPhong(PhongVO P) { return(_PhongDAO.DeleteGiaoVien(P)); }
public bool CapNhatPhong(PhongVO P) { return(_PhongDAO.UpdatePhong(P)); }