コード例 #1
0
        //

        //
        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");
            }
        }
コード例 #2
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();
        }
コード例 #3
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();
        }
コード例 #4
0
        //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();
            }
        }
コード例 #5
0
        //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();
            }
        }
コード例 #6
0
        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();
        }
コード例 #7
0
        //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();
            }
        }
コード例 #8
0
        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 ");
            }
        }
コード例 #9
0
 //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");
     }
 }