public List <string> GetElective(string sCollege, string sDegree, string sMajor, int iOrder, InitializeModule.EnumCampus Campus) { Connection_StringCLS myConnection_String = new Connection_StringCLS(Campus); SqlConnection Conn = new SqlConnection(myConnection_String.Conn_string); Conn.Open(); SqlCommand Cmd; SqlDataReader Rd; List <string> Result = new List <string>(); try { string sElectSQL = "SELECT sEelecive FROM dbo.Reg_Specialization_Elective AS E"; sElectSQL += " WHERE sMajor ='" + sMajor + "' AND sDegree='" + sDegree + "' AND sCollege ='" + sCollege + "' AND intOrder =" + iOrder; Cmd = new SqlCommand(sElectSQL, Conn); Rd = Cmd.ExecuteReader(); while (Rd.Read()) { Result.Add(Rd["sEelecive"].ToString()); } Rd.Close(); } catch (Exception ex) { Console.WriteLine("{0} Exception caught.", ex.Message); } finally { Conn.Close(); Conn.Dispose(); } return(Result); }
public override string ToString() { var sb = new StringBuilder("DoItNow_args("); int tmp193 = 0; if ((Rd != null) && __isset.rd) { if (0 < tmp193++) { sb.Append(", "); } sb.Append("Rd: "); Rd.ToString(sb); } if (__isset.mitDefault) { if (0 < tmp193++) { sb.Append(", "); } sb.Append("MitDefault: "); MitDefault.ToString(sb); } sb.Append(')'); return(sb.ToString()); }
public ITripOffer CreateTemporaryTripOffer() { ITravelAgency travelAgency = TravelAgencies[Rd.Next(0, TravelAgencies.Count)]; IPhoto[] photos = new IPhoto[NumberOfPhotos]; for (int i = 0; i < NumberOfPhotos; ++i) { photos[i] = travelAgency.CreatePhoto(); } return(new GraphicTemporaryTripOffer(travelAgency.CreateTrip(), ViewLimit, photos)); }
public ITripOffer CreateTemporaryTripOffer() { ITravelAgency travelAgency = TravelAgencies[Rd.Next(0, TravelAgencies.Count)]; IReview[] reviews = new IReview[NumberOfReviews]; for (int i = 0; i < NumberOfReviews; ++i) { reviews[i] = travelAgency.CreateReview(); } return(new TextTemporaryTripOffer(travelAgency.CreateTrip(), ViewLimit, reviews)); }
//-------------------------------------------------------------------- private void EmtsIniGtb(int Ei) { int k; double Rr, xx, x; CElement ei = Ev[Ei]; Rr = Rb * Rb; do { xx = 0D; for (k = 0; k < Rn; k++) { ei.X[k] = x = Rb * 2D * (Rd.NextDouble() - 0.5D); xx += x * x; } }while (xx >= Rr); }//Set random coordinates of Ex element within bound
public object GetResult(string Strsql, bool IsStoredProcedure = false, ArrayList pa = null, ArrayList pv = null) { SqlConnection con = new SqlConnection(); try { object Result; con.ConnectionString = this.ConnectionString; con.Open(); SqlDataReader Rd; SqlCommand cmd = new SqlCommand(Strsql, con); if (IsStoredProcedure == true) { cmd.CommandType = CommandType.StoredProcedure; for (int count = 0; count < pa.Count; count++) { // pa[count] = pv[count]; cmd.Parameters.AddWithValue(pa[count].ToString(), pv[count]); } } Rd = cmd.ExecuteReader(); Rd.Read(); if (Rd.HasRows) { Result = Rd[0]; } else { Result = ""; } con.Close(); return(Result); } catch (Exception ex) { throw ex; return(null); } //Added by nisha finally { if (con.State.Equals("Open")) { con.Close(); } con.Dispose(); } }
CElement[] Ev; //Elements container //-------------------------------------------------------------------- private void EmtsIni() { //Allocate resources try { Ev = new CElement[En]; for (int i = 0; i < En; i++) { Ev[i] = new CElement(); } } catch (Exception e) { e.Source = "EmtsIni"; Ev = null; return; } //Allocate resources for (int i = 0; i < En; i++) { if (Ev[i].Dim(Rn)) { //throw exeption Ev = null; return; } } //init elements for (int i = 0; i < En; i++) { //Set Radius of element Ev[i].R = Re * (1D + 0.01 * dR * 2D * (Rd.NextDouble() - 0.5D)); //Set mass Ev[i].M = Vgamma(Rn); for (int k = 0; k < Rn; k++) { Ev[i].M *= Ev[i].R; } //Set coordinates, random value EmtsIniGtb(i); //set speed, random value double V = 1D / Math.Sqrt(Rn * Ev[i].M); for (int k = 0; k < Rn; k++) { Ev[i].V[k] = V * 2D * (Rd.NextDouble() - 0.5D); } } }
/// <summary> /// 生成指定范围内的不重复随机数 /// </summary> /// <param name="count">随机数个数</param> /// <param name="minNum">随机数下限(随机数可以取该下界值)</param> /// <param name="maxNum">随机数上限(随机数不能取该上界值)</param> /// <returns></returns> public static int[] RandomMultiple(int count, int minNum, int maxNum) { int[] result = new int[count]; #if true //方法2:利用Hashtable。 if (maxNum >= minNum) { Hashtable hashtable = new Hashtable(); for (int i = 0; hashtable.Count < count; i++) { int nValue = Random.Next(minNum, maxNum); if (!hashtable.ContainsValue(nValue)) { result[hashtable.Count] = nValue; hashtable.Add(nValue, nValue); } } } #else //方法1:思想是用一个数组来保存索引号,先随机生成一个数组位置,然后把随机抽取到的位置的索引号取出来,并把最后一个索引号复制到当前的数组位置,然后使随机数的上限减一,具体如:先把这100个数放在一个数组内,每次随机取一个位置(第一次是1-100,第二次是1-99,...),将该位置的数用最后的数代替。 int j; for (j = 0; j < count; j++) { int i = Rd.Next(minNum, maxNum); int num = 0; for (int k = 0; k < j; k++) { if (result[k] == i) { num = num + 1; } } if (num == 0) { result[j] = i; } else { j = j - 1; } } #endif return(result); }
public List <int> GetPrerequisiteofElectiveCourse(string sCollege, string sDegree, string sMajor, string sCourse, InitializeModule.EnumCampus Campus) { Connection_StringCLS myConnection_String = new Connection_StringCLS(Campus); SqlConnection Conn = new SqlConnection(myConnection_String.Conn_string); Conn.Open(); SqlCommand Cmd; SqlDataReader Rd; List <int> Result = new List <int>(); try { string sPreSQL = "SELECT PSC.byteOrder"; sPreSQL += " FROM dbo.Reg_Prerequisites AS P INNER JOIN"; sPreSQL += " dbo.Reg_Specialization_Courses AS PSC ON P.strCollege = PSC.strCollege "; sPreSQL += " AND P.strDegree = PSC.strDegree AND P.strSpecialization = PSC.strSpecialization "; sPreSQL += " AND P.strPrerequisite = PSC.strCourse"; sPreSQL += " WHERE (P.strCollege = '" + sCollege + "')"; sPreSQL += " AND (P.strDegree = '" + sDegree + "') "; sPreSQL += " AND (P.strSpecialization = '" + sMajor + "')"; sPreSQL += " AND (P.strCourse = '" + sCourse + "')"; sPreSQL += " Order by PSC.byteOrder"; Cmd = new SqlCommand(sPreSQL, Conn); Rd = Cmd.ExecuteReader(); while (Rd.Read()) { Result.Add(int.Parse(Rd["byteOrder"].ToString())); } Rd.Close(); } catch (Exception ex) { Console.WriteLine("{0} Exception caught.", ex.Message); } finally { Conn.Close(); Conn.Dispose(); } return(Result); }
public SqlDataReader CreateReader(string Strsql, bool IsStoredProcedure = false, ArrayList pa = null, ArrayList pv = null) { try { SqlConnection con = new SqlConnection(); con.ConnectionString = this.ConnectionString; con.Open(); SqlDataReader Rd; SqlCommand cmd = new SqlCommand(Strsql, con); if (IsStoredProcedure == true) { cmd.CommandType = CommandType.StoredProcedure; for (int count = 0; count < pa.Count; count++) { // pa[count] = pv[count]; cmd.Parameters.AddWithValue(pa[count].ToString(), pv[count]); } } Rd = cmd.ExecuteReader(); Rd.Read(); if (Rd.HasRows) { return(Rd); } else { return(null); con.Close(); } } catch (Exception ex) { return(null); throw ex; } }
public static sbyte Read(this sbyte x, Rd rd) { return rd.ReadSByte(); }
public static short Read(this short x, Rd rd) { return rd.ReadInt16(); }
public abstract object Read(Rd rd);
public static Int Read(Int val, Rd rd) { return rd.ReadInt32(); }
public static string Read(this string x, Rd rd) { return rd.ReadString(); }
public override object Read(Rd rd) { return rd.ReadSingle(); }
public static float Read(this float x, Rd rd) { return(rd.ReadSingle()); }
public static double Read(this double x, Rd rd) { return rd.ReadDouble(); }
public static ulong Read(this ulong x, Rd rd) { return(rd.ReadUInt64()); }
public static long Read(this long x, Rd rd) { return(rd.ReadInt64()); }
public override object Read(Rd rd) { return rd.ReadUInt64(); }
public abstract object Read(Rd rd);
public override object Read(Rd rd) { return(rd.ReadString()); }
public static int Read(this int x, Rd rd) { return rd.ReadInt32(); }
public static double Read(this double x, Rd rd) { return(rd.ReadDouble()); }
public static long Read(this long x, Rd rd) { return rd.ReadInt64(); }
public static decimal Read(this decimal x, Rd rd) { return(rd.ReadDecimal()); }
public static char Read(this char x, Rd rd) { return rd.ReadChar(); }
public static char Read(this char x, Rd rd) { return(rd.ReadChar()); }
public override object Read(Rd rd) { return rd.ReadByte(); }
public static byte[] Read(this byte[] x, Rd rd) { return(rd.ReadBytes()); }
public override object Read(Rd rd) { return rd.ReadBoolean(); }
public static string Read(this string x, Rd rd) { return(rd.ReadString()); }
public override object Read(Rd rd) { return rd.ReadInt32(); }
public static Int Read(Int val, Rd rd) { return(rd.ReadInt32()); }
public static bool Read(this bool x, Rd rd) { return rd.ReadBoolean(); }
public static bool Read(this bool x, Rd rd) { return(rd.ReadBoolean()); }
public static ushort Read(this ushort x, Rd rd) { return rd.ReadUInt16(); }
public List <Plans> GetPlans(string sCollege, string sDegree, string sMajor, bool isPreIncluded, InitializeModule.EnumCampus Campus) { Connection_StringCLS myConnection_String = new Connection_StringCLS(Campus); SqlConnection Conn = new SqlConnection(myConnection_String.Conn_string); Conn.Open(); SqlCommand Cmd, CmdCourses, CmdElect, CmdPre; SqlDataReader Rd, RdCourses, RdElect, RdPre; List <Plans> Result = new List <Plans>(); try { string sSQL = "SELECT S.strCollege,S.strDegree,S.strSpecialization,S.strMajor,S.strDisplay,S.intStudyHours,S.ElectiveCreditHours"; sSQL += " FROM dbo.Reg_Specializations AS S "; sSQL += " WHERE (1 = 1)"; if (!string.IsNullOrEmpty(sCollege)) { sSQL += " AND strCollege ='" + sCollege + "'"; } if (!string.IsNullOrEmpty(sDegree)) { sSQL += " AND strDegree ='" + sDegree + "'"; } if (!string.IsNullOrEmpty(sMajor)) { sSQL += " AND strSpecialization ='" + sMajor + "'"; } Cmd = new SqlCommand(sSQL, Conn); Rd = Cmd.ExecuteReader(); int iPlan = 0; Plans Plan; PlanCourses.Crs Cr; string sCCollege = ""; string sCDegree = ""; string sCMajor = ""; while (Rd.Read()) { iPlan += 1; Plan = new Plans(); Plan.College = Rd["strCollege"].ToString(); Plan.Degree = Rd["strDegree"].ToString(); Plan.Major = Rd["strSpecialization"].ToString(); sCCollege = Plan.College; sCDegree = Plan.Degree; sCMajor = Plan.Major; Plan.PlanDesc = Rd["strMajor"].ToString(); Plan.SDisplay = Rd["strDisplay"].ToString(); Plan.Plan = iPlan; Plan.StudyHours = int.Parse(Rd["intStudyHours"].ToString()); Plan.Elective = int.Parse(Rd["ElectiveCreditHours"].ToString()); //Collect Plan Courses Plan.Courses = new List <PlanCourses.Crs>(); Plan.Courses = GetCourses(sCCollege, sCDegree, sCMajor, isPreIncluded, Campus); Result.Add(Plan); } Rd.Close(); } catch (Exception ex) { Console.WriteLine("{0} Exception caught.", ex.Message); } finally { Conn.Close(); } return(Result); }
public static uint Read(this uint x, Rd rd) { return rd.ReadUInt32(); }
public override object Read(Rd rd) { return rd.ReadString(); }
public static ulong Read(this ulong x, Rd rd) { return rd.ReadUInt64(); }
public override object Read(Rd rd) { return this.rdChMeth.Invoke(null, new object[]{null, rd}); }
public static float Read(this float x, Rd rd) { return rd.ReadSingle(); }
public static uint Read(this uint x, Rd rd) { return(rd.ReadUInt32()); }
public static decimal Read(this decimal x, Rd rd) { return rd.ReadDecimal(); }
public static int Read(this int x, Rd rd) { return(rd.ReadInt32()); }
public static byte[] Read(this byte[] x, Rd rd) { return rd.ReadBytes(); }
/* Execute Step Comments: * The temp variables Rs,Rd,Operand8,etc registers are defined in constructor Main() method to avoid memory leaks. * But, this also means they will also retain the same value even after ExecuteStep() is called again. * So, for any temp variables, modify all its constituent variables then only use it. * e.g. Do not use Operand16 by modifying just its LB or HB. */ private void ExecuteStep() { IC++; CCC = CCC + Int32.Parse(I.Names[m[PC.DEC16].DEC8, 2]); if (changeInte == true) //Interrupt control logic (as ei/de affects inte f/f only during next instruction) { if (changeInteTo == true) { inte = true; } else { inte = false; } changeInte = false; UpdateInterrupt(); } Opcode.DEC8 = m[PC.DEC16].DEC8; // * DATA TRANSFER GROUP * if (BitCombination(Opcode[7], Opcode[6]) == "01") //MOV,HLT { //Except Rs=Rd=M 01110110 hlt if (BitCombination(Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "110110") { //Halt Rs=Rd=M 01110110 hlt Stop(); return; } else { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); Set8BitRegisterValue(Rs.DEC8, Opcode[5], Opcode[4], Opcode[3]); PC.INX(); } } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "00110") //MVI Rd,8BitData { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; Set8BitRegisterValue(Operand8.DEC8, Opcode[5], Opcode[4], Opcode[3]); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "000001") //LXI Rp,16BitData { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; Set16BitRegisterValue(true, Operand16.DEC16, Opcode[5], Opcode[4]); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00111010") //LDA { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; PSW.HB.DEC8 = m[Operand16.DEC16].DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00110010") //STA { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; m[Operand16.DEC16].DEC8 = PSW.HB.DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00101010") //LHLD { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; HL.LB.DEC8 = m[Operand16.DEC16].DEC8; Operand16.INX(); HL.HB.DEC8 = m[Operand16.DEC16].DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00100010") //SHLD { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; m[Operand16.DEC16].DEC8 = HL.LB.DEC8; Operand16.INX(); m[Operand16.DEC16].DEC8 = HL.HB.DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00001010") //LDAX B { PSW.HB.DEC8 = m[BC.DEC16].DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00011010") //LDAX D { PSW.HB.DEC8 = m[DE.DEC16].DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11101010") //XCHG { Operand16.DEC16 = HL.DEC16; HL.DEC16 = DE.DEC16; DE.DEC16 = Operand16.DEC16; PC.INX(); } else if (Opcode.DEC8 == 219) //IN 8bitIOPortAddress { PC.INX(); PSW.HB.DEC8 = io[m[PC.DEC16].DEC8].DEC8; PC.INX(); } else if (Opcode.DEC8 == 211) //OUT 8bitIOPortAddress { PC.INX(); io[m[PC.DEC16].DEC8].DEC8 = PSW.HB.DEC8; PC.INX(); } // * ARITHMETIC GROUP * else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10000") //ADD Rs { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); if ((PSW.HB.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10001") //ADC R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); byte i; if (PSW.LB[0] == true) { i = 1; } else { i = 0; } if ((PSW.HB.GetLowerNibble() + Rs.GetLowerNibble() + i) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Rs.DEC8 + i) > 255) { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8 + i - 256); } else { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8 + i); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11000110") //ADI 8bitdata { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; if ((PSW.HB.GetLowerNibble() + Operand8.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Operand8.DEC8) > 255) { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8 - 256); } else { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11001110") //ACI 8bitdata { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; byte i; if (PSW.LB[0] == true) { i = 1; } else { i = 0; } if ((PSW.HB.GetLowerNibble() + Operand8.GetLowerNibble() + i) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Operand8.DEC8 + i) > 255) { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8 + i - 256); } else { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8 + i); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "00100") //INR R { Rs.DEC8 = Get8BitRegisterValue(Opcode[5], Opcode[4], Opcode[3]); if (Rs.GetLowerNibble() == 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if (Rs.DEC8 == 255) { Rs.DEC8 = (byte)(0 + 1); } else { Rs.DEC8 = (byte)(Rs.DEC8 + 1); } Set8BitRegisterValue(Rs.DEC8, Opcode[5], Opcode[4], Opcode[3]); UpdateP(Rs.DEC8); UpdateS(Rs.DEC8); UpdateZ(Rs.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10010") //SUB R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); Rs.DEC8 = Rs.Get2sComplement(); //In 2's complement addition, complement both CY and AC. Here, it is done directly in if conditional //by inverting true and false. if ((PSW.HB.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10011") //SBB R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); if (PSW.LB[0] == true) { if (Rs.DEC8 == 255) { Rs.DEC8 = 0; } else { Rs.DEC8 = (byte)(Rs.DEC8 + 1); } } Rs.DEC8 = Rs.Get2sComplement(); if ((PSW.HB.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11010110") //SUI 8bitData { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; Operand8.DEC8 = Operand8.Get2sComplement(); if ((PSW.HB.GetLowerNibble() + Operand8.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Operand8.DEC8) > 255) { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8 - 256); } else { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11011110") //SBI 8BitDAta { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; if (PSW.LB[0] == true) { if (Operand8.DEC8 == 255) { Operand8.DEC8 = 0; } else { Operand8.DEC8 = (byte)(Operand8.DEC8 + 1); } } Operand8.DEC8 = Operand8.Get2sComplement(); if ((PSW.HB.GetLowerNibble() + Operand8.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Operand8.DEC8) > 255) { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8 - 256); } else { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "00101") //DCR R { /*Rs.DEC8 = Get8BitRegisterValue(Opcode[5], Opcode[4], Opcode[3]); * * Rs.DEC8 = Rs.Get2sComplement(); * * if (Rs.GetLowerNibble() == 15) * PSW.LB[4] = true; * else * PSW.LB[4] = false; * * if (Rs.DEC8 == 255) * { * Rs.DEC8 = (byte)(0 + 1); * } * else * { * Rs.DEC8 = (byte)(Rs.DEC8 + 1); * } * * Set8BitRegisterValue(Rs.DEC8, Opcode[5], Opcode[4], Opcode[3]); * UpdateP(Rs.DEC8); * UpdateS(Rs.DEC8); * UpdateZ(Rs.DEC8); * * PC.INX(); * */ Rd.DEC8 = Get8BitRegisterValue(Opcode[5], Opcode[4], Opcode[3]); Rs.DEC8 = 1; //As 1 is substracted Rs.DEC8 = Rs.Get2sComplement(); //In 2's complement addition, complement both CY and AC. Here, it is done directly in if conditional //by inverting true and false. if ((Rd.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((Rd.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = false; Rd.DEC8 = (byte)(Rd.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = true; Rd.DEC8 = (byte)(Rd.DEC8 + Rs.DEC8); } Set8BitRegisterValue(Rd.DEC8, Opcode[5], Opcode[4], Opcode[3]); UpdateP(Rd.DEC8); UpdateS(Rd.DEC8); UpdateZ(Rd.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "000011") //INX Rp { switch (BitCombination(Opcode[5], Opcode[4])) { case "00": { BC.INX(); break; } case "01": { DE.INX(); break; } case "10": { HL.INX(); break; } case "11": { SP.INX(); break; } } PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "001011") //DCX Rp { switch (BitCombination(Opcode[5], Opcode[4])) { case "00": { BC.DCX(); break; } case "01": { DE.DCX(); break; } case "10": { HL.DCX(); break; } case "11": { SP.DCX(); break; } } PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "001001") //DAD Rp,16BitData { Operand16.DEC16 = Get16BitRegisterValue(true, Opcode[5], Opcode[4]); if ((HL.DEC16 + Operand16.DEC16) > 65535) { PSW.LB[0] = true; HL.DEC16 = (ushort)(HL.DEC16 + Operand16.DEC16 - 65536); } else { PSW.LB[0] = false; HL.DEC16 = (ushort)(HL.DEC16 + Operand16.DEC16); } PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00100111") //DAA { if ((PSW.HB.GetLowerNibble() > 9) || (PSW.LB[4] == true)) { //Add 6 to lower nibble if ((PSW.HB.GetLowerNibble() + 6) > 15) { PSW.LB[4] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + 6 - 16); //6 is added, 16 is sub to neutralize overflow out of nibble } else { PSW.LB[4] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + 6); } } else { PSW.LB[4] = false; } byte i; if (PSW.LB[4] == true) { i = 1; } else { i = 0; } if ((PSW.HB.GetHigherNibble() > 9) || (PSW.LB[0] == true)) { bool PreviousCY = PSW.LB[0]; //Add 6 to higher nibble if ((PSW.HB.GetHigherNibble() + 6 + i) > 15) { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + (6 + i - 16) * 16); //i is carry from lower nibble, Multiply by 16 to reach uppaer nibble ( i.e. up by 4 bits 2^4) } else { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + (6 + i) * 16); } if (PreviousCY) //Set CY if it was initially set { PSW.LB[0] = true; } } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } // * LOGICAL GROUP * else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10100") //ANA R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 & Rs.DEC8); PSW.LB[0] = false; PSW.LB[4] = true; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11100110") //ANI 8bitData { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 & Operand8.DEC8); PSW.LB[0] = false; PSW.LB[4] = true; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10110") //ORA R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 | Rs.DEC8); PSW.LB[0] = false; PSW.LB[4] = false; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11110110") //ORI 8bitData { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 | Operand8.DEC8); PSW.LB[0] = false; PSW.LB[4] = false; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10101") //XRA R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 ^ Rs.DEC8); PSW.LB[0] = false; PSW.LB[4] = false; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11101110") //XRI 8bitData { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 ^ Operand8.DEC8); PSW.LB[0] = false; PSW.LB[4] = false; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00101111") //CMA { PSW.HB.DEC8 = (byte)(~PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00111111") //CMC { PSW.LB[0] = !PSW.LB[0]; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00110111") //STC { PSW.LB[0] = true; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10111") //CMP R { Operand8.DEC8 = PSW.HB.DEC8; Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); Rs.DEC8 = Rs.Get2sComplement(); if ((Operand8.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((Operand8.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = false; Operand8.DEC8 = (byte)(Operand8.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = true; Operand8.DEC8 = (byte)(Operand8.DEC8 + Rs.DEC8); } UpdateP(Operand8.DEC8); UpdateS(Operand8.DEC8); UpdateZ(Operand8.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10111") //CPI 8bitData { Operand8.DEC8 = PSW.HB.DEC8; PC.INX(); Rs.DEC8 = m[PC.DEC16].DEC8; Rs.DEC8 = Rs.Get2sComplement(); if ((Operand8.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((Operand8.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = false; Operand8.DEC8 = (byte)(Operand8.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = true; Operand8.DEC8 = (byte)(Operand8.DEC8 + Rs.DEC8); } UpdateP(Operand8.DEC8); UpdateS(Operand8.DEC8); UpdateZ(Operand8.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00000111") //RLC { bool D7 = PSW.HB[7]; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 << 1); PSW.HB[0] = D7; PSW.LB[0] = D7; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00001111") //RRC { bool D0 = PSW.HB[0]; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 >> 1); PSW.HB[7] = D0; PSW.LB[0] = D0; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00010111") //RAL { bool D7 = PSW.HB[7]; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 << 1); PSW.HB[0] = PSW.LB[0]; PSW.LB[0] = D7; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00011111") //RAR { bool D0 = PSW.HB[0]; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 >> 1); PSW.HB[7] = PSW.LB[0]; PSW.LB[0] = D0; PC.INX(); } // * STACK AND MACHINE CONTROL GROUP * else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "110101") //PUSH Rp { //FOR Push/Pop and in Branching only , IsSP = false i.e. return PC Operand16.DEC16 = Get16BitRegisterValue(false, Opcode[5], Opcode[4]); SP.DCX(); m[SP.DEC16].DEC8 = Operand16.HB.DEC8; SP.DCX(); m[SP.DEC16].DEC8 = Operand16.LB.DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "110001") //POP Rp { Operand16.LB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); Operand16.HB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); Set16BitRegisterValue(false, Operand16.DEC16, Opcode[5], Opcode[4]); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11111001") //SPHL { SP.DEC16 = HL.DEC16; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11100011") //XTHL { Operand16.DEC16 = HL.DEC16; HL.LB.DEC8 = m[SP.DEC16].DEC8; m[SP.DEC16].DEC8 = Operand16.LB.DEC8; if (SP.DEC16 == 255) //Check for overflow { HL.HB.DEC8 = m[0].DEC8; m[0].DEC8 = Operand16.HB.DEC8; } else { HL.HB.DEC8 = m[SP.DEC16 + 1].DEC8; m[SP.DEC16 + 1].DEC8 = Operand16.HB.DEC8; } PC.INX(); } else if (Opcode.DEC8 == 0) //NOP { PC.INX(); } else if (Opcode.DEC8 == 251) //EI { changeInte = true; changeInteTo = true; PC.INX(); } else if (Opcode.DEC8 == 251) //DI { changeInte = true; changeInteTo = false; PC.INX(); } else if (Opcode.DEC8 == 32) //RIM { //Read sid and output to d7 bit of accumulator if (rbSid0.IsChecked == true) { PC.HB[7] = false; } else { PC.HB[7] = true; } //No logic for interrupts pending in simulator //Read inte if (inte == true) { PC.HB[3] = true; } else { PC.HB[3] = false; } //Reads masks if (interrupt[2] == true) //M7.5 { PC.HB[2] = true; } else { PC.HB[2] = false; } if (interrupt[1] == true) //M6.5 { PC.HB[1] = true; } else { PC.HB[1] = false; } if (interrupt[0] == true) //M5.5 { PC.HB[0] = true; } else { PC.HB[0] = false; } PC.INX(); UpdateInterrupt(); } else if (Opcode.DEC8 == 48) //SIM { //Set sod=1 if sde=1 else sod=0 if (PC.HB[6] == true) { if (PC.HB[7] == true) { tbSod.Text = "1"; } else { tbSod.Text = "0"; } } if (PC.HB[4] == true) //Resets r7.5 f/f, else has no effect { r75 = false; } if (PC.HB[3] == true) //MSE { if (PC.HB[2] == true) //M'7.5 { interrupt[2] = true; } else { interrupt[2] = false; } if (PC.HB[1] == true) //M'6.5 { interrupt[1] = true; } else { interrupt[1] = false; } if (PC.HB[0] == true) //M'5.5 { interrupt[0] = true; } else { interrupt[0] = false; } } PC.INX(); UpdateInterrupt(); } // * BRANCH GROUP * //In branch group, take care of whether to execute PC.INX() or not at end. else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11101001") //PCHL { PC.DEC16 = HL.DEC16; } else if (Opcode.DEC8 == 195) //JMP { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; PC.DEC16 = Operand16.DEC16; } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "11010") //Conditional Jump { if (CheckCondition(Opcode[5], Opcode[4], Opcode[3]) == true) { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; PC.DEC16 = Operand16.DEC16; } else { PC.INX(); PC.INX(); PC.INX(); } } else if (Opcode.DEC8 == 205) //CALL { //Storing address to be branched in temp register Operand16 PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); //Push contents of PC onto stack SP.DCX(); m[SP.DEC16].DEC8 = PC.HB.DEC8; SP.DCX(); m[SP.DEC16].DEC8 = PC.LB.DEC8; //Branch PC.DEC16 = Operand16.DEC16; } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "11100") //Conditional CALL { if (CheckCondition(Opcode[5], Opcode[4], Opcode[3]) == true) { //Storing address to be branched in temp register Operand16 PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); //Push contents of PC onto stack SP.DCX(); m[SP.DEC16].DEC8 = PC.HB.DEC8; SP.DCX(); m[SP.DEC16].DEC8 = PC.LB.DEC8; //Branch PC.DEC16 = Operand16.DEC16; } else { PC.INX(); PC.INX(); PC.INX(); } } else if (Opcode.DEC8 == 201) //RET { //Pop content from stack to temp RegisterPair Operand16 Operand16.LB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); Operand16.HB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); //Branch PC.DEC16 = Operand16.DEC16; } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "11000") //Conditional Return { if (CheckCondition(Opcode[5], Opcode[4], Opcode[3]) == true) { Operand16.LB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); Operand16.HB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); //Branch PC.DEC16 = Operand16.DEC16; } else { PC.INX(); } } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "11111") //RST N { PC.INX(); //Push contents of PC onto stack SP.DCX(); m[SP.DEC16].DEC8 = PC.HB.DEC8; SP.DCX(); m[SP.DEC16].DEC8 = PC.LB.DEC8; //Branch switch (BitCombination(Opcode[5], Opcode[4], Opcode[3])) { case "000": { PC.DEC16 = 0; break; } case "001": { PC.DEC16 = 8; break; } case "010": { PC.DEC16 = 16; break; } case "011": { PC.DEC16 = 24; break; } case "100": { PC.DEC16 = 32; break; } case "101": { PC.DEC16 = 40; break; } case "110": { PC.DEC16 = 48; break; } case "111": { PC.DEC16 = 56; break; } } } else { //Unrecognised Instructions PC.INX(); } RefreshMIO(false); //Nofocus, as it will cause Stop button never to gain focus UpdateAll(); //Rucurse in Fast Mode but in idle priority if (rbFast.IsChecked == true) { bStep.IsEnabled = false; if (IsStopped == false) { bStart.Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new ExecuteStepDelegate(ExecuteStep)); } } }
public static sbyte Read(this sbyte x, Rd rd) { return(rd.ReadSByte()); }
public override object Read(Rd rd) { return rd.ReadChar(); }
public List <PlanCourses.Crs> GetCourses(string sCollege, string sDegree, string sMajor, bool isPreIncluded, InitializeModule.EnumCampus Campus) { Connection_StringCLS myConnection_String = new Connection_StringCLS(Campus); SqlConnection Conn = new SqlConnection(myConnection_String.Conn_string); Conn.Open(); SqlCommand Cmd; SqlDataReader Rd; List <PlanCourses.Crs> Result = new List <PlanCourses.Crs>(); PlanCourses.Crs Cr; int iOrder = 0; try{ string sCrsSQL = "Select SC.byteOrder, SC.strCourse, C.byteCreditHours, C.strCourseDescEn AS sDesc, C.strParallel, C.bExtraLab,SC.byteCourseClass"; sCrsSQL += " FROM dbo.Reg_Specialization_Courses AS SC INNER JOIN dbo.Reg_Courses AS C ON SC.strCourse = C.strCourse"; sCrsSQL += " Where SC.strCollege='" + sCollege + "' and SC.strDegree='" + sDegree + "' and SC.strSpecialization='" + sMajor + "'"; sCrsSQL += " ORDER BY SC.byteOrder"; Cmd = new SqlCommand(sCrsSQL, Conn); Rd = Cmd.ExecuteReader(); while (Rd.Read()) { iOrder += 1; Cr = new PlanCourses.Crs(); Cr.sCourse = Rd["strCourse"].ToString(); Cr.sDesc = Rd["sDesc"].ToString(); Cr.sParallel = Rd["strParallel"].ToString(); Cr.iOrder = int.Parse(Rd["byteOrder"].ToString()); Cr.iClass = int.Parse(Rd["byteCourseClass"].ToString()); if (!Rd["byteCreditHours"].Equals(DBNull.Value)) { Cr.iCredit = int.Parse(Rd["byteCreditHours"].ToString()); } else { Cr.iCredit = 0; } //Collect Elective Options if (Cr.sCourse == "ELECT1" || Cr.sCourse == "ELECT2" || Cr.sCourse == "MELECT1" || Cr.sCourse == "MELECT2" || Cr.sCourse == "MELECT3") { Cr.isElectve = true; Cr.sElectives = new List <string>(); Cr.sElectives = GetElective(sCollege, sDegree, sMajor, iOrder, Campus); } //Collect Courses Prerequisites if (isPreIncluded == true) { Cr.iPre = new List <int>(); Cr.iPre = GetPrerequisite(sCollege, sDegree, sMajor, Cr.sCourse, Campus); } Result.Add(Cr); } Rd.Close(); } catch (Exception ex) { Console.WriteLine("{0} Exception caught.", ex.Message); } finally { Conn.Close(); Conn.Dispose(); } return(Result); }
public static ushort Read(this ushort x, Rd rd) { return(rd.ReadUInt16()); }
public static short Read(this short x, Rd rd) { return(rd.ReadInt16()); }
public override object Read(Rd rd) { return rd.ReadDecimal(); }