本文整理汇总了C#中Record.AddRecord方法的典型用法代码示例。如果您正苦于以下问题:C# Record.AddRecord方法的具体用法?C# Record.AddRecord怎么用?C# Record.AddRecord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record.AddRecord方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button1_Click
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: Login_Click
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: " + entries.ID + "\nPassword: " + entries.Password + "\n");
}
}
示例3: Compile
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: CompileResultScript
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: newToolStripMenuItem_Click
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();
}