protected void btnSaveSupervision_Click(object sender, EventArgs e)
        {
            try
            {
                var q = (from p in db.Supervisions
                            where p.UserName == username
                            where p.DurationId == dm.getDurationId()
                            where p.SupervisionTypeId == Convert.ToInt32(ddSupervisionType.SelectedValue)
                            select p).First();

                q.StudentCount += Convert.ToInt32(txtStudentCount.Text);
                db.SubmitChanges();

            }
            catch (Exception)
            {
                Supervision spv = new Supervision();

                spv.UserName = username;
                spv.DurationId = dm.getDurationId();

                spv.SupervisionTypeId = Convert.ToInt32(ddSupervisionType.SelectedValue);
                spv.StudentCount = Convert.ToInt32(txtStudentCount.Text);
                spv.Description = txtDesc.Text;

                db.Supervisions.InsertOnSubmit(spv);
                db.SubmitChanges();
            }
        }
        //************************************************************************************************************************
        protected void ASPxGridView2_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            Supervision sp = new Supervision();

            sp.SupervisionId = Convert.ToInt32(((HiddenField)ASPxGridView2.FindEditRowCellTemplateControl((GridViewDataColumn)ASPxGridView2.Columns["StudentCount"], "hidEditId")).Value);
            sp.StudentCount = Convert.ToInt32(((ASPxSpinEdit)ASPxGridView2.FindEditRowCellTemplateControl((GridViewDataColumn)ASPxGridView2.Columns["StudentCount"], "txtEditStudentCount")).Text);

            dll_DirectTeach_Supervision dt = new dll_DirectTeach_Supervision(username, dr.getDurationId());
            dt.updateData(sp);
            this.ASPxGridView2.CancelEdit();
            e.Cancel = true;
            FillGridView2();
        }
        protected void ASPxGridView2_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            Supervision sp = new Supervision();

            sp.UserName = username;
            sp.DurationId = dr.getDurationId();

            sp.StudentCount = Convert.ToInt32(((ASPxSpinEdit)ASPxGridView2.FindEditRowCellTemplateControl((GridViewDataColumn)ASPxGridView2.Columns["StudentCount"], "txtEditStudentCount")).Text);
            sp.SupervisionTypeId = 1;

            dll_DirectTeach_Supervision dt = new dll_DirectTeach_Supervision(username, dr.getDurationId());
            dt.insertData(sp);
            e.Cancel = true;
            ASPxGridView2.CancelEdit();
            FillGridView2();
        }
 partial void DeleteSupervision(Supervision instance);
 partial void UpdateSupervision(Supervision instance);
 partial void InsertSupervision(Supervision instance);
		private void detach_Supervisions(Supervision entity)
		{
			this.SendPropertyChanging();
			entity.SupervisionType = null;
		}
		private void detach_Supervisions(Supervision entity)
		{
			this.SendPropertyChanging();
			entity.DurationDirectTeach = null;
		}