protected void btnSave_Click(object sender, EventArgs e)
        {
            AssessmentSystemsDBDataContext db = new AssessmentSystemsDBDataContext();

            var q = (from p in db.Assessments
                     where p.UserName == Session["OtherCarryUserName"]
                     where p.DurationId == Convert.ToInt32(Session["DurationId"])
                     select p).First();

            if (q.Duration.Header == true)
            {
                q.G_CarryWork = Convert.ToInt32(ddHeader.Text);
                lbl_H.Text = q.G_CarryWork.ToString();

                q.D_CarryWork = q.G_CarryWork;
                lbl_D.Text = q.D_CarryWork.ToString();

                db.SubmitChanges();

                lbl_Result.Text = lbl_D.Text;
            }
            else if (q.Duration.Dean == true)
            {
                q.D_CarryWork = Convert.ToInt32(ddDean.SelectedValue);
                lbl_D.Text = q.D_CarryWork.ToString();

                db.SubmitChanges();

                lbl_Result.Text = lbl_D.Text;
            }

            lbl_H.Visible = true;
            lbl_D.Visible = true;

            ddHeader.Visible = false;
            ddDean.Visible = false;
            btnSave.Visible = false;
            btnCancle.Visible = false;
            btnAssess.Visible = true;

            AssessmentCheckComplete ckComplete = new AssessmentCheckComplete();
            ckComplete.CheckComplete(Session["OtherCarryUserName"].ToString(), Convert.ToInt32(Session["DurationId"]));
        }
        public void CheckComplete(string username, int durationid)
        {
            AssessmentSystemsDBDataContext db = new AssessmentSystemsDBDataContext();

            var q = (from p in db.Assessments
                     where p.UserName == username
                     where p.DurationId == durationid
                     select p).First();

            if (q.G_CarryWork != 0 && q.G_Teach != 0 && q.G_Research != 0 && q.G_Service != 0 && q.G_Other != 0 && q.G_Organize != 0 && q.G_SelfDev != 0 && q.G_Professional != 0 && q.G_Communicate != 0 && q.G_TeamWork != 0 && q.G_Mind != 0)
            {
                q.AssessComplete = true;
            }
            else
            {
                q.AssessComplete = false;
            }

            db.SubmitChanges();
        }
        protected void linkBtnHeaderSave_Click(object sender, EventArgs e)
        {
            AssessmentSystemsDBDataContext db = new AssessmentSystemsDBDataContext();

            var q = (from p in db.Assessments
                     where p.UserName == Session["OtherCarryUserName"]
                     where p.DurationId == Convert.ToInt32(Session["DurationId"])
                     select p).First();

            if (rdo5.Checked)
            {
                q.G_Research = 5;
                G_level.InnerText = "ระดับที่ได้ : " + q.G_Research;
            }
            else if (rdo4.Checked)
            {
                q.G_Research = 4;
                G_level.InnerText = "ระดับที่ได้ : " + q.G_Research;
            }
            else if (rdo3.Checked)
            {
                q.G_Research = 3;
                G_level.InnerText = "ระดับที่ได้ : " + q.G_Research;
            }
            else if (rdo2.Checked)
            {
                q.G_Research = 2;
                G_level.InnerText = "ระดับที่ได้ : " + q.G_Research;
            }
            else if (rdo1.Checked)
            {
                q.G_Research = 1;
                G_level.InnerText = "ระดับที่ได้ : " + q.G_Research;
            }
            else
            {
                q.G_Research = 0;
                G_level.InnerText = "ระดับที่ได้ :" + q.G_Research;
            }

            q.ResearchComment = txtHeaderEdit.Text;
            db.SubmitChanges();
            txtHeaderShow.Text = txtHeaderEdit.Text;

            tbHeaderShow.Visible = true;
            tbHeaderEdit.Visible = false;
            tbAssessShow.Visible = true;
            tbAssessEdit.Visible = false;

            AssessmentCheckComplete ckComplete = new AssessmentCheckComplete();
            ckComplete.CheckComplete(Session["OtherCarryUserName"].ToString(), Convert.ToInt32(Session["DurationId"]));
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            String data = hdfMark.Value;

            AssessmentSystemsDBDataContext db = new AssessmentSystemsDBDataContext();

            var q = (from p in db.Assessments
                     where p.UserName == Session["OtherCarryUserName"]
                     where p.DurationId == Convert.ToInt32(Session["DurationId"])
                     select p).First();

            q.Mark_Research = data;
            db.SubmitChanges();

            Response.Redirect("Q_Research.aspx");
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            String data = hdfMark.Value;

            AssessmentSystemsDBDataContext db = new AssessmentSystemsDBDataContext();

            var q = (from p in db.Assessments
                     where p.UserName == username
                     where p.DurationId == durationId
                     select p).First();

            q.Mark_Others = data;
            db.SubmitChanges();

            Response.Redirect("Q_Others.aspx");
        }
        protected void linkBtnSave_Click(object sender, EventArgs e)
        {
            AssessmentSystemsDBDataContext db = new AssessmentSystemsDBDataContext();

            var q = (from p in db.Assessments
                     where p.UserName == Session["UserName"]
                     where p.DurationId == Convert.ToInt32(Session["DurationId"])
                     select p).First();

            q.NewServiceDetail = txtNewDetail.Text;
            db.SubmitChanges();
            txtShowNewDetail.Text = txtNewDetail.Text;
            tbEdit.Visible = false;
            tbShow.Visible = true;
        }
        protected void btnApproveAll_Click(object sender, EventArgs e)
        {
            if (hdfConfirm.Value == "1")
            {
                AssessmentSystemsDBDataContext db = new AssessmentSystemsDBDataContext();

                var q = (from p in db.Assessments
                         where p.DurationId == Convert.ToInt32(Session["DurationId"])
                         where p.User.DeptId == Convert.ToInt32(ddDepartment.SelectedValue)
                         select p).ToList();

                foreach (var item in q)
                {
                    item.AssessApproved = true;
                }

                db.SubmitChanges();

                GridView1.DataBind();

                btnUnApproved.Visible = true;

                btnApproved.Visible = false;
                btnEdit.Visible = false;
            }
            else
            {
                hdfConfirm.Value = "0";
            }
        }