Ejemplo n.º 1
0
        private void FrmSPD_Load(object sender, EventArgs e)
        {
            List <Pegawai>           pegawai     = DbQuery.GetPegawai();
            Dictionary <int, string> dCmbPegawai = new Dictionary <int, string>();

            dCmbPegawai.Add(-1, "Pilih Pegawai");
            foreach (var p in pegawai)
            {
                dCmbPegawai.Add(p.id, p.nip + " | " + p.nama);
            }
            cmbPegawai.DataSource    = new BindingSource(dCmbPegawai, null);
            cmbPegawai.DisplayMember = "Value";
            cmbPegawai.ValueMember   = "Key";

            List <Transport>         transport     = DbQuery.GetTransport();
            Dictionary <int, string> dCmbTransport = new Dictionary <int, string>();

            dCmbTransport.Add(-1, "Pilih Transport");
            foreach (var t in transport)
            {
                dCmbTransport.Add(t.id, t.transport);
            }
            cmbTrasportasi.DataSource    = new BindingSource(dCmbTransport, null);
            cmbTrasportasi.DisplayMember = "Value";
            cmbTrasportasi.ValueMember   = "Key";

            Dictionary <int, string> dCmbKotaBerangkat = new Dictionary <int, string>();

            dCmbKotaBerangkat.Add(438, "Kota Palu");
            cmbBerangkat.DataSource    = new BindingSource(dCmbKotaBerangkat, null);
            cmbBerangkat.DisplayMember = "Value";
            cmbBerangkat.ValueMember   = "Key";

            List <Provinsi>             provinsi     = DbQuery.GetProvinsi();
            Dictionary <string, string> dCmbProvinsi = new Dictionary <string, string>();

            dCmbProvinsi.Add("", "Pilih Provinsi");
            foreach (var p in provinsi)
            {
                dCmbProvinsi.Add(p.kode, p.nama);
            }
            cmbProvinsi.DataSource    = new BindingSource(dCmbProvinsi, null);
            cmbProvinsi.DisplayMember = "Value";
            cmbProvinsi.ValueMember   = "Key";

            if (aksi == "update")
            {
                foreach (var s in spd)
                {
                    txtKode.Text                 = s.kode;
                    txtMaksud.Text               = s.maksud;
                    txtPenjabat.Text             = s.penjabat;
                    txtTJabatan.Text             = s.t_jabatan;
                    txtLama.Text                 = s.lama.ToString();
                    txtNoSuratTuga.Text          = s.no_surat;
                    txtAkun.Text                 = s.akun;
                    cmbTb.SelectedIndex          = cmbTb.FindStringExact(s.tb);
                    cmbPegawai.SelectedValue     = s.pegawai_id;
                    cmbTrasportasi.SelectedValue = s.trasport_id;
                    cmbTujuan.SelectedValue      = s.t_tujuan_id;
                    if (s.tgl_berangkat != "")
                    {
                        dtTglBerangkat.Value = DateTime.ParseExact(s.tgl_berangkat, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                    }
                    if (s.tgl_kembali != "")
                    {
                        dtTglKembali.Value = DateTime.ParseExact(s.tgl_kembali, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                    }
                    if (s.tgl_tugas != "")
                    {
                        dtTglSurat.Value = DateTime.ParseExact(s.tgl_tugas, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                    }

                    Dictionary <int, string> dCmbKotaTujuan = new Dictionary <int, string>();
                    dCmbKotaTujuan.Add(s.t_tujuan_id, s.t_tujuan);
                    cmbTujuan.DataSource    = new BindingSource(dCmbKotaTujuan, null);
                    cmbTujuan.DisplayMember = "Value";
                    cmbTujuan.ValueMember   = "Key";
                }

                foreach (var b in biaya)
                {
                    lbTotalHarian.Text      = " = Rp" + b.h_total.ToString("N1", CultureInfo.InvariantCulture);
                    txtHarian.Text          = b.harian.ToString();
                    txtHLama.Text           = b.h_lama.ToString();
                    lblTotalPenginapan.Text = " = Rp" + b.p_total.ToString("N1", CultureInfo.InvariantCulture);
                    txtPenginapan.Text      = b.penginapan.ToString();
                    txtP_lama.Text          = b.p_lama.ToString();
                    txtTransport.Text       = b.transport_pp.ToString();
                    txtLTransport.Text      = b.transport_loak.ToString();
                    txtDamri.Text           = b.damri.ToString();
                    txtLain_lain.Text       = b.lain_lain.ToString();
                }

                if (pengikut.ElementAtOrDefault(0) != null)
                {
                    gpPengikut1.Enabled        = true;
                    cbPengikut1.Checked        = true;
                    cmbPengikut1.SelectedValue = pengikut[0].pegawai;
                    txtKetPengikut1.Text       = pengikut[0].ket;
                }

                if (pengikut.ElementAtOrDefault(1) != null)
                {
                    gpPengikut2.Enabled        = true;
                    cbPengikut2.Checked        = true;
                    cmbPengikut2.SelectedValue = pengikut[1].pegawai;
                    txtKetPengikut2.Text       = pengikut[1].ket;
                }

                if (pengikut.ElementAtOrDefault(2) != null)
                {
                    gpPengikut3.Enabled        = true;
                    cbPengikut3.Checked        = true;
                    cmbPengikut3.SelectedValue = pengikut[2].pegawai;
                    txtKetPengikut3.Text       = pengikut[2].ket;
                }
            }
        }