public AuthItems GetAllUserAuth() { AuthItems items = new AuthItems(); DataTable dt = TableMethods.GetTable(BaseMethod.DbPath, "Auth"); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Auth auth = new Auth(); auth.Username = (string)dt.Rows[i]["Username"]; auth.MacAddress = (string)dt.Rows[i]["MacAddress"]; items.AllAuthItems.Add(auth); } } return items; }
private void Button_Add_Click(object sender, RoutedEventArgs e) { if (auth == null) auth = new Auth(); auth.Username = TextBox_Username.Text; auth.MacAddress = TextBox_MacAddress.Text; if (string.IsNullOrEmpty(auth.Username)) { MessageBox.Show("لطفا نام کاربری را وارد کنید"); return; } if (string.IsNullOrEmpty(auth.MacAddress)) { MessageBox.Show("لطفا مک آدرس را وارد کنید"); return; } UserAuthManager uam = new UserAuthManager(); if (uam.NewUser(auth.Username, auth.MacAddress)) this.Items.Add(auth); TextBox_Username.Text = TextBox_MacAddress.Text = string.Empty; }