コード例 #1
0
ファイル: OpenStudent.cs プロジェクト: sean97140/TutoringApp
        private void button1_Click(object sender, EventArgs e)
        {
            Record entries = new Record();

            #region Database Handling
            list.Clear();
            var id = StudentID.Text;
            // Open a connection to the database...
            MySqlConnection conn = new MySqlConnection("server=localhost;user=root;database=students;port=3306;password=;");
            conn.Open();
            // Perform the first query...
            String sql = "SELECT * FROM students.demographics WHERE id = '" + id + "'";
            MySqlCommand cmd = new MySqlCommand(sql, conn);
            cmd.ExecuteNonQuery();
            MySqlDataReader sqlReader = cmd.ExecuteReader();
            #endregion

            // Parse through results and store in a list...
            while (sqlReader.Read())
            {
                entries.AddRecord(Convert.ToInt32(sqlReader.GetValue(0)), sqlReader.GetValue(1).ToString(), sqlReader.GetValue(2).ToString(), sqlReader.GetValue(3).ToString());
                // Add the record to the list of records...
                list.Add(entries);
            }

            // If we have an empty list, let the user know.
            if (list.Count == 0)
            {
                MessageBox.Show("ID returned no matches", "No results");
            }
            else
            {
                MessageBox.Show("Confirm:\nYour name is: " + entries.FirstName + " " + entries.LastName, "Confirmation", MessageBoxButtons.YesNo);
            }
        }
コード例 #2
0
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            Record entries = new Record();

            #region Database Handling
            MySqlConnection conn = new MySqlConnection("server=localhost;user=root;database=students;port=3306;password=;");
            conn.Open();
            // Perform the first query...
            String sql = "SELECT * FROM students.tutorpasswords";
            MySqlCommand cmd = new MySqlCommand(sql, conn);
            cmd.ExecuteNonQuery();
            MySqlDataReader sqlReader = cmd.ExecuteReader();
            #endregion

            // Parse through results and store in a list...
            while (sqlReader.Read())
            {
                entries.AddRecord(sqlReader.GetValue(0).ToString(), sqlReader.GetValue(1).ToString());
                // Add the record to the list of records...
                list.Add(entries);
                MessageBox.Show("User: "******"\nPassword: "******"\n");
            }
        }
コード例 #3
0
ファイル: ScriptCompiler.cs プロジェクト: robjer/tesvsnip
        public static bool Compile(Record r2, out string msg)
        {
            msg=null;
            r=new Record();
            string script=null;
            int scptype=0;
            foreach(SubRecord sr2 in r2.SubRecords) {
                if(sr2.Name=="SCTX") script=sr2.GetStrData();
                if(sr2.Name=="SCHR") {
                    byte[] tmp=sr2.GetReadonlyData();
                    scptype=TypeConverter.h2si(tmp[16], tmp[17], tmp[18], tmp[19]);
                }
            }
            if(script==null) {
                msg="Script had no SCTX record to compile";
                return false;
            }
            locals.Clear();
            localList.Clear();
            edidRefs.Clear();
            refcount=0;
            errors.Clear();

            ts=new TokenStream(script, errors);
            if(errors.Count>0) return OutputErrors( out msg);
            Token[] smt=ts.PopNextStatement();
            if(smt.Length!=2||!smt[0].IsKeyword(Keywords.ScriptName)||smt[1].token==null) return ReturnError("Expected 'ScriptName <edid>'", out msg);
            SubRecord sr=new SubRecord();
            sr.Name="EDID";
            sr.SetStrData(smt[1].utoken, true);
            r.AddRecord(sr);
            r.descriptiveName=" ("+smt[1].token+")";
            schr=new SubRecord();
            schr.Name="SCHR";
            r.AddRecord(schr);
            scda=new SubRecord();
            scda.Name="SCDA";
            r.AddRecord(scda);
            sr=new SubRecord();
            sr.Name="SCTX";
            sr.SetStrData(script, false);
            r.AddRecord(sr);

            bw=new BinaryWriter(new MemoryStream());
            Emit(0x001d);
            Emit(0x0000);
            try {
                HandleVariables();
            } catch(Exception ex) {
                return ReturnError(ex.Message, out msg);
            }
            for(int i=0;i<localList.Count;i++) {
                if(localList[i].type==VarType.Ref) {
                    sr=new SubRecord();
                    sr.Name="SCRV";
                    sr.SetData(TypeConverter.si2h(i+1));
                    r.AddRecord(sr);
                    refcount++;
                    localList[i].refid=refcount;
                }
            }
            while(ts.PeekNextStatement().Length>0) {
                try {
                    HandleBlock();
                } catch(Exception ex) {
                    return ReturnError(ex.Message, out msg);
                }
            }
            if(errors.Count>0) {
                return OutputErrors(out msg);
            }

            byte[] header=new byte[20];
            TypeConverter.si2h(refcount, header, 4);
            TypeConverter.i2h((uint)bw.BaseStream.Length, header, 8);
            TypeConverter.si2h(localList.Count, header, 12);
            TypeConverter.si2h(scptype, header, 16);
            schr.SetData(header);
            byte[] compileddata=((MemoryStream)bw.BaseStream).GetBuffer();
            if(compileddata.Length!=bw.BaseStream.Length) Array.Resize<byte>(ref compileddata, (int)bw.BaseStream.Length);
            scda.SetData(compileddata);
            r2.SubRecords.Clear();
            r2.SubRecords.AddRange(r.SubRecords);
            bw.Close();
            return true;
        }
コード例 #4
0
ファイル: ScriptCompiler.cs プロジェクト: robjer/tesvsnip
        public static bool CompileResultScript(SubRecord sr, out Record r2, out string msg)
        {
            msg=null;
            r2=null;
            r=new Record();
            string script=sr.GetStrData();
            locals.Clear();
            localList.Clear();
            edidRefs.Clear();
            refcount=0;
            errors.Clear();

            ts=new TokenStream(script, errors);
            if(errors.Count>0) return OutputErrors(out msg);
            schr=new SubRecord();
            schr.Name="SCHR";
            r.AddRecord(schr);
            scda=new SubRecord();
            scda.Name="SCDA";
            r.AddRecord(scda);
            sr=(SubRecord)sr.Clone();
            r.AddRecord(sr);

            bw=new BinaryWriter(new MemoryStream());

            while(ts.PeekNextStatement().Length>0) {
                try {
                    HandleResultsBlock();
                } catch(Exception ex) {
                    return ReturnError(ex.Message, out msg);
                }
            }

            if(errors.Count>0) {
                return OutputErrors(out msg);
            }

            byte[] header=new byte[20];
            TypeConverter.si2h(refcount, header, 4);
            TypeConverter.i2h((uint)bw.BaseStream.Length, header, 8);
            TypeConverter.si2h(localList.Count, header, 12);
            TypeConverter.si2h(0x10000, header, 16);
            schr.SetData(header);
            byte[] compileddata=((MemoryStream)bw.BaseStream).GetBuffer();
            if(compileddata.Length!=bw.BaseStream.Length) Array.Resize<byte>(ref compileddata, (int)bw.BaseStream.Length);
            scda.SetData(compileddata);
            bw.Close();
            r2=r;
            return true;
        }
コード例 #5
0
ファイル: MainView.cs プロジェクト: robjer/tesvsnip
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!ValidateMakeChange())
         return;
     Plugin p = new Plugin();
     Record r = new Record();
     r.Name = "TES4";
     SubRecord sr = new SubRecord();
     sr.Name = "HEDR";
     sr.SetData(new byte[] { 0xD7, 0xA3, 0x70, 0x3F, 0xFA, 0x56, 0x0C, 0x00, 0x19, 0xEA, 0x07, 0xFF });
     r.AddRecord(sr);
     sr = new SubRecord();
     sr.Name = "CNAM";
     sr.SetData(System.Text.Encoding.ASCII.GetBytes("Default\0"));
     r.AddRecord(sr);
     p.AddRecord(r);
     TreeNode tn = new TreeNode(p.Name);
     tn.Tag = p;
     TreeNode tn2 = new TreeNode(r.DescriptiveName);
     tn2.Tag = r;
     tn.Nodes.Add(tn2);
     PluginTree.Nodes.Add(tn);
     UpdateStringEditor();
 }