Exemplo n.º 1
0
 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();
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public bool DeleteBooks(Admins admins)
 {
     return(dalAdmins.DeleteAdmins(admins));
 }
Exemplo n.º 4
0
 public bool UpdateAdmins(Admins admins)
 {
     return(dalAdmins.UpdateAdmins(admins));
 }
Exemplo n.º 5
0
 public bool InsertAdmins(Admins admins)
 {
     return(dalAdmins.InsertAdmins(admins));
 }