예제 #1
0
 private int CekDataDuplikasi(PegawaiEntity input)
 {
     return(Pcontrol.CekDataDuplikasi(input));
 }
예제 #2
0
        private void btnTambah_Click(object sender, EventArgs e)
        {
            try{
                if (flagperintah == 1)
                {
                    if (cektxt() == true)
                    {
                        errorProvider1.Clear();

                        int IDRole = Pcontrol.getIDRole(cmbJabatan.Text);
                        int idLast = Pcontrol.getLastIdPegawai() + 1;
                        if (IDRole == 4)
                        {
                            Pcontrol.EntryUserPegawai(IDRole, "Ins" + idLast, "123456");
                        }
                        else
                        {
                            Pcontrol.EntryUserPegawai(IDRole, "Pegawai" + idLast, "123456");
                        }
                        PegawaiEntity pegawai = new PegawaiEntity(IDRole, edNama.Text, edAlamat.Text, edEmail.Text, edNomor.Text, Pcontrol.getLastIdLogin());
                        if (Pcontrol.CekDataDuplikasi(pegawai) != 0)
                        {
                            MessageBox.Show("Maaf, data sudah ada." + Pcontrol.CekDataDuplikasi(pegawai), "Kesalahan", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        Pcontrol.EntryPegawai(pegawai);
                        cleartxt();
                        this.Hide();
                        FormPegawai myParent = (FormPegawai)this.Parent;
                        myParent.enable();
                    }
                }

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

                        int           IDRole  = Pcontrol.getIDRole(cmbJabatan.Text);
                        PegawaiEntity pegawai = new PegawaiEntity(IDRole, edNama.Text, edAlamat.Text, edEmail.Text, edNomor.Text);
                        //if (Pcontrol.CekDataDuplikasi(pegawai) > 1) //Masih error code pengecekan ini
                        //{
                        //    MessageBox.Show("Maaf, data sudah ada." + Pcontrol.CekDataDuplikasi(pegawai), "Kesalahan", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //    return;
                        //}
                        DialogResult dr = MessageBox.Show("Apakah Anda yakin akan mengupdate pegawai ini ?", "Pertanyaan",
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dr == DialogResult.Yes)
                        {
                            Pcontrol.EditPegawai(pegawai, int.Parse(txtID.Text));
                        }
                        cleartxt();
                        this.Hide();
                        FormPegawai myParent = (FormPegawai)this.Parent;
                        myParent.EnableEdit();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Kesalahan", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
 public void EditPegawai(PegawaiEntity baru, int id_pegawai)
 {
     tbl_pegawai.UpdatePegawai(baru.Id_role, baru.Nama_pegawai, baru.Alamat, baru.Email, baru.Nohp, id_pegawai);
 }
예제 #4
0
 public int CekDataDuplikasi(PegawaiEntity input)
 {
     return((int)tbl_pegawai.CekDataDuplikasi(input.Nama_pegawai, input.Email, input.Nohp));
 }
예제 #5
0
 public void EntryPegawai(PegawaiEntity input)
 {
     tbl_pegawai.EntryPegawai(input.Id_role, input.Nama_pegawai, input.Alamat, input.Email, input.Nohp, input.Id_login);
 }