private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                //if (txtnama.CheckEmpty() && txtaddr1.CheckEmpty())
                //{
                //    return;
                //}
                IList <Control> lstCtrlEmptyCheck = new List <Control>();
                lstCtrlEmptyCheck.Add(txtappdate);
                lstCtrlEmptyCheck.Add(txtnama);
                lstCtrlEmptyCheck.Add(txticno);
                lstCtrlEmptyCheck.Add(txtnolesen);
                //lstCtrlEmptyCheck.Add(cbbangsa);
                lstCtrlEmptyCheck.Add(txtaddr1);
                lstCtrlEmptyCheck.Add(txtaddr2);
                //lstCtrlEmptyCheck.Add(txtaddr3);
                lstCtrlEmptyCheck.Add(txtbandar);
                lstCtrlEmptyCheck.Add(txtposkod);
                lstCtrlEmptyCheck.Add(cbnegeri);
                //lstCtrlEmptyCheck.Add(cbdaerah);
                //lstCtrlEmptyCheck.Add(cbdun);
                //lstCtrlEmptyCheck.Add(cbparlimen);
                lstCtrlEmptyCheck.Add(txthometel);
                lstCtrlEmptyCheck.Add(txtofficetel);
                lstCtrlEmptyCheck.Add(txthptel);
                lstCtrlEmptyCheck.Add(txtemail);

                if (WFUtils.CheckControllCollectionEmpty(lstCtrlEmptyCheck))
                {
                    return;
                }

                bool    IsNew   = false;
                appinfo appinfo = AppInfoRepo.GetBy(appinfo_id);
                if (appinfo == null)
                {
                    appinfo    = new appinfo();
                    appinfo_id = Convert.ToInt32(WFUtils.DateTimeToUnixTimestamp(DateTime.Now));
                    IsNew      = true;
                    refno_new  = GenerateRefNo(cbnegeri.SelectedValue.ToString());
                }

                appinfo.id      = appinfo_id;
                appinfo.appdate = txtappdate.Text;
                appinfo.nama    = txtnama.Text;
                appinfo.type_id = 0;//txttype_id.Text;
                appinfo.icno    = txticno.Text;
                appinfo.nolesen = txtnolesen.Text;
                appinfo.bangsa  = cbbangsa.SelectedValue == null ? "" : cbbangsa.SelectedValue.ToString();
                appinfo.addr1   = txtaddr1.Text;
                appinfo.addr2   = txtaddr2.Text;
                appinfo.addr3   = txtaddr3.Text;
                appinfo.bandar  = txtbandar.Text;
                appinfo.daerah  = cbdaerah.SelectedValue == null ? "" : cbdaerah.SelectedValue.ToString();
                appinfo.dun     = cbdun.SelectedValue == null ? "" : cbdun.SelectedValue.ToString();
                int?     sparlimen = (int?)cbparlimen.SelectedValue;
                parlimen parlimen  = ParlimenRepo.GetBy(sparlimen);
                appinfo.parlimen      = parlimen == null ? null : (int?)parlimen.Id;
                appinfo.poskod        = txtposkod.Text;
                appinfo.negeri        = cbnegeri.SelectedValue.ToString();
                appinfo.hometel       = txthometel.Text;
                appinfo.officetel     = txtofficetel.Text;
                appinfo.hptel         = txthptel.Text;
                appinfo.sts_bck       = 0;
                appinfo.status        = 0;
                appinfo.sop           = 0;
                appinfo.date_approved = DateTime.MinValue;
                appinfo.approved_by   = "";
                //appinfo.faks = txtfaks.Text;
                appinfo.email = txtemail.Text;
                //appinfo.kelompok = txtkelompok.Text;
                appinfo.refno_new = refno_new;// GenerateRefNo(appinfo.negeri);

                if (IsNew)
                {
                    try
                    {
                        appinfo.created   = DateTime.Now;
                        appinfo.createdby = VariableSettingRepo.GetBy("UserKeyIn").Value;
                        AppInfoRepo.Create(appinfo);
                        MessageBox.Show("Data berhasil disimpan [" + appinfo.refno_new + "]");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.GetFullMessage());
                    }
                }
                else
                {
                    try
                    {
                        AppInfoRepo.Edit(appinfo);
                        MessageBox.Show("Data berhasil disimpan [" + appinfo.refno_new + "]");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.GetFullMessage());
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetFullMessage() + " - Harap periksa data input kembali");
                return;
            }
            button2.PerformClick();
        }
Exemple #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (appinfo_id <= 0)
                {
                    MessageBox.Show("Harap masukan data dari Maklumat Pemohon.");
                    return;
                }

                IList <Control> lstCtrlEmptyCheck = new List <Control>();
                lstCtrlEmptyCheck.Add(txtaddr1);
                lstCtrlEmptyCheck.Add(txtaddr2);
                lstCtrlEmptyCheck.Add(cbnegeri);
                //lstCtrlEmptyCheck.Add(cbdaerah);
                //lstCtrlEmptyCheck.Add(cbdun);
                //lstCtrlEmptyCheck.Add(cbparlimen);
                lstCtrlEmptyCheck.Add(txtnolot);
                lstCtrlEmptyCheck.Add(txtluasmatang);
                lstCtrlEmptyCheck.Add(cbsyarattanah);
                lstCtrlEmptyCheck.Add(txtnolesen);
                lstCtrlEmptyCheck.Add(cbjenishakmiliktanah);
                lstCtrlEmptyCheck.Add(cbpengurusan);
                lstCtrlEmptyCheck.Add(cbpemilikan);

                if (WFUtils.CheckControllCollectionEmpty(lstCtrlEmptyCheck))
                {
                    return;
                }

                bool     IsNew    = false;
                makkebun makkebun = MakkebunRepo.GetBy(id_makkebun);
                if (makkebun == null)
                {
                    makkebun = new makkebun();
                    IsNew    = true;
                }
                makkebun.appinfo_id    = appinfo_id;
                makkebun.addr1         = txtaddr1.Text;
                makkebun.addr2         = txtaddr2.Text;
                makkebun.addr3         = txtaddr3.Text;
                makkebun.catatan       = txtcatatan.Text;
                makkebun.luaslesen     = Convert.ToDouble(string.IsNullOrEmpty(txtluaslesen.Text) ? 0 : Convert.ToDouble(txtluaslesen.Text));
                makkebun.luasmatang    = Convert.ToDouble(txtluasmatang.Text);
                makkebun.nolesen       = txtnolesen.Text;
                makkebun.nolot         = txtnolot.Text;
                makkebun.tarikhtebang  = txttarikhtebang.Text;
                makkebun.negeri        = cbnegeri.SelectedValue.ToString();
                makkebun.daerah        = cbdaerah.SelectedValue == null ? "" : cbdaerah.SelectedValue.ToString();
                makkebun.dun           = cbdun.SelectedValue == null ? "" : cbdun.SelectedValue.ToString();
                makkebun.parlimen      = ParlimenRepo.GetParlimenIDBy(cbparlimen.SelectedValue.ToString());
                makkebun.syarattanah   = cbsyarattanah.SelectedValue.ToString();
                makkebun.hakmiliktanah = cbjenishakmiliktanah.SelectedValue.ToString();
                makkebun.pemilikan     = cbpemilikan.SelectedValue.ToString();
                makkebun.pengurusan    = cbpengurusan.SelectedValue.ToString();
                makkebun.tncr          = cbtncr.SelectedValue.ToString();
                makkebun.tebang        = rbSudah.Checked ? "SUDAH" : rbBelum.Checked ? "BELUM" : "";


                if (IsNew)
                {
                    try
                    {
                        makkebun.created   = DateTime.Now;
                        makkebun.createdby = VariableSettingRepo.GetBy("UserKeyIn").Value;
                        MakkebunRepo.Create(makkebun);
                        MessageBox.Show("Data berhasil disimpan [" + refno_new + " | " + txtnolot.Text + "]");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.GetFullMessage());
                    }
                }
                else
                {
                    try
                    {
                        MakkebunRepo.Edit(makkebun);
                        MessageBox.Show("Data berhasil disimpan [" + refno_new + " | " + txtnolot.Text + "]");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.GetFullMessage());
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetFullMessage() + " - Harap periksa data input kembali");
                return;
            }
            BindGrid(page);

            btnReset.PerformClick();
        }