コード例 #1
0
        ///<summary>Inserts one EvaluationDef into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(EvaluationDef evaluationDef, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO evaluationdef (";

            if (!useExistingPK && isRandomKeys)
            {
                evaluationDef.EvaluationDefNum = ReplicationServers.GetKeyNoCache("evaluationdef", "EvaluationDefNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "EvaluationDefNum,";
            }
            command += "SchoolCourseNum,EvalTitle,GradingScaleNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(evaluationDef.EvaluationDefNum) + ",";
            }
            command +=
                POut.Long(evaluationDef.SchoolCourseNum) + ","
                + "'" + POut.String(evaluationDef.EvalTitle) + "',"
                + POut.Long(evaluationDef.GradingScaleNum) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                evaluationDef.EvaluationDefNum = Db.NonQ(command, true, "EvaluationDefNum", "evaluationDef");
            }
            return(evaluationDef.EvaluationDefNum);
        }
コード例 #2
0
        /// <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();
        }
コード例 #3
0
        ///<summary>Inserts one EvaluationDef into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(EvaluationDef evaluationDef, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                evaluationDef.EvaluationDefNum = ReplicationServers.GetKey("evaluationdef", "EvaluationDefNum");
            }
            string command = "INSERT INTO evaluationdef (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "EvaluationDefNum,";
            }
            command += "SchoolCourseNum,EvalTitle,GradingScaleNum) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(evaluationDef.EvaluationDefNum) + ",";
            }
            command +=
                POut.Long(evaluationDef.SchoolCourseNum) + ","
                + "'" + POut.String(evaluationDef.EvalTitle) + "',"
                + POut.Long(evaluationDef.GradingScaleNum) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                evaluationDef.EvaluationDefNum = Db.NonQ(command, true, "EvaluationDefNum", "evaluationDef");
            }
            return(evaluationDef.EvaluationDefNum);
        }
コード例 #4
0
 ///<summary>Inserts one EvaluationDef into the database.  Returns the new priKey.</summary>
 public static long Insert(EvaluationDef evaluationDef)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         evaluationDef.EvaluationDefNum = DbHelper.GetNextOracleKey("evaluationdef", "EvaluationDefNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(evaluationDef, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     evaluationDef.EvaluationDefNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(evaluationDef, false));
     }
 }
コード例 #5
0
        ///<summary>Updates one EvaluationDef in the database.</summary>
        public static void Update(EvaluationDef evaluationDef)
        {
            string command = "UPDATE evaluationdef SET "
                             + "SchoolCourseNum =  " + POut.Long(evaluationDef.SchoolCourseNum) + ", "
                             + "EvalTitle       = '" + POut.String(evaluationDef.EvalTitle) + "', "
                             + "GradingScaleNum =  " + POut.Long(evaluationDef.GradingScaleNum) + " "
                             + "WHERE EvaluationDefNum = " + POut.Long(evaluationDef.EvaluationDefNum);

            Db.NonQ(command);
        }
コード例 #6
0
ファイル: EvaluationDefCrud.cs プロジェクト: mnisl/OD
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<EvaluationDef> TableToList(DataTable table){
			List<EvaluationDef> retVal=new List<EvaluationDef>();
			EvaluationDef evaluationDef;
			for(int i=0;i<table.Rows.Count;i++) {
				evaluationDef=new EvaluationDef();
				evaluationDef.EvaluationDefNum= PIn.Long  (table.Rows[i]["EvaluationDefNum"].ToString());
				evaluationDef.SchoolCourseNum = PIn.Long  (table.Rows[i]["SchoolCourseNum"].ToString());
				evaluationDef.EvalTitle       = PIn.String(table.Rows[i]["EvalTitle"].ToString());
				evaluationDef.GradingScaleNum = PIn.Long  (table.Rows[i]["GradingScaleNum"].ToString());
				retVal.Add(evaluationDef);
			}
			return retVal;
		}
コード例 #7
0
        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();
        }
コード例 #8
0
        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();
            }
        }
コード例 #9
0
 ///<summary>Inserts one EvaluationDef into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(EvaluationDef evaluationDef)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(evaluationDef, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             evaluationDef.EvaluationDefNum = DbHelper.GetNextOracleKey("evaluationdef", "EvaluationDefNum");                  //Cacheless method
         }
         return(InsertNoCache(evaluationDef, true));
     }
 }
コード例 #10
0
 ///<summary>Returns true if Update(EvaluationDef,EvaluationDef) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(EvaluationDef evaluationDef, EvaluationDef oldEvaluationDef)
 {
     if (evaluationDef.SchoolCourseNum != oldEvaluationDef.SchoolCourseNum)
     {
         return(true);
     }
     if (evaluationDef.EvalTitle != oldEvaluationDef.EvalTitle)
     {
         return(true);
     }
     if (evaluationDef.GradingScaleNum != oldEvaluationDef.GradingScaleNum)
     {
         return(true);
     }
     return(false);
 }
コード例 #11
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <EvaluationDef> TableToList(DataTable table)
        {
            List <EvaluationDef> retVal = new List <EvaluationDef>();
            EvaluationDef        evaluationDef;

            foreach (DataRow row in table.Rows)
            {
                evaluationDef = new EvaluationDef();
                evaluationDef.EvaluationDefNum = PIn.Long(row["EvaluationDefNum"].ToString());
                evaluationDef.SchoolCourseNum  = PIn.Long(row["SchoolCourseNum"].ToString());
                evaluationDef.EvalTitle        = PIn.String(row["EvalTitle"].ToString());
                evaluationDef.GradingScaleNum  = PIn.Long(row["GradingScaleNum"].ToString());
                retVal.Add(evaluationDef);
            }
            return(retVal);
        }
コード例 #12
0
        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();
        }
コード例 #13
0
        ///<summary>Updates one EvaluationDef in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(EvaluationDef evaluationDef, EvaluationDef oldEvaluationDef)
        {
            string command = "";

            if (evaluationDef.SchoolCourseNum != oldEvaluationDef.SchoolCourseNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SchoolCourseNum = " + POut.Long(evaluationDef.SchoolCourseNum) + "";
            }
            if (evaluationDef.EvalTitle != oldEvaluationDef.EvalTitle)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "EvalTitle = '" + POut.String(evaluationDef.EvalTitle) + "'";
            }
            if (evaluationDef.GradingScaleNum != oldEvaluationDef.GradingScaleNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "GradingScaleNum = " + POut.Long(evaluationDef.GradingScaleNum) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE evaluationdef SET " + command
                      + " WHERE EvaluationDefNum = " + POut.Long(evaluationDef.EvaluationDefNum);
            Db.NonQ(command);
            return(true);
        }
コード例 #14
0
ファイル: EvaluationDefCrud.cs プロジェクト: mnisl/OD
		///<summary>Inserts one EvaluationDef into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(EvaluationDef evaluationDef,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				evaluationDef.EvaluationDefNum=ReplicationServers.GetKey("evaluationdef","EvaluationDefNum");
			}
			string command="INSERT INTO evaluationdef (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="EvaluationDefNum,";
			}
			command+="SchoolCourseNum,EvalTitle,GradingScaleNum) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(evaluationDef.EvaluationDefNum)+",";
			}
			command+=
				     POut.Long  (evaluationDef.SchoolCourseNum)+","
				+"'"+POut.String(evaluationDef.EvalTitle)+"',"
				+    POut.Long  (evaluationDef.GradingScaleNum)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				evaluationDef.EvaluationDefNum=Db.NonQ(command,true);
			}
			return evaluationDef.EvaluationDefNum;
		}
コード例 #15
0
ファイル: EvaluationDefCrud.cs プロジェクト: mnisl/OD
		///<summary>Inserts one EvaluationDef into the database.  Returns the new priKey.</summary>
		public static long Insert(EvaluationDef evaluationDef){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				evaluationDef.EvaluationDefNum=DbHelper.GetNextOracleKey("evaluationdef","EvaluationDefNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(evaluationDef,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							evaluationDef.EvaluationDefNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(evaluationDef,false);
			}
		}
コード例 #16
0
ファイル: EvaluationDefCrud.cs プロジェクト: mnisl/OD
		///<summary>Updates one EvaluationDef in the database.</summary>
		public static void Update(EvaluationDef evaluationDef){
			string command="UPDATE evaluationdef SET "
				+"SchoolCourseNum =  "+POut.Long  (evaluationDef.SchoolCourseNum)+", "
				+"EvalTitle       = '"+POut.String(evaluationDef.EvalTitle)+"', "
				+"GradingScaleNum =  "+POut.Long  (evaluationDef.GradingScaleNum)+" "
				+"WHERE EvaluationDefNum = "+POut.Long(evaluationDef.EvaluationDefNum);
			Db.NonQ(command);
		}
コード例 #17
0
ファイル: EvaluationDefCrud.cs プロジェクト: mnisl/OD
		///<summary>Updates one EvaluationDef in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
		public static bool Update(EvaluationDef evaluationDef,EvaluationDef oldEvaluationDef){
			string command="";
			if(evaluationDef.SchoolCourseNum != oldEvaluationDef.SchoolCourseNum) {
				if(command!=""){ command+=",";}
				command+="SchoolCourseNum = "+POut.Long(evaluationDef.SchoolCourseNum)+"";
			}
			if(evaluationDef.EvalTitle != oldEvaluationDef.EvalTitle) {
				if(command!=""){ command+=",";}
				command+="EvalTitle = '"+POut.String(evaluationDef.EvalTitle)+"'";
			}
			if(evaluationDef.GradingScaleNum != oldEvaluationDef.GradingScaleNum) {
				if(command!=""){ command+=",";}
				command+="GradingScaleNum = "+POut.Long(evaluationDef.GradingScaleNum)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE evaluationdef SET "+command
				+" WHERE EvaluationDefNum = "+POut.Long(evaluationDef.EvaluationDefNum);
			Db.NonQ(command);
			return true;
		}
コード例 #18
0
 public FormEvaluationDefEdit(EvaluationDef evalDefCur)
 {
     InitializeComponent();
     Lan.F(this);
     _evalDefCur = evalDefCur;
 }
コード例 #19
0
 ///<summary>Inserts one EvaluationDef into the database.  Returns the new priKey.</summary>
 public static long Insert(EvaluationDef evaluationDef)
 {
     return(Insert(evaluationDef, false));
 }