/// <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 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 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();
        }