private void FillGrid()
        {
            long courseNum = 0;

            if (comboCourse.SelectedIndex != 0)
            {
                courseNum = _listSchoolCourses[comboCourse.SelectedIndex - 1].SchoolCourseNum;
            }
            DataTable table = EvaluationDefs.GetAllByCourse(courseNum);

            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableEvaluationSetup", "Course"), 100);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableEvaluationSetup", "Evaluation Title"), 180);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(table.Rows[i]["CourseID"].ToString());
                row.Cells.Add(table.Rows[i]["EvalTitle"].ToString());
                row.Tag = table.Rows[i]["EvaluationDefNum"].ToString();
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
 private void butOK_Click(object sender, EventArgs e)
 {
     if (_evalDefCur.SchoolCourseNum == 0)
     {
         MsgBox.Show(this, "A school course must be selected for this evaluation def before it can be saved.");
         return;
     }
     if (_evalDefCur.GradingScaleNum == 0)
     {
         MsgBox.Show(this, "A grading scale must be selected for this evaluation def before it can be saved.");
         return;
     }
     if (!String.IsNullOrWhiteSpace(_evalDefCur.EvalTitle) &&
         _evalDefCur.EvalTitle != textTitle.Text &&
         !MsgBox.Show(this, MsgBoxButtons.YesNo, "Changing the EvaluationDef titles during a term could interfere with grading reports.  Continue?"))
     {
         return;
     }
     _evalDefCur.EvalTitle = textTitle.Text;
     EvaluationDefs.Update(_evalDefCur);
     for (int i = 0; i < _criterionDefsForEval.Count; i++)
     {
         _criterionDefsForEval[i].ItemOrder = i;
         EvaluationCriterionDefs.Update(_criterionDefsForEval[i]);
     }
     DialogResult = DialogResult.OK;
 }
        /// <summary>The selected Def from the grid will be copied into a brand new Evaluation and saved to the DB. This includes all EvaluationCriterion as well. Used when creating a new Evaluation.</summary>
        private void CopyDefToEvaluation()
        {
            EvaluationDef evalDef = EvaluationDefs.GetOne(PIn.Long(gridMain.Rows[gridMain.GetSelectedIndex()].Tag.ToString()));
            Evaluation    evalNew = new Evaluation();

            evalNew.DateEval        = DateTime.Today;
            evalNew.EvalTitle       = evalDef.EvalTitle;
            evalNew.GradingScaleNum = evalDef.GradingScaleNum;
            evalNew.InstructNum     = Security.CurUser.ProvNum;
            evalNew.SchoolCourseNum = evalDef.SchoolCourseNum;
            evalNew.EvaluationNum   = Evaluations.Insert(evalNew);
            List <EvaluationCriterionDef> evalCritDefs = EvaluationCriterionDefs.GetAllForEvaluationDef(evalDef.EvaluationDefNum);
            EvaluationCriterion           evalCrit;

            for (int i = 0; i < evalCritDefs.Count; i++)
            {
                evalCrit = new EvaluationCriterion();
                evalCrit.CriterionDescript = evalCritDefs[i].CriterionDescript;
                evalCrit.EvaluationNum     = evalNew.EvaluationNum;
                evalCrit.GradingScaleNum   = evalCritDefs[i].GradingScaleNum;
                evalCrit.IsCategoryName    = evalCritDefs[i].IsCategoryName;
                evalCrit.ItemOrder         = evalCritDefs[i].ItemOrder;
                evalCrit.MaxPointsPoss     = evalCritDefs[i].MaxPointsPoss;
                EvaluationCriterions.Insert(evalCrit);
            }
            evalNew.IsNew = true;
            FormEvaluationEdit FormEE = new FormEvaluationEdit(evalNew);

            FormEE.ShowDialog();
        }
 private void butCancel_Click(object sender, EventArgs e)
 {
     if (_evalDefCur.IsNew)
     {
         EvaluationDefs.Delete(_evalDefCur.EvaluationDefNum);
     }
     DialogResult = DialogResult.Cancel;
 }
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (_evalDefCur.IsNew || MsgBox.Show(this, MsgBoxButtons.YesNo, "This will delete the evaluation def.  Continue?"))
     {
         EvaluationDefs.Delete(_evalDefCur.EvaluationDefNum);
         DialogResult = DialogResult.Cancel;
     }
 }
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            if (IsSelectionMode)
            {
                CopyDefToEvaluation();
                DialogResult = DialogResult.OK;
                return;
            }
            EvaluationDef         evalDef = EvaluationDefs.GetOne(PIn.Long(gridMain.Rows[gridMain.GetSelectedIndex()].Tag.ToString()));
            FormEvaluationDefEdit FormEDE = new FormEvaluationDefEdit(evalDef);

            FormEDE.ShowDialog();
            FillGrid();
        }
        private void butAdd_Click(object sender, EventArgs e)
        {
            EvaluationDef evalDef = new EvaluationDef();

            evalDef.IsNew            = true;
            evalDef.EvaluationDefNum = EvaluationDefs.Insert(evalDef);
            FormEvaluationDefEdit FormEDE = new FormEvaluationDefEdit(evalDef);

            FormEDE.ShowDialog();
            if (FormEDE.DialogResult == DialogResult.OK)
            {
                FillGrid();
            }
        }
        private void butDuplicate_Click(object sender, EventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select an evaluation to duplicate");
                return;
            }
            //Creates a full copy of the EvaluationDef including all EvaluationCriterionDefs.
            EvaluationDef evalDefOld = EvaluationDefs.GetOne(PIn.Long(gridMain.Rows[gridMain.GetSelectedIndex()].Tag.ToString()));
            EvaluationDef evalDefNew = evalDefOld.Copy();

            evalDefNew.EvalTitle       += "-copy";
            evalDefNew.EvaluationDefNum = EvaluationDefs.Insert(evalDefNew);
            List <EvaluationCriterionDef> listCritDefs = EvaluationCriterionDefs.GetAllForEvaluationDef(evalDefOld.EvaluationDefNum);

            for (int i = 0; i < listCritDefs.Count; i++)
            {
                EvaluationCriterionDef critDefCopy = listCritDefs[i].Copy();
                critDefCopy.EvaluationDefNum = evalDefNew.EvaluationDefNum;
                EvaluationCriterionDefs.Insert(critDefCopy);
            }
            FillGrid();
        }