private void button1_Click(object sender, EventArgs e) { if (check) { if (textBox3.Text == textBox4.Text) { context.Users.Remove(user); context.SaveChanges(); user.Password = textBox3.Text; context.Users.Add(user); context.SaveChanges(); this.Close(); } } if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("enter your information!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } foreach (var item in context.Users) { if (textBox2.Text == item.Email) { textBox1.Enabled = false; textBox2.Enabled = false; textBox3.Enabled = true; textBox4.Enabled = true; user = item; button1.Text = "Save"; check = true; break; } } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "") { MessageBox.Show("enter your information!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (textBox3.Text != textBox4.Text) { MessageBox.Show("Check your password!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } EFcontext EFContext = new EFcontext(); foreach (var item in EFContext.Users) { if (item.Login == textBox1.Text && item.Email == textBox2.Text) { return; } } EFContext.Users.Add(new User { Login = textBox1.Text, Email = textBox2.Text, Password = textBox3.Text }); EFContext.SaveChanges(); this.Close(); }
private void toolStripLabel3_Click(object sender, EventArgs e) { if (toolStripTextBox1.Text == "") { return; } foreach (var item in context.Sections) { if (item.Name == toolStripTextBox1.Text && item.UserId == user.Id) { MessageBox.Show("This Section exist!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } context.Sections.Add( new Section { Name = toolStripTextBox1.Text, UserId = user.Id }); context.SaveChanges(); updateSectionComboBox(); UpdateTreeView(); }