public void updateAvailableSeatInfo(NewAllotInfo aObj)
        {
            connection.Open();
            SqlDataAdapter sdaob = new SqlDataAdapter("update tbl_roomEntry set available_seat=" + (aObj.availabe_seat - 1) + " where room_no=" + aObj.allot_room_no + "", connection);

            sdaob.SelectCommand.ExecuteNonQuery();
            connection.Close();
            //MessageBox.Show("update successfully.");
        }
        public void saveAllotment(NewAllotInfo aObj)
        {
            connection.Open();
            SqlDataAdapter sda =
                new SqlDataAdapter(
                    "insert into tbl_allot(allot_room_no,stu_id,in_date) values(" + aObj.allot_room_no + "," + aObj.allot_student_id + ",'" + aObj.inDate + "')", connection);

            sda.SelectCommand.ExecuteNonQuery();
            connection.Close();
            MessageBox.Show("save successfully");
        }
        public void saveAllotCheck(NewAllotInfo aObj)
        {
            if (aObj.allot_room_no == -1 || aObj.allot_student_id == -1 || aObj.inDate == "")
            {
                MessageBox.Show("please fill up all properties successfully !!!");
            }
            else
            {
                NewAllotDataAccess dobj = new NewAllotDataAccess();
                dobj.saveAllotment(aObj);

                dobj.updateAvailableSeatInfo(aObj);
            }
        }
        private void saveButton_Click(object sender, EventArgs e)
        {
            NewAllotInfo Obj = new NewAllotInfo()
            {
                inDate = allotInDateTextBox.Text
            };

            //if (allotIdTextBox.Text == "" )
            //{
            //    Obj.allot_id= -1;
            //}
            if (allotRoomNOTextBox.Text == "" || allotStudentIDTextBox.Text == "")
            {
                Obj.allot_room_no = -1;
            }
            //if (allotStudentID.Text == "")
            //{
            //    Obj.allot_student_id = -1;
            //}
            else
            {
                //Obj.allot_id = Convert.ToInt32(allotIdTextBox.Text);
                Obj.allot_room_no    = Convert.ToInt32(allotRoomNOTextBox.Text);
                Obj.allot_student_id = Convert.ToInt32(allotStudentIDTextBox.Text);
                Obj.availabe_seat    = Convert.ToInt32(allotAvailableSeatTextBox.Text);
            }

            NewAllotCheck ob = new NewAllotCheck();

            ob.saveAllotCheck(Obj);

            allotRoomNOTextBox.Clear();
            allotStudentIDTextBox.Clear();
            allotAvailableSeatTextBox.Clear();
            allotInDateTextBox.Clear();

            NewAllotDataAccess dataAc   = new NewAllotDataAccess();
            List <StudentInfo> students = dataAc.viewNotAllotStudentInfo();

            studentNotAllotDataGridView.AutoGenerateColumns = false;
            studentNotAllotDataGridView.DataSource          = students;


            NewAllotDataAccess dataAccess = new NewAllotDataAccess();
            List <RoomInfo>    rooms      = dataAccess.viewRoomNotFillUpInfo();

            roomNotFillUPDataGridView.AutoGenerateColumns = false;
            roomNotFillUPDataGridView.DataSource          = rooms;
        }