private void setKodeKantorToolStripMenuItem_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; updater.DoUpdate(false); FormSetKodeKantor setKantor = new FormSetKodeKantor(); setKantor.StartPosition = FormStartPosition.CenterParent; setKantor.ShowDialog(this); }
private void FormMain_Load(object sender, EventArgs e) { this.Activate(); try { var parser = new FileIniDataParser(); IniData data = parser.ReadFile("app.ini"); this.Text = this.Text + " v" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + " - " + data["Sekolah"]["NamaSekolah"] + ", " + data["Sekolah"]["LokasiSekolah"]; if (string.IsNullOrEmpty(data["Sekolah"]["IDSekolah"]) == true) { FormSetKodeKantor setKantor = new FormSetKodeKantor(); setKantor.StartPosition = FormStartPosition.CenterParent; setKantor.ShowDialog(this); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private async Task PostingPegawaiAsync() { try { Cursor.Current = Cursors.WaitCursor; if (string.IsNullOrEmpty(kantor)) { FormSetKodeKantor setKantor = new FormSetKodeKantor(); setKantor.StartPosition = FormStartPosition.CenterParent; setKantor.ShowDialog(this); return; } lblProses.Invoke(new Action(() => lblProses.Text = "Mengambil data pegawai")); var pegawai = fp.pegawais.ToList(); int jml = pegawai.Count(); int i = 1; string hapus = ""; lblProses.Invoke(new Action(() => lblProses.Text = "Menghapus data pegawai di web")); using (var client = new HttpClient()) { using (HttpResponseMessage response = await client.DeleteAsync(url + "hapuspegawai/" + kantor)) { using (HttpContent content = response.Content) { hapus = await content.ReadAsStringAsync(); } } } if (!hapus.Contains("berhasil")) { MessageBox.Show("Terjadi kesalahan\n" + hapus); Close(); } //string result = ""; int no = 0; int noGagal = 0; gagal.Clear(); foreach (var row in pegawai) { IEnumerable <KeyValuePair <string, string> > queries = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("pegawai_nip", row.pegawai_nip), new KeyValuePair <string, string>("pegawai_nama", row.pegawai_nama), new KeyValuePair <string, string>("pegawai_golongan", row.pegawai_golongan), new KeyValuePair <string, string>("pegawai_jenis_kelamin", row.pegawai_jenis_kelamin), new KeyValuePair <string, string>("kantor_id", kantor) }; HttpContent qContent = new FormUrlEncodedContent(queries); string upload = ""; using (var client = new HttpClient()) { using (HttpResponseMessage response = await client.PostAsync(url + "tambahpegawai", qContent)) { using (HttpContent content = response.Content) { upload = await content.ReadAsStringAsync(); } } } string hasil = "berhasil"; if (!upload.Contains("berhasil")) { ++noGagal; gagal.Add(row.pegawai_id); hasil = "gagal"; } lblProses.Invoke(new Action(() => lblProses.Text = ++no + ". Upload data pegawai " + row.pegawai_panggilan + " " + hasil)); int percentage = i * 100 / jml; progressBar.Value = percentage; i += 1; } if (gagal.Count() > 0) { await UploadGagalAsync(); return; } else { MessageBox.Show("Berhasil upload semua data pegawai", "Result"); Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private async Task PostingAbsenAsync() { try { Cursor.Current = Cursors.WaitCursor; if (string.IsNullOrEmpty(kantor)) { FormSetKodeKantor setKantor = new FormSetKodeKantor(); setKantor.StartPosition = FormStartPosition.CenterParent; setKantor.ShowDialog(this); return; } lblProses.Invoke(new Action(() => lblProses.Text = "Mengambil data pegawai")); var absen = fp.absens.Join(fp.pegawais, a => a.pegawai_id, b => b.pegawai_id, (a, b) => new { abs = a, peg = b }).Where(x => x.abs.absen_tanggal >= tgl1 && x.abs.absen_tanggal <= tgl2).ToList(); int jml = absen.Count(); int i = 1; if (jml == 0) { MessageBox.Show("Tidak ada data absen"); Close(); return; } int no = 0; int noGagal = 0; foreach (var row in absen) { string upload = ""; IEnumerable <KeyValuePair <string, string> > queries = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("pegawai_nip", row.peg.pegawai_nip), new KeyValuePair <string, string>("absen_tanggal", row.abs.absen_tanggal.ToString("yyyy-MM-dd")), new KeyValuePair <string, string>("absen_hari", row.abs.absen_hari), new KeyValuePair <string, string>("absen_izin", row.abs.absen_izin), new KeyValuePair <string, string>("absen_telat", row.abs.absen_telat.ToString()), new KeyValuePair <string, string>("absen_masuk", row.abs.absen_masuk.ToString()), new KeyValuePair <string, string>("absen_pulang", row.abs.absen_pulang.ToString()), new KeyValuePair <string, string>("absen_istirahat", row.abs.absen_istirahat.ToString()), new KeyValuePair <string, string>("absen_kembali", row.abs.absen_kembali.ToString()), new KeyValuePair <string, string>("absen_lembur", row.abs.absen_lembur.ToString()), new KeyValuePair <string, string>("absen_lembur_pulang", row.abs.absen_lembur_pulang.ToString()), new KeyValuePair <string, string>("kantor_id", kantor) }; HttpContent qContent = new FormUrlEncodedContent(queries); using (var client = new HttpClient()) { using (HttpResponseMessage response = await client.PostAsync(url + "tambahabsen", qContent)) { using (HttpContent content = response.Content) { upload = await content.ReadAsStringAsync(); } } } string hasil = "BERHASIL"; if (!upload.Contains("berhasil")) { ++noGagal; gagal.Add(row.peg.pegawai_id); hasil = "GAGAL"; } lblProses.Invoke(new Action(() => lblProses.Text = ++no + ". Upload data absensi " + row.peg.pegawai_panggilan + " " + row.abs.absen_tanggal.ToString("dd MMMM yyyy") + " " + hasil)); int percentage = i * 100 / jml; progressBar.Value = percentage; i += 1; } if (gagal.Count() > 0) { await UploadGagalAsync(); return; } else { MessageBox.Show("Berhasil upload semua data absensi", "Result"); Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }