コード例 #1
0
 private void btnSimpan_Click(object sender, EventArgs e)
 {
     try
     {
         var      diff    = (dtTanggal2.Value.Date - dtTanggal1.Value.Date).TotalDays;
         DateTime tanggal = dtTanggal1.Value;
         for (int i = 0; i <= diff; i++)
         {
             DateTime inputDate = tanggal.AddDays(i);
             if (fp.izins.Where(x => x.izin_tanggal.Equals(inputDate.Date) && x.pegawai_id.Equals(cbPegawai.SelectedValue.ToString())).Count() == 0)
             {
                 izin data = new izin();
                 data.pegawai_id      = cbPegawai.SelectedValue.ToString();
                 data.izin_tanggal    = inputDate.Date;
                 data.izin_jenis      = cbJenis.Text;
                 data.izin_keterangan = txtKeterangan.Text;
                 fp.izins.Add(data);
                 fp.SaveChanges();
             }
         }
         GetData();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     GroupAksi(true);
     GetSelectedRow();
 }
コード例 #2
0
ファイル: UcLog.cs プロジェクト: fajarlahhh/fingerprintsync
 private void btnHapus_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(String.Format("Anda akan menghapus semua data log di tahun\n\"{0}\"", dtTahun.Value.Year),
                         "Konfirmasi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         var log = fp.logs.Where(x => x.log_tanggal.Year.Equals(dtTahun.Value.Year)).ToList();
         fp.logs.RemoveRange(log);
         fp.SaveChanges();
     }
 }
コード例 #3
0
        private void btnSimpan_Click(object sender, EventArgs e)
        {
            try
            {
                if (aksi == "Tambah")
                {
                    var      diff    = (dtTanggal2.Value.Date - dtTanggal1.Value.Date).TotalDays;
                    DateTime tanggal = dtTanggal1.Value;
                    for (int i = 0; i <= diff; i++)
                    {
                        DateTime inputDate = tanggal.AddDays(i);
                        if (fp.liburs.Where(x => x.libur_tanggal.Equals(inputDate.Date)).Count() == 0)
                        {
                            libur data = new libur();
                            data.libur_tanggal    = inputDate.Date;
                            data.libur_keterangan = txtKeterangan.Text;
                            fp.liburs.Add(data);
                            fp.SaveChanges();
                        }
                    }
                    GetData();
                }
                else
                {
                    var libur = fp.liburs.Where(x => x.libur_tanggal.Equals(libur_id)).FirstOrDefault();

                    libur.libur_keterangan = txtKeterangan.Text;
                    fp.SaveChanges();

                    DataGridViewRow dataRow = dgHariLibur.Rows[rowIndex];
                    dataRow.Cells[0].Value = dtTanggal1.Value;
                    dataRow.Cells[1].Value = txtKeterangan.Text;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            GroupAksi(true);
            GetSelectedRow();
        }
コード例 #4
0
ファイル: UcMesin.cs プロジェクト: fajarlahhh/fingerprintsync
        private void btnSimpan_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (aksi == "Tambah")
                {
                    mesin data = new mesin();
                    data.mesin_nama = txtNama.Text;
                    data.mesin_ip   = txtIP.Text;
                    data.mesin_key  = txtKey.Text;
                    data.mesin_sn   = "123";
                    fp.mesins.Add(data);
                    fp.SaveChanges();
                    GetData();
                }
                else
                {
                    var mesin = fp.mesins.Where(x => x.mesin_id.Equals(mesin_id)).FirstOrDefault();
                    mesin.mesin_nama = txtNama.Text;
                    mesin.mesin_ip   = txtIP.Text;
                    mesin.mesin_key  = txtKey.Text;
                    mesin.mesin_sn   = "123";
                    fp.SaveChanges();

                    DataGridViewRow dataRow = dgMesin.Rows[rowIndex];
                    dataRow.Cells[1].Value = txtNama.Text;
                    dataRow.Cells[2].Value = txtIP.Text;
                    dataRow.Cells[3].Value = txtKey.Text;
                    dataRow.Cells[4].Value = "123";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            GroupAksi(true);
            GetSelectedRow();
        }
コード例 #5
0
        private void btnSimpan_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (fp.pegawais.Where(x => x.pegawai_nip.Equals(txtNIP.Text)).Count() > 0 && txtNIP.Text != pegawai_nip)
                {
                    MessageBox.Show("NIP sudah ada");
                    txtNIP.Focus();
                    return;
                }
                if (aksi == "Tambah")
                {
                    if (fp.pegawais.Where(x => x.pegawai_id.Equals(txtID.Text)).Count() > 0)
                    {
                        MessageBox.Show("ID sudah ada");
                        txtNIP.Focus();
                        return;
                    }
                    pegawai data = new pegawai();
                    data.pegawai_id            = txtID.Text;
                    data.pegawai_nip           = txtNIP.Text;
                    data.pegawai_nama          = txtNama.Text;
                    data.pegawai_panggilan     = txtPanggilan.Text;
                    data.pegawai_golongan      = txtGolongan.Text;
                    data.pegawai_jenis_kelamin = cbJenisKelamin.Text;
                    data.pegawai_izin          = cbHakAkses.SelectedIndex.ToString();
                    data.upload = false;
                    if (cbHakAkses.SelectedIndex == 1)
                    {
                        data.pegawai_sandi = "";
                    }
                    else
                    {
                        data.pegawai_sandi = txtSandi.Text;
                    }
                    fp.pegawais.Add(data);
                    fp.SaveChanges();

                    if (chkSync.Checked)
                    {
                        UploadKeMesin(txtID.Text);
                    }
                    GetData();
                }
                else
                {
                    var pegawai = fp.pegawais.Where(x => x.pegawai_id.Equals(pegawai_id)).FirstOrDefault();
                    pegawai.pegawai_nip           = txtNIP.Text;
                    pegawai.pegawai_nama          = txtNama.Text;
                    pegawai.pegawai_panggilan     = txtPanggilan.Text;
                    pegawai.pegawai_golongan      = txtGolongan.Text;
                    pegawai.pegawai_jenis_kelamin = cbJenisKelamin.Text;
                    pegawai.pegawai_izin          = cbHakAkses.SelectedIndex.ToString();
                    pegawai.upload = false;
                    if (cbHakAkses.SelectedIndex == 1)
                    {
                        pegawai.pegawai_sandi = "";
                    }
                    else
                    {
                        if (txtSandi.Text != "")
                        {
                            pegawai.pegawai_sandi = txtSandi.Text;
                        }
                    }
                    fp.SaveChanges();

                    if (chkSync.Checked)
                    {
                        UploadKeMesin(txtID.Text);
                    }

                    DataGridViewRow dataRow = dgPegawai.Rows[rowIndex];
                    dataRow.Cells[1].Value = txtNIP.Text;
                    dataRow.Cells[2].Value = txtNama.Text;
                    dataRow.Cells[3].Value = txtPanggilan.Text;
                    dataRow.Cells[4].Value = txtGolongan.Text;
                    dataRow.Cells[5].Value = cbJenisKelamin.Text;
                    dataRow.Cells[6].Value = cbHakAkses.Text;
                    dataRow.Cells[7].Value = txtSandi.Text;
                }
                txtSandi.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            GroupAksi(true);
            GetSelectedRow();
        }