private void Button4_Click(object sender, EventArgs e) { if (flag == "add") { if (CheckData()) { Admins admins = new Admins(); admins.CodeEmployee = txtCode.Text; admins.FullName = txtFullName.Text; admins.YearOfBirth = DateTime.Parse(dtpYearOfBirth.Text); admins.Gender = cbbGender.Text.Trim(); admins.Email = txtEmail.Text; admins.Address = txtAddress.Text; admins.Phone = txtPhone.Text; admins.UserName = txtUserName.Text; admins.Password = txtPassword.Text; admins.Position = cbbPosition.Text.Trim(); if (bllAdmins.InsertAdmins(admins)) { ShowAllAdmins(); } else { MessageBox.Show("Произошла ошибка", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } } else if (flag == "edit") { if (CheckData()) { Admins admins = new Admins(); admins.ID = ID; admins.CodeEmployee = txtCode.Text; admins.FullName = txtFullName.Text; admins.YearOfBirth = DateTime.Parse(dtpYearOfBirth.Text); admins.Gender = cbbGender.Text.Trim(); admins.Email = txtEmail.Text; admins.Address = txtAddress.Text; admins.Phone = txtPhone.Text; admins.UserName = txtUserName.Text; admins.Password = txtPassword.Text; admins.Position = cbbPosition.Text.Trim(); if (bllAdmins.UpdateAdmins(admins)) { ShowAllAdmins(); } else { MessageBox.Show("Произошла ошибка", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } } LockControl(); }
public bool DeleteAdmins(Admins admins) { string sql = "delete Admins where ID = @ID"; SqlConnection con = dc.getConnect(); try { cmd = new SqlCommand(sql, con); con.Open(); cmd.Parameters.Add("@ID", SqlDbType.BigInt).Value = admins.ID; cmd.ExecuteNonQuery(); con.Close(); } catch (Exception e) { return(false); } return(true); }
public bool DeleteBooks(Admins admins) { return(dalAdmins.DeleteAdmins(admins)); }
public bool UpdateAdmins(Admins admins) { return(dalAdmins.UpdateAdmins(admins)); }
public bool InsertAdmins(Admins admins) { return(dalAdmins.InsertAdmins(admins)); }