private void BtnAutentication_Click(object sender, EventArgs e) { AdminBase = new AdminBase(); if (AdminBase.SuperPass.Equals(txtPass.Text)) { this.Hide(); this.Close(); this.Dispose(); new registerForm().ShowDialog(); } else { MessageBox.Show("Erro ao conectar-se com o servidor!", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// The ArrayList returned contain in the firste row the name of the Table /// and then contain an String Array (Object[]) in the other rows /// representing the name of the field and the data, and finally if exist a /// sql statement or an empty string if there isn't a sql statement /// </summary> /// <param name="admin"> /// A <see cref="AdminBase"/> /// </param> /// <param name="obj"> /// A <see cref="System.Object"/> /// </param> /// <param name="oper"> /// A <see cref="OPERATION"/> /// </param> /// <returns> /// A <see cref="ArrayList"/> /// </returns> public ArrayList entity2Array(AdminBase admin, object obj, OPERATION oper) { ArrayList array = new ArrayList(); bool sql = true; bool ignore = false; string statement = ""; array.Add(this.readClassName(obj)); bool tempParent = this.hasParent; this.hasParent = false; this.primaryKey.Push("id"); PropertyInfo[] properties = obj.GetType().GetProperties(); for (int i = 0; i < properties.Length; i++) { object[] objs = new object[2]; string field = properties[i].Name; objs[0] = field; Attribute att = null; Attribute[] attributes = (Attribute[])properties[i].GetCustomAttributes(false); foreach (Attribute a in attributes) { if (a is ColumnAttribute) { if (((ColumnAttribute)a).Name.Length != 0) { objs[0] = ((ColumnAttribute)a).Name; } ignore = ((ColumnAttribute)a).Ignore; att = a; if (((ColumnAttribute)a).Type == Properties.TYPES.PRIMARYKEY) { this.primaryKey.Pop(); this.primaryKey.Push(objs[0].ToString()); continue; } } else { continue; } } if (ignore) { ignore = false; continue; } if (sql) { if (oper == OPERATION.MODIFY || oper == OPERATION.DELETE) { string nameF = this.primaryKey.Peek(); int valueId = (int)properties[i].GetValue(obj, new object[0]); statement = nameF + "=" + valueId; } else { statement = this.primaryKey.Peek() + " > 0"; } sql = false; } object result = properties[i].GetValue(obj, new object[0]); } return(array); }