private void btn_login_Click(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(txt_nik.Text) && !string.IsNullOrEmpty(txt_pass.Text)) { Karyawan _karyawan = new Karyawan(txt_nik.Text); if (!string.IsNullOrEmpty(_karyawan.password) && _karyawan.password == txt_pass.Text.ToString()) { Program.isLogin = true; Program.cNIK = txt_nik.Text; Program.cName = _karyawan.nama; Program.cLevel = _karyawan.level; this.Close(); } else { MessageBox.Show("Password Salah", "Informasi"); } } else { MessageBox.Show("NIK dan Password harus di isi", "Informasi", MessageBoxButtons.OK); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Informasi"); } }
private void btn_delete_Click(object sender, EventArgs e) { Karyawan _K = new Karyawan(txt_nik.Text); var hsl = MessageBox.Show("Hapus Data Karyawan?", "Warning", MessageBoxButtons.YesNo); if (hsl == DialogResult.Yes) { MessageBox.Show(_K.Delete().ToString() + " Data karyawan telah dihapus", "Informasi"); load_karyawan(); reset_default(); } }
private void form_login_Load(object sender, EventArgs e) { try { Karyawan test = new Karyawan(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Informasi"); this.Close(); } }
private void load_karyawan() { Karyawan _K = new Karyawan(); _K.Select(); dgv_karyawan.DataSource = _K.tbl_karyawan.Tables["tbl_karyawan"]; dgv_karyawan.Columns["nik_karyawan"].Width = 100; dgv_karyawan.Columns["nama_karyawan"].Width = 150; dgv_karyawan.Columns["pass"].Visible = false; dgv_karyawan.Columns["jabatan"].Width = 100; dgv_karyawan.Columns["alamat"].Width = 200; dgv_karyawan.Columns["memo"].Width = 200; dgv_karyawan.Columns["foto"].Visible = false; dgv_karyawan.Sort(dgv_karyawan.Columns["nik_karyawan"], ListSortDirection.Ascending); }
private void form_karyawan_Load(object sender, EventArgs e) { this.Location = new Point(0, 0); dgv_karyawan.ReadOnly = true; dgv_karyawan.AllowUserToAddRows = false; dgv_karyawan.AllowUserToDeleteRows = false; dgv_karyawan.SelectionMode = DataGridViewSelectionMode.FullRowSelect; reset_default(); try { var _karyawan = new Karyawan(); list_jabatan.Items.Clear(); list_jabatan.Items.AddRange(_karyawan.struktur); load_karyawan(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Informasi"); //this.Close(); } }
private void btn_save_Click(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(txt_nik.Text) && !string.IsNullOrEmpty(txt_nama.Text) && !string.IsNullOrEmpty(txt_pass.Text) && list_jabatan.SelectedIndex > -1) { string jabatan = (string)list_jabatan.Items[list_jabatan.SelectedIndex]; Karyawan _K = new Karyawan(txt_nik.Text, txt_nama.Text, txt_pass.Text, jabatan, txt_alamat.Text, txt_memo.Text, _img); if (this.Tag.ToString() == "new") { MessageBox.Show(_K.Insert().ToString() + " Data Karyawan telah berhasil ditambahkan", "Informasi"); load_karyawan(); int nPos = dgv_karyawan.Rows.Count - 1; dgv_karyawan.CurrentCell = dgv_karyawan.Rows[nPos].Cells[0]; dgv_karyawan.Rows[nPos].Selected = true; pos = nPos; } else if (this.Tag.ToString() == "edit") { MessageBox.Show(_K.Update(oldNik).ToString() + " Data Karyawan telah berhasil diupdate", "Informasi"); int nPos = dgv_karyawan.CurrentRow.Index; load_karyawan(); dgv_karyawan.CurrentCell = dgv_karyawan.Rows[nPos].Cells[0]; dgv_karyawan.Rows[nPos].Selected = true; pos = nPos; } reset_default(); } else { MessageBox.Show("Nik, Nama, Password, dan Jabatan harus di isi", "Informasi"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Informasi"); } }