public bool DeleteUserSistem(UserSistem u_ser)
        {
            bool result = false;

            query = "UPDATE user_sistem SET status_deleted = 1 WHERE id_user_sistem = '" + u_ser.Id_user_sistem + "'";

            try
            {
                connect.Open();
                cmd = new MySqlCommand(query, connect);
                cmd.ExecuteNonQuery();
                result = true;
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message.ToString());
                result = false;
            }
            finally
            {
                connect.Close();
            }

            return result;
        }
        public bool AddUserSistem(UserSistem u_ser)
        {
            bool result = false;

            query = "INSERT INTO user_sistem VALUES('" + u_ser.Id_user_sistem + "','" + u_ser.Nama_user + "','" + u_ser.Password_user + "','" + u_ser.Role_user + "', 0)";

            try
            {
                connect.Open();
                cmd = new MySqlCommand(query, connect);
                cmd.ExecuteNonQuery();
                result = true;
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message.ToString());
                result = false;
            }
            finally
            {
                connect.Close();
            }

            return result;
        }
Exemple #3
0
        private void btn_DeletePermanenUserSistem_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Peringatan! Anda akan menghapus semua data secara permanen. Anda yakin?", "WARNING", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                s_userSistem = new UserSistem();
                s_userSistem.Id_user_sistem = Utils.ConcatMaxID(txt_IdPenggunaSistem.Text.ToString(), txt_IdPenggunaSistemNum.Text.ToString());

                if (s_userSistemManager.DeleteUserSistemPermanen(s_userSistem))
                {
                    MessageBox.Show("Data berhasil dihapus permanen");
                    txt_IdPenggunaSistemNum.Text = Utils.DisplayMaxID(s_userSistemManager.GetMaxIDUserSistem().Substring((s_userSistemManager.GetMaxIDUserSistem().IndexOf("-")) + 1));
                    ClearField();
                }
                else
                {
                    MessageBox.Show("Data gagal dihapus permanen");
                }
            }
            else
            {
                return;
            }
        }
Exemple #4
0
 private void btn_AddUserSistem_Click(object sender, EventArgs e)
 {
     if (txt_NamaPengguna.TextLength > 0 && txt_KataSandi.TextLength > 0 && txt_UlangiKataSandi.TextLength > 0 && cmb_Role.SelectedIndex != -1)
     {
         s_userSistem = new UserSistem(Utils.ConcatMaxID(txt_IdPenggunaSistem.Text.ToString(), txt_IdPenggunaSistemNum.Text.ToString()), txt_NamaPengguna.Text.ToString(), Utils.PassEncrypt(txt_KataSandi.Text.ToString(), true), cmb_Role.SelectedItem.ToString());
         if (s_userSistemManager.AddUserSistem(s_userSistem))
         {
             MessageBox.Show("Data berhasil ditambah");
             txt_IdPenggunaSistemNum.Text = Utils.DisplayMaxID(s_userSistemManager.GetMaxIDUserSistem().Substring(s_userSistemManager.GetMaxIDUserSistem().IndexOf("-") + 1));
             ClearField();
         }
         else
         {
             MessageBox.Show("Data gagal ditambah");
         }
     }
     else
     {
         MessageBox.Show("Mohon data-data dilengkapi");
     }
 }
        public bool ValidateLogin(UserSistem u_ser)
        {
            bool result = false;

            query = "SELECT nama_user, pass_user FROM user_sistem WHERE nama_user = '******' and pass_user = '******'";

            try
            {
                connect.Open();
                cmd = new MySqlCommand(query, connect);
                reader = cmd.ExecuteReader();
                if (reader.HasRows == true)
                {
                    result = true;
                }
                else if (reader.HasRows == false)
                {
                    result = false;
                }
                reader.Close();
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message.ToString());
                result = false;
            }
            finally
            {
                connect.Close();
            }

            return result;
        }
        public bool UpdateUserSistem(UserSistem u_ser)
        {
            bool result = false;

            query = "UPDATE user_sistem SET nama_user = '******', pass_user = '******', role_user = '******' WHERE id_user_sistem = '" + u_ser.Id_user_sistem + "'";

            try
            {
                connect.Open();
                cmd = new MySqlCommand(query, connect);
                cmd.ExecuteNonQuery();
                result = true;
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message.ToString());
                result = false;
            }
            finally
            {
                connect.Close();
            }

            return result;
        }