Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            clearall();
            errorProvider1.Clear();
            this.Hide();
            PengelolaanPegawai myParent = (PengelolaanPegawai)this.Parent;

            myParent.enable();
        }
Exemple #2
0
        private void button2_Click(object sender, EventArgs e) // Button Simpan
        {
            if (flagperintah == 1)                             //tambah data
            {
                if (cektxt() == true)
                {
                    errorProvider1.Clear();

                    if (PC.unikUsername(txtUsername.Text) == txtUsername.Text)
                    {
                        DialogResult dr = MessageBox.Show("Username tersebut sudah ada, silahkan gunakan username yang lain", "iNBC",
                                                          MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        int IDRole            = PC.getIdRole(cmbRolePgw.Text);
                        iNBC.Entity.Pegawai P = new Entity.Pegawai(txtNama.Text, jenis_kelamin, txtTelp.Text, txtAlamat.Text, txtUsername.Text.ToUpper(), txtPass.Text, IDRole, status, 1);
                        PC.addPegawai(P);
                        clearall();
                        this.Hide();
                        PengelolaanPegawai myParent = (PengelolaanPegawai)this.Parent;
                        myParent.enable();
                        myParent.Show();
                    }
                }
            }
            else
            {
                string usernameToEdit = txtUsername.Text;

                if (cektxt() == true)
                {
                    errorProvider1.Clear();


                    if (txtUsername.Text == PC.unikUsername(tempUsernametoEdit.Text))
                    {
                        int IDRole            = PC.getIdRole(cmbRolePgw.Text);
                        iNBC.Entity.Pegawai P = new Entity.Pegawai(txtNama.Text, jenis_kelamin, txtTelp.Text, txtAlamat.Text, txtUsername.Text, txtPass.Text, IDRole, status, 1);

                        DialogResult dr = MessageBox.Show("Apakah anda yakin ingin mengubah data pegawai " + temp_pegawai, "Peringatan",
                                                          MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);

                        if (dr == DialogResult.Yes)
                        {
                            PC.editPegawai(P, int.Parse(txtID.Text));
                        }
                        clearall();
                        this.Hide();
                        PengelolaanPegawai myParent = (PengelolaanPegawai)this.Parent;
                        myParent.Enableedit();
                    }

                    else if (PC.unikUsername(txtUsername.Text) == txtUsername.Text)
                    {
                        DialogResult dr = MessageBox.Show("Username tersebut sudah ada, silahkan gunakan username yang lain", "iNBC",
                                                          MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    else
                    {
                        int IDRole            = PC.getIdRole(cmbRolePgw.Text);
                        iNBC.Entity.Pegawai P = new Entity.Pegawai(txtNama.Text, jenis_kelamin, txtTelp.Text, txtAlamat.Text, txtUsername.Text, txtPass.Text, IDRole, status, 1);

                        DialogResult dr = MessageBox.Show("Apakah anda yakin ingin mengubah data pegawai " + temp_pegawai, "Peringatan",
                                                          MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);

                        if (dr == DialogResult.Yes)
                        {
                            PC.editPegawai(P, int.Parse(txtID.Text));
                        }
                        clearall();
                        this.Hide();
                        PengelolaanPegawai myParent = (PengelolaanPegawai)this.Parent;
                        myParent.Enableedit();
                    }
                }
            }
        }