Ejemplo n.º 1
0
 private void butDelete_Click(object sender, System.EventArgs e)
 {
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
     }
     else
     {
         string inuseby = ReqStudents.InUseBy(ReqCur.ReqNeededNum);
         if (inuseby != "")
         {
             MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(Lan.g(this, "Requirement is already in use by student(s) with grade point(s) attached."
                                                                + "\r\n" + Lan.g(this, "Delete anyway?  Student grades will not be affected."))
                                                          + "\r\n" + inuseby);
             msgBox.ShowDialog();
             if (msgBox.DialogResult != DialogResult.OK)
             {
                 return;
             }
         }
         if (!MsgBox.Show(this, true, "Delete this Requirement?"))
         {
             return;
         }
     }
     ReqCur       = null;
     DialogResult = DialogResult.OK;
 }
Ejemplo n.º 2
0
 ///<summary>Inserts one ReqNeeded into the database.  Returns the new priKey.</summary>
 internal static long Insert(ReqNeeded reqNeeded)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         reqNeeded.ReqNeededNum=DbHelper.GetNextOracleKey("reqneeded","ReqNeededNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(reqNeeded,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     reqNeeded.ReqNeededNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(reqNeeded,false);
     }
 }
Ejemplo n.º 3
0
        ///<summary>Inserts one ReqNeeded into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(ReqNeeded reqNeeded, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                reqNeeded.ReqNeededNum = ReplicationServers.GetKey("reqneeded", "ReqNeededNum");
            }
            string command = "INSERT INTO reqneeded (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "ReqNeededNum,";
            }
            command += "Descript,SchoolCourseNum,SchoolClassNum) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(reqNeeded.ReqNeededNum) + ",";
            }
            command +=
                "'" + POut.String(reqNeeded.Descript) + "',"
                + POut.Long(reqNeeded.SchoolCourseNum) + ","
                + POut.Long(reqNeeded.SchoolClassNum) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                reqNeeded.ReqNeededNum = Db.NonQ(command, true);
            }
            return(reqNeeded.ReqNeededNum);
        }
Ejemplo n.º 4
0
        ///<summary></summary>
        public static void Insert(ReqNeeded req)
        {
            if (PrefB.RandomKeys)
            {
                req.ReqNeededNum = MiscData.GetKey("reqneeded", "ReqNeededNum");
            }
            string command = "INSERT INTO reqneeded (";

            if (PrefB.RandomKeys)
            {
                command += "ReqNeededNum,";
            }
            command += "Descript,SchoolCourseNum,SchoolClassNum) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(req.ReqNeededNum) + "', ";
            }
            command +=
                "'" + POut.PString(req.Descript) + "', "
                + "'" + POut.PInt(req.SchoolCourseNum) + "', "
                + "'" + POut.PInt(req.SchoolClassNum) + "')";
            if (PrefB.RandomKeys)
            {
                General.NonQ(command);
            }
            else
            {
                req.ReqNeededNum = General.NonQ(command, true);
            }
        }
Ejemplo n.º 5
0
        ///<summary>Inserts one ReqNeeded into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(ReqNeeded reqNeeded, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO reqneeded (";

            if (!useExistingPK && isRandomKeys)
            {
                reqNeeded.ReqNeededNum = ReplicationServers.GetKeyNoCache("reqneeded", "ReqNeededNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "ReqNeededNum,";
            }
            command += "Descript,SchoolCourseNum,SchoolClassNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(reqNeeded.ReqNeededNum) + ",";
            }
            command +=
                "'" + POut.String(reqNeeded.Descript) + "',"
                + POut.Long(reqNeeded.SchoolCourseNum) + ","
                + POut.Long(reqNeeded.SchoolClassNum) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                reqNeeded.ReqNeededNum = Db.NonQ(command, true, "ReqNeededNum", "reqNeeded");
            }
            return(reqNeeded.ReqNeededNum);
        }
Ejemplo n.º 6
0
 ///<summary>Inserts one ReqNeeded into the database.  Returns the new priKey.</summary>
 internal static long Insert(ReqNeeded reqNeeded)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         reqNeeded.ReqNeededNum = DbHelper.GetNextOracleKey("reqneeded", "ReqNeededNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(reqNeeded, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     reqNeeded.ReqNeededNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(reqNeeded, false));
     }
 }
Ejemplo n.º 7
0
 ///<summary>Inserts one ReqNeeded into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(ReqNeeded reqNeeded,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         reqNeeded.ReqNeededNum=ReplicationServers.GetKey("reqneeded","ReqNeededNum");
     }
     string command="INSERT INTO reqneeded (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="ReqNeededNum,";
     }
     command+="Descript,SchoolCourseNum,SchoolClassNum) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(reqNeeded.ReqNeededNum)+",";
     }
     command+=
          "'"+POut.String(reqNeeded.Descript)+"',"
         +    POut.Long  (reqNeeded.SchoolCourseNum)+","
         +    POut.Long  (reqNeeded.SchoolClassNum)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         reqNeeded.ReqNeededNum=Db.NonQ(command,true);
     }
     return reqNeeded.ReqNeededNum;
 }
Ejemplo n.º 8
0
        ///<summary></summary>
        public static void Update(ReqNeeded req)
        {
            string command = "UPDATE reqneeded SET "
                             + "Descript = '" + POut.PString(req.Descript) + "'"
                             + ",SchoolCourseNum = '" + POut.PInt(req.SchoolCourseNum) + "'"
                             + ",SchoolClassNum = '" + POut.PInt(req.SchoolClassNum) + "'"
                             + " WHERE ReqNeededNum = '" + POut.PInt(req.ReqNeededNum) + "'";

            General.NonQ(command);
        }
Ejemplo n.º 9
0
        ///<summary>Updates one ReqNeeded in the database.</summary>
        internal static void Update(ReqNeeded reqNeeded)
        {
            string command = "UPDATE reqneeded SET "
                             + "Descript       = '" + POut.String(reqNeeded.Descript) + "', "
                             + "SchoolCourseNum=  " + POut.Long(reqNeeded.SchoolCourseNum) + ", "
                             + "SchoolClassNum =  " + POut.Long(reqNeeded.SchoolClassNum) + " "
                             + "WHERE ReqNeededNum = " + POut.Long(reqNeeded.ReqNeededNum);

            Db.NonQ(command);
        }
Ejemplo n.º 10
0
 private bool RemoveReqFromAllList(ReqNeeded req)
 {
     for (int i = 0; i < _listReqsAll.Count; i++)
     {
         if (_listReqsAll[i].ReqNeededNum == req.ReqNeededNum)
         {
             _listReqsAll.RemoveAt(i);
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 11
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<ReqNeeded> TableToList(DataTable table){
			List<ReqNeeded> retVal=new List<ReqNeeded>();
			ReqNeeded reqNeeded;
			for(int i=0;i<table.Rows.Count;i++) {
				reqNeeded=new ReqNeeded();
				reqNeeded.ReqNeededNum   = PIn.Long  (table.Rows[i]["ReqNeededNum"].ToString());
				reqNeeded.Descript       = PIn.String(table.Rows[i]["Descript"].ToString());
				reqNeeded.SchoolCourseNum= PIn.Long  (table.Rows[i]["SchoolCourseNum"].ToString());
				reqNeeded.SchoolClassNum = PIn.Long  (table.Rows[i]["SchoolClassNum"].ToString());
				retVal.Add(reqNeeded);
			}
			return retVal;
		}
Ejemplo n.º 12
0
 ///<summary>Inserts one ReqNeeded into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ReqNeeded reqNeeded)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(reqNeeded, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             reqNeeded.ReqNeededNum = DbHelper.GetNextOracleKey("reqneeded", "ReqNeededNum");                  //Cacheless method
         }
         return(InsertNoCache(reqNeeded, true));
     }
 }
Ejemplo n.º 13
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <ReqNeeded> TableToList(DataTable table)
        {
            List <ReqNeeded> retVal = new List <ReqNeeded>();
            ReqNeeded        reqNeeded;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                reqNeeded = new ReqNeeded();
                reqNeeded.ReqNeededNum    = PIn.Long(table.Rows[i]["ReqNeededNum"].ToString());
                reqNeeded.Descript        = PIn.String(table.Rows[i]["Descript"].ToString());
                reqNeeded.SchoolCourseNum = PIn.Long(table.Rows[i]["SchoolCourseNum"].ToString());
                reqNeeded.SchoolClassNum  = PIn.Long(table.Rows[i]["SchoolClassNum"].ToString());
                retVal.Add(reqNeeded);
            }
            return(retVal);
        }
Ejemplo n.º 14
0
 ///<summary>Returns true if Update(ReqNeeded,ReqNeeded) 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(ReqNeeded reqNeeded, ReqNeeded oldReqNeeded)
 {
     if (reqNeeded.Descript != oldReqNeeded.Descript)
     {
         return(true);
     }
     if (reqNeeded.SchoolCourseNum != oldReqNeeded.SchoolCourseNum)
     {
         return(true);
     }
     if (reqNeeded.SchoolClassNum != oldReqNeeded.SchoolClassNum)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 15
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ReqNeeded> TableToList(DataTable table)
        {
            List <ReqNeeded> retVal = new List <ReqNeeded>();
            ReqNeeded        reqNeeded;

            foreach (DataRow row in table.Rows)
            {
                reqNeeded = new ReqNeeded();
                reqNeeded.ReqNeededNum    = PIn.Long(row["ReqNeededNum"].ToString());
                reqNeeded.Descript        = PIn.String(row["Descript"].ToString());
                reqNeeded.SchoolCourseNum = PIn.Long(row["SchoolCourseNum"].ToString());
                reqNeeded.SchoolClassNum  = PIn.Long(row["SchoolClassNum"].ToString());
                retVal.Add(reqNeeded);
            }
            return(retVal);
        }
Ejemplo n.º 16
0
        public static ReqNeeded GetReq(int reqNeededNum)
        {
            string    command = "SELECT * FROM reqneeded WHERE ReqNeededNum=" + POut.PInt(reqNeededNum);
            DataTable table   = General.GetTable(command);

            if (table.Rows.Count == 0)
            {
                return(null);
            }
            ReqNeeded req = new ReqNeeded();

            //for(int i=0;i<table.Rows.Count;i++){
            req.ReqNeededNum    = PIn.PInt(table.Rows[0][0].ToString());
            req.Descript        = PIn.PString(table.Rows[0][1].ToString());
            req.SchoolCourseNum = PIn.PInt(table.Rows[0][2].ToString());
            req.SchoolClassNum  = PIn.PInt(table.Rows[0][3].ToString());
            return(req);
        }
Ejemplo n.º 17
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            FormReqNeededEdit FormR = new FormReqNeededEdit();

            FormR.ReqCur = _listReqsInGrid[e.Row];          //Previously got from the database but we want the copy from the list
            FormR.ShowDialog();
            if (FormR.DialogResult == DialogResult.OK)
            {
                if (FormR.ReqCur == null)
                {
                    RemoveReqFromAllList(_listReqsInGrid[gridMain.GetSelectedIndex()]);
                }
                else
                {
                    ReqNeeded reqNeeded = _listReqsAll.FirstOrDefault(x => x.ReqNeededNum == FormR.ReqCur.ReqNeededNum);
                    if (reqNeeded != null)                     //This should never be null.
                    {
                        reqNeeded = FormR.ReqCur;
                    }
                }
                FillGrid();
            }
        }
Ejemplo n.º 18
0
 private void butCopy_Click(object sender, EventArgs e)
 {
     if (comboClassTo.SelectedIndex == -1 || comboCourseTo.SelectedIndex == -1)
     {
         MsgBox.Show(this, "Please select a Class and Course first.");
         return;
     }
     if (MsgBox.Show(this, MsgBoxButtons.OKCancel, "Are you sure you would like to copy over the requirements? Doing so will not replace any previous requirements."))
     {
         long schoolClassFrom  = _listSchoolClasses[comboClassFrom.SelectedIndex].SchoolClassNum;
         long schoolClassTo    = _listSchoolClasses[comboClassTo.SelectedIndex].SchoolClassNum;
         long schoolCourseFrom = _listSchoolCourses[comboCourseFrom.SelectedIndex].SchoolCourseNum;
         long schoolCourseTo   = _listSchoolCourses[comboCourseTo.SelectedIndex].SchoolCourseNum;
         if (schoolClassFrom == schoolClassTo && schoolCourseFrom == schoolCourseTo)
         {
             return;
         }
         ReqNeeded reqCur;
         for (int i = 0; i < _listReqsInGrid.Count; i++)
         {
             reqCur                 = new ReqNeeded();
             reqCur.Descript        = _listReqsInGrid[i].Descript;
             reqCur.SchoolClassNum  = schoolClassTo;
             reqCur.SchoolCourseNum = schoolCourseTo;
             if (_listReqsAll.Any(x => x.Descript == reqCur.Descript &&              //Alternative to LINQ would be to create a method and loop through the whole list
                                  x.SchoolClassNum == reqCur.SchoolClassNum &&
                                  x.SchoolCourseNum == reqCur.SchoolCourseNum))
             {
                 continue;
             }
             _listReqsAll.Add(reqCur);
         }
         comboClassFrom.SelectedIndex  = comboClassTo.SelectedIndex;
         comboCourseFrom.SelectedIndex = comboCourseTo.SelectedIndex;
         FillGrid();
     }
 }
Ejemplo n.º 19
0
        ///<summary>Updates one ReqNeeded 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(ReqNeeded reqNeeded, ReqNeeded oldReqNeeded)
        {
            string command = "";

            if (reqNeeded.Descript != oldReqNeeded.Descript)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Descript = '" + POut.String(reqNeeded.Descript) + "'";
            }
            if (reqNeeded.SchoolCourseNum != oldReqNeeded.SchoolCourseNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SchoolCourseNum = " + POut.Long(reqNeeded.SchoolCourseNum) + "";
            }
            if (reqNeeded.SchoolClassNum != oldReqNeeded.SchoolClassNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SchoolClassNum = " + POut.Long(reqNeeded.SchoolClassNum) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE reqneeded SET " + command
                      + " WHERE ReqNeededNum = " + POut.Long(reqNeeded.ReqNeededNum);
            Db.NonQ(command);
            return(true);
        }
Ejemplo n.º 20
0
		///<summary>Updates one ReqNeeded 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(ReqNeeded reqNeeded,ReqNeeded oldReqNeeded){
			string command="";
			if(reqNeeded.Descript != oldReqNeeded.Descript) {
				if(command!=""){ command+=",";}
				command+="Descript = '"+POut.String(reqNeeded.Descript)+"'";
			}
			if(reqNeeded.SchoolCourseNum != oldReqNeeded.SchoolCourseNum) {
				if(command!=""){ command+=",";}
				command+="SchoolCourseNum = "+POut.Long(reqNeeded.SchoolCourseNum)+"";
			}
			if(reqNeeded.SchoolClassNum != oldReqNeeded.SchoolClassNum) {
				if(command!=""){ command+=",";}
				command+="SchoolClassNum = "+POut.Long(reqNeeded.SchoolClassNum)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE reqneeded SET "+command
				+" WHERE ReqNeededNum = "+POut.Long(reqNeeded.ReqNeededNum);
			Db.NonQ(command);
			return true;
		}
Ejemplo n.º 21
0
		///<summary>Updates one ReqNeeded in the database.</summary>
		public static void Update(ReqNeeded reqNeeded){
			string command="UPDATE reqneeded SET "
				+"Descript       = '"+POut.String(reqNeeded.Descript)+"', "
				+"SchoolCourseNum=  "+POut.Long  (reqNeeded.SchoolCourseNum)+", "
				+"SchoolClassNum =  "+POut.Long  (reqNeeded.SchoolClassNum)+" "
				+"WHERE ReqNeededNum = "+POut.Long(reqNeeded.ReqNeededNum);
			Db.NonQ(command);
		}
Ejemplo n.º 22
0
 ///<summary>Inserts one ReqNeeded into the database.  Returns the new priKey.</summary>
 public static long Insert(ReqNeeded reqNeeded)
 {
     return(Insert(reqNeeded, false));
 }