Example #1
0
        private void btnSimpan_Click(object sender, EventArgs e)
        {
            if (WithErrors())
            {
                val.validateMaskedTextBox(mTxtJam, errorProvider1, "Jam harus diisi.");
                val.validateComboBox(cbAsal,errorProvider1, "Kota asal harus dipilih.");
                val.validateComboBox(cbTujuan, errorProvider1, "Kota tujuan harus dipilih.");
                val.validateComboBox(cbArmada, errorProvider1, "Armada harus dipilih.");
                val.validateComboBox(cbSupir, errorProvider1, "Supir harus dipilih.");

                return;
            }
            else
            {
                if (Convert.ToInt32(txtId.Text) == 0)
                {
                    if ((from a in context.ADM_JADWALs where a.TGL_BERANGKAT == Convert.ToDateTime(dtpTgl.Text) && a.ID_KENDARAAN == Convert.ToInt32(cbArmada.SelectedValue) select a).Any())
                        MessageBox.Show("Jadwal untuk armada bersangkutan sudah ada.", "Jadwal", MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    else
                    {
                        var jadwal = new ADM_JADWAL();
                        jadwal.TGL_BERANGKAT = Convert.ToDateTime(dtpTgl.Text);
                        jadwal.JAM = TimeSpan.Parse(mTxtJam.Text);
                        jadwal.KOTA_ASAL = Convert.ToInt32(cbAsal.SelectedValue);
                        jadwal.KOTA_TUJUAN = Convert.ToInt32(cbTujuan.SelectedValue);
                        jadwal.ID_KENDARAAN = Convert.ToInt32(cbArmada.SelectedValue);
                        jadwal.ID_SUPIR = Convert.ToInt32(cbSupir.SelectedValue);
                        jadwal.CARTER = chkCarter.Checked;
                        jadwal.ID_INDEX_GAJI = chkCarter.Checked ? 2 : 1;
                        context.ADM_JADWALs.InsertOnSubmit(jadwal);
                    }
                }
                else
                {
                    var query = from a in context.ADM_JADWALs
                                where a.ID_JADWAL == Convert.ToInt32(txtId.Text)
                                select a;
                    foreach (var a in query)
                    {
                        a.TGL_BERANGKAT = Convert.ToDateTime(dtpTgl.Text);
                        a.JAM = TimeSpan.Parse(mTxtJam.Text);
                        a.KOTA_ASAL = Convert.ToInt32(cbAsal.SelectedValue);
                        a.KOTA_TUJUAN = Convert.ToInt32(cbTujuan.SelectedValue);
                        a.ID_KENDARAAN = Convert.ToInt32(cbArmada.SelectedValue);
                        a.ID_SUPIR = Convert.ToInt32(cbSupir.SelectedValue);
                        a.CARTER = chkCarter.Checked;
                        a.ID_INDEX_GAJI = chkCarter.Checked ? 2 : 1;
                    }
                }
                context.SubmitChanges();
                Close();
            }
        }
Example #2
0
 partial void DeleteADM_JADWAL(ADM_JADWAL instance);
Example #3
0
 partial void UpdateADM_JADWAL(ADM_JADWAL instance);
Example #4
0
 partial void InsertADM_JADWAL(ADM_JADWAL instance);
Example #5
0
		private void detach_ADM_JADWALs(ADM_JADWAL entity)
		{
			this.SendPropertyChanging();
			entity.REF_SUPIR = null;
		}
Example #6
0
		private void attach_ADM_JADWALs(ADM_JADWAL entity)
		{
			this.SendPropertyChanging();
			entity.REF_STATUS = this;
		}
Example #7
0
		private void attach_ADM_JADWALs1(ADM_JADWAL entity)
		{
			this.SendPropertyChanging();
			entity.REF_KOTA1 = this;
		}
Example #8
0
		private void attach_ADM_JADWALs(ADM_JADWAL entity)
		{
			this.SendPropertyChanging();
			entity.REF_INDEX_GAJI = this;
		}