Пример #1
0
        private void btnSimpan_Click(object sender, EventArgs e)
        {
            StringBuilder sb     = new StringBuilder();
            bool          IsPass = true;

            if (string.IsNullOrEmpty(textBoxKeterangan.Text))
            {
                IsPass = false;
                sb.Append("- Keterangan harus diisi \n");
            }

            if (string.IsNullOrEmpty(textBoxJumlah.Text))
            {
                IsPass = false;
                sb.Append("- Jumlah harus diisi \n");
            }

            if (!string.IsNullOrEmpty(textBoxJumlah.Text))
            {
                decimal result;
                bool    IsHargaBeliPass = decimal.TryParse(textBoxJumlah.Text, out result);
                if (!IsHargaBeliPass)
                {
                    IsPass = false;
                    sb.Append("- Jumlah harus angka \n");
                }
            }

            if (string.IsNullOrEmpty(comboBoxJenis.Text))
            {
                IsPass = false;
                sb.Append("- Jenis harus diisi \n");
            }

            if (!IsPass)
            {
                MessageBox.Show(sb.ToString(), "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            TransaksiInternal transaksiInternal = new TransaksiInternal()
            {
                Keterangan = textBoxKeterangan.Text,
                Tanggal    = dateTimePicker.Value,
                Jumlah     = decimal.Parse(textBoxJumlah.Text),
                Jenis      = comboBoxJenis.Text
            };

            transaksiInternalService.Post(transaksiInternal);

            this.Dispose();
            this.ParentForm.dataGridViewTransaksiInternal.DataSource = transaksiInternalService.Get();
        }
 public void Delete(TransaksiInternal transaksiInternal)
 {
     transaksiInternalRepository.Delete(transaksiInternal);
 }
        //public decimal GetLastTotal()
        //{
        //    return transaksiInternalRepository.GetLastTotal();
        //}

        public void Put(TransaksiInternal transaksiInternal)
        {
            transaksiInternalRepository.Put(transaksiInternal);
        }