private void btn_simpan_Click_1(object sender, EventArgs e) { karyawan k = new karyawan(); k.nik = txt_nik.Text; k.nama = txt_nama.Text; k.jenis_kelamin = cmb_jenis_kelamin.Text; k.agama = cmb_agama.Text; k.pendidikan = cmb_pendidikan.Text; k.jabatan = cmb_jabatan.Text; k.ttl = txt_ttl.Text; k.tgl_lahir = dtp_tgl_lahir.Value.ToString("yyyy-MM-dd"); k.pass = txt_pass.Text; if (k.nik == "") { MessageBox.Show("Nomor Induk Karyawan Kosong", "PESAN", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } else if ((k.nama == "") || (k.tgl_lahir == "") || (k.jabatan == "") || (k.jenis_kelamin == "") || (k.pass == "") || (k.pendidikan == "") || (k.ttl == "")) { MessageBox.Show("Teks Kosong, Isikan Kembali", "PESAN", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } if (new karyawan_dao().insertdata(k)) { this.DialogResult = DialogResult.OK; } }
private void frm_kasir_Load(object sender, EventArgs e) { lbl_kd_kasir.Text = kd_nik; binding(); txt_kd_berikut.Hide(); karyawan k = new karyawan(); k.nik = lbl_kd_kasir.Text; DataSet ds = new karyawan_dao().carinama_kasir(k); lbl_nama_kasir.Text = ds.Tables[0].Rows[0][0].ToString(); lbl_kd_kasir.Hide(); }
public bool hapusdata(karyawan k) { bool stat = false; conn.Open(); MySqlCommand query = new MySqlCommand(); query.Connection = conn; query.CommandText = "DELETE FROM t_karyawan WHERE `Nik`= '" + k.nik + "'"; query.ExecuteNonQuery(); stat = true; conn.Close(); return(stat); }
public bool insertdata(karyawan k) { bool stat = false; conn.Open(); MySqlCommand query = new MySqlCommand(); query.Connection = conn; query.CommandText = "INSERT INTO t_karyawan VALUES ('" + k.nik + "'," + "'" + k.nama + "'," + "'" + k.jenis_kelamin + "'," + "'" + k.ttl + "'," + "'" + k.tgl_lahir + "'," + "'" + k.agama + "'," + "'" + k.pendidikan + "'," + "'" + k.jabatan + "'," + "'" + k.pass + "')"; query.ExecuteNonQuery(); stat = true; conn.Close(); return(stat); }
public DataSet carinama_kasir(karyawan k) { DataSet ds = new DataSet(); conn.Open(); MySqlCommand query = new MySqlCommand(); query.Connection = conn; query.CommandText = "SELECT Nama_Karyawan FROM t_karyawan WHERE Nik = '" + k.nik + "' "; MySqlDataAdapter data = new MySqlDataAdapter(query); data.Fill(ds, "db_indomart"); conn.Close(); return(ds); }
public DataSet carijabatan(karyawan k) { DataSet ds = new DataSet(); conn.Open(); MySqlCommand query = new MySqlCommand(); query.Connection = conn; query.CommandText = "SELECT * FROM t_karyawan WHERE Jabatan = '" + k.jabatan + "' "; MySqlDataAdapter data = new MySqlDataAdapter(query); data.Fill(ds, "db_indomart"); conn.Close(); return(ds); }
private void btn_ubah_Click(object sender, EventArgs e) { karyawan kry = new karyawan(); kry.nik = txt_nik.Text; kry.nama = txt_nama.Text; kry.jenis_kelamin = cmb_jenis_kelamin.Text; kry.ttl = txt_ttl.Text; kry.tgl_lahir = dtp_tanggal_lahir.Value.ToString("yyyy-MM-dd"); kry.agama = cmb_agama.Text; kry.pendidikan = cmb_pendidikan.Text; kry.jabatan = cmb_jabatan.Text; if (new karyawan_dao().updatedata(kry)) { MessageBox.Show("Data Berhasil Dirubah"); binding(); } }
public ActionResult Create(karyawan karyawan) { try { if (ModelState.IsValid) { db.karyawan.Add(karyawan); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DbEntityValidationException e) { var newException = new FormattedDbEntityValidationException(e); //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(RedirectToAction("Index")); }
public ActionResult Create(user_login user_Login) { try { var check = (from s in db.user_login where s.user_id == user_Login.user_id select s).FirstOrDefault(); if (check == null) { var keyNew = PasswordHashHelper.GeneratePassword(10); var pass = PasswordHashHelper.EncodePassword(user_Login.user_id + DateTime.Now.Year.ToString(), keyNew); user_login _Login = new user_login { user_id = user_Login.user_id, password = pass, vcode = keyNew, role = user_Login.role, status = user_Login.status, date_created = DateTime.Now }; karyawan karyawan = new karyawan { user_id = _Login.user_id }; db.user_login.Add(_Login); db.karyawan.Add(karyawan); db.SaveChanges(); ModelState.Clear(); return(Json("0", JsonRequestBehavior.AllowGet)); } return(Json("1", JsonRequestBehavior.AllowGet)); } catch (DbEntityValidationException e) { return(Json("2", JsonRequestBehavior.AllowGet)); } }
private void btn_hapus_Click_1(object sender, EventArgs e) { if (txt_nik.Text == "") { MessageBox.Show("NIK Kosong", "PESAN", MessageBoxButtons.OK); return; } DialogResult dialogresult = MessageBox.Show("Apakah Data Akan Dihapus ?", "PESAN", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (dialogresult == DialogResult.Yes) { karyawan k = new karyawan(); k.nik = txt_nik.Text; if (new karyawan_dao().hapusdata(k)) { MessageBox.Show("Data Berhasil Dihapus"); binding(); } } }
private void btn_cari_Click(object sender, EventArgs e) { karyawan k = new karyawan(); if (cmb_cari.Text == "NIK") { try { k.nik = txt_cari.Text; DataSet ds = new karyawan_dao().carikode(k); dgv_karyawan.DataSource = ds; dgv_karyawan.DataMember = "db_indomart"; } catch { MessageBox.Show("Not Found"); } } else if (cmb_cari.Text == "Nama") { k.nama = txt_cari.Text; DataSet ds = new karyawan_dao().carinama(k); dgv_karyawan.DataSource = ds; dgv_karyawan.DataMember = "db_indomart"; } else if (cmb_cari.Text == "Jabatan") { k.jabatan = txt_cari.Text; DataSet ds = new karyawan_dao().carijabatan(k); dgv_karyawan.DataSource = ds; dgv_karyawan.DataMember = "db_indomart"; } }
public bool updatedata(karyawan k) { bool stat = false; conn.Open(); MySqlCommand query = new MySqlCommand(); query.Connection = conn; query.CommandText = "UPDATE t_karyawan " + "SET Nama_Karyawan='" + k.nama + "'," + "Jenis_Kelamin='" + k.jenis_kelamin + "'," + "ttl = '" + k.ttl + "'," + "tgl_lahir='" + k.tgl_lahir + "'," + "Agama='" + k.agama + "'," + "Pendidikan='" + k.pendidikan + "'," + "Jabatan='" + k.jabatan + "' " + "WHERE Nik='" + k.nik + "'"; query.ExecuteNonQuery(); stat = true; conn.Close(); return(stat); }