//

        //
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                var      db        = new QuanLyPhongTroEntities2();
                int      RoomName  = (int)(this.cboRoomName.SelectedValue);
                DateTime dateStart = dtpStart.Value;
                DateTime dateEnd   = dtpEnd.Value;
                //
                int?duration;
                txtDuration.Text = (dtpEnd.Value - dtpStart.Value).TotalDays.ToString("#");
                duration         = int.Parse(txtDuration.Text);
                //
                int?Bill = int.Parse(txtBill.Text);
                //
                var newSession = db.Sessions.Find(this.session.ID);
                newSession.RoomID     = RoomName;
                newSession.DateStart  = dateStart;
                newSession.DateEnd    = dateEnd;
                newSession.Duration   = duration;
                newSession.TenantName = txtName.Text;
                newSession.TenantId   = txtIDN.Text;
                newSession.Total      = Bill;
                //
                db.Entry(newSession).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Invalid input : please dont let any field empty");
            }
        }
        public FormEditSession(int ID)
        {
            InitializeComponent();
            var db = new QuanLyPhongTroEntities2();

            session = db.Sessions.Single(st => st.ID == ID);
        }
Beispiel #3
0
        public FormEditRoom(int ID)
        {
            var db = new QuanLyPhongTroEntities2();

            InitializeComponent();
            room = db.Rooms.Single(st => st.ID == ID);
        }
Beispiel #4
0
        public FormEditPrice(int ID)
        {
            var db = new QuanLyPhongTroEntities2();

            InitializeComponent();
            price = db.Prices.Single(st => st.ID == ID);
        }
Beispiel #5
0
        private void FormEditPrice_Load(object sender, EventArgs e)
        {
            var db = new QuanLyPhongTroEntities2();

            this.txtValue.Text = price.Value.ToString();
            this.txtVName.Text = price.ValueName.ToString();
        }
        private void FormAddSession_Load(object sender, EventArgs e)
        {
            var db = new QuanLyPhongTroEntities2();

            this.cboRoomName.DataSource    = db.Rooms.ToList();
            this.cboRoomName.ValueMember   = "ID";
            this.cboRoomName.DisplayMember = "RoomName";
        }
        //event for loading data to the main form
        private void FormMain_Load(object sender, EventArgs e)
        {
            QuanLyPhongTroEntities2 db = new QuanLyPhongTroEntities2();

            this.frmRoom.DataSource    = db.Rooms.ToList().Select(r => new model.RoomView(r)).ToList();
            this.frmSession.DataSource = db.Sessions.ToList().Select(s => new model.SessionView(s)).ToList();
            this.frmPrice.DataSource   = db.Prices.ToList().Select(p => new model.PriceView(p)).ToList();
        }
Beispiel #8
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            var db        = new QuanLyPhongTroEntities2();
            var newPrice  = db.Prices.Find(this.price.ID);
            int tempValue = int.Parse(txtValue.Text);

            newPrice.Value           = tempValue;
            newPrice.ValueName       = txtVName.Text;
            db.Entry(newPrice).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            this.Close();
        }
        private void FormAddRoom_Load(object sender, EventArgs e)
        {
            QuanLyPhongTroEntities2 db = new QuanLyPhongTroEntities2();

            //loading data for combo box Room status
            this.cboRoomStatus.DataSource = db.RoomStatus.ToList();
            //display the status name into the combo box
            this.cboRoomStatus.ValueMember   = "ID";
            this.cboRoomStatus.DisplayMember = "StatusName";
            //loading data for combo box Room Type
            this.cboRoomType.DataSource    = db.Prices.ToList();
            this.cboRoomType.ValueMember   = "ID";
            this.cboRoomType.DisplayMember = "ValueName";
        }
Beispiel #10
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int Type    = (int)(this.cboRoomType.SelectedValue);
            int Status  = (int)(this.cboRoomStatus.SelectedValue);
            var db      = new QuanLyPhongTroEntities2();
            var newRoom = db.Rooms.Find(this.room.ID);

            newRoom.RoomName        = txtRoomName.Text;
            newRoom.TypeID          = Type;
            newRoom.StatusID        = Status;
            db.Entry(newRoom).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            this.Close();
        }
        //Price
        private void btnDeleteP_Click(object sender, EventArgs e)
        {
            var db = new QuanLyPhongTroEntities2();

            if (frmPrice.SelectedRows.Count == 1)
            {
                var   row   = frmPrice.SelectedRows[0];
                var   cell  = row.Cells["ID"];
                int   id    = (int)cell.Value;
                Price price = db.Prices.Single(st => st.ID == id);
                db.Prices.Remove(price);
                db.SaveChanges();
                this.LoadFrmPrice();
            }
        }
        //Session
        private void btnDeleteS_Click(object sender, EventArgs e)
        {
            var db = new QuanLyPhongTroEntities2();

            if (frmSession.SelectedRows.Count == 1)
            {
                var     row     = frmSession.SelectedRows[0];
                var     cell    = row.Cells["id"];
                int     id      = (int)cell.Value;
                Session session = db.Sessions.Single(st => st.ID == id);
                db.Sessions.Remove(session);
                db.SaveChanges();
                this.LoadFrmSession();
            }
        }
        //
        private void FormEditSession_Load(object sender, EventArgs e)
        {
            var db = new QuanLyPhongTroEntities2();

            this.cboRoomName.DataSource    = db.Rooms.ToList();
            this.cboRoomName.ValueMember   = "id";
            this.cboRoomName.DisplayMember = "RoomName";
            this.cboRoomName.SelectedValue = session.Room.ID;
            this.dtpStart.Value            = session.DateStart;
            this.dtpEnd.Value     = session.DateEnd.Value;
            this.txtDuration.Text = session.Duration.ToString();
            this.txtBill.Text     = session.Total.ToString();
            this.txtName.Text     = session.TenantName;
            this.txtIDN.Text      = session.TenantId;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            string RoomName   = this.txtRoomName.Text;
            int    RoomType   = (int)this.cboRoomType.SelectedValue;
            int    RoomStatus = (int)this.cboRoomStatus.SelectedValue;
            var    db         = new QuanLyPhongTroEntities2();
            Room   room       = new Room();

            room.StatusID = RoomStatus;
            room.RoomName = RoomName;
            room.TypeID   = RoomType;
            db.Rooms.Add(room);
            db.SaveChanges();
            this.Close();
        }
        //Delete funciton for price , room and session

        //Room
        private void btnDELETE_Click(object sender, EventArgs e)
        {
            var db = new QuanLyPhongTroEntities2();

            if (frmRoom.SelectedRows.Count == 1)
            {
                var row  = frmRoom.SelectedRows[0];
                var cell = row.Cells["id"];
                int id   = (int)cell.Value;

                Room room = db.Rooms.Single(st => st.ID == id);
                db.Rooms.Remove(room);
                db.SaveChanges();
                this.LoadFrmRoom();
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string VName = txtVName.Text;
                int    Value = int.Parse(txtValue.Text);
                Price  p     = new Price();
                p.ValueName = VName;
                p.Value     = Value;

                var db = new QuanLyPhongTroEntities2();
                db.Prices.Add(p);
                db.SaveChanges();
                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("please input field :VALUE ");
            }
        }
Beispiel #17
0
        //function for loading data to the Edit Form
        private void FormEditRoom_Load(object sender, EventArgs e)
        {
            QuanLyPhongTroEntities2 db = new QuanLyPhongTroEntities2();

            //loading the DataSource
            this.cboRoomStatus.DataSource = db.RoomStatus.ToList();
            this.cboRoomType.DataSource   = db.Prices.ToList();
            //display the status name into the combobox
            this.cboRoomStatus.ValueMember   = "ID";
            this.cboRoomStatus.DisplayMember = "StatusName";

            //loading current data to combobox /Room Type

            this.cboRoomType.ValueMember   = "ID";
            this.cboRoomType.DisplayMember = "ValueName";
            //
            this.txtRoomName.Text = room.RoomName;
            //loading current data to combobox /Room status
            this.cboRoomStatus.SelectedValue = room.StatusID;
            this.cboRoomType.SelectedValue   = room.TypeID;
        }
 //Save function event
 private void btnSave_Click(object sender, EventArgs e)
 {
     //create var to store the inputed information
     try
     {
         string Name = txtName.Text;
         string ID   = txtIDN.Text;
         string duration;
         txtDuration.Text = (dtpEnd.Value - dtpStart.Value).TotalDays.ToString("#");
         duration         = txtDuration.Text;
         int?     totalday  = int.Parse(duration);
         DateTime dateStart = dtpStart.Value;
         DateTime dateEnd   = dtpEnd.Value;
         //string Bill = txtBill.Text;
         int BillTotal = int.Parse(txtBill.Text);
         int RoomName  = (int)(this.cboRoomName.SelectedValue);
         //create the connect to database
         var     db = new QuanLyPhongTroEntities2();
         Session s  = new Session();
         //storing the data with the new session
         s.DateStart  = dateStart;
         s.DateEnd    = dateEnd;
         s.Duration   = totalday;
         s.TenantId   = ID;
         s.TenantName = Name;
         s.RoomID     = RoomName;
         s.Total      = BillTotal;
         //
         //add the new  session into database
         db.Sessions.Add(s);
         db.SaveChanges();
         this.Close();
     }
     catch (Exception)
     {
         MessageBox.Show("Invalid input : please dont let the field empty");
     }
 }
        private void LoadFrmSession()//Session
        {
            QuanLyPhongTroEntities2 db = new QuanLyPhongTroEntities2();

            this.frmSession.DataSource = db.Sessions.ToList().Select(s => new model.SessionView(s)).ToList();
        }
        private void LoadFrmPrice()//Price
        {
            QuanLyPhongTroEntities2 db = new QuanLyPhongTroEntities2();

            this.frmPrice.DataSource = db.Prices.ToList().Select(p => new model.PriceView(p)).ToList();
        }
        //function to refresh the data after add,edit or delete room after changes
        private void LoadFrmRoom()//Room
        {
            QuanLyPhongTroEntities2 db = new QuanLyPhongTroEntities2();

            this.frmRoom.DataSource = db.Rooms.ToList().Select(r => new model.RoomView(r)).ToList();
        }