private void PreviewReport() { var periode = string.Empty; IReportStokProdukBll reportBll = new ReportStokProdukBll(_log); IList <ReportPenyesuaianStokProduk> listOfReportPenyesuaianStokProduk = new List <ReportPenyesuaianStokProduk>(); IList <string> listOfAlasanPenyesuaianStokId = new List <string>(); if (chkBoxTitle.Checked) { listOfAlasanPenyesuaianStokId = GetAlasanPenyesuaianStokId(_listOfAlasanPenyesuaianStok); if (listOfAlasanPenyesuaianStokId.Count == 0) { MsgHelper.MsgWarning("Minimal 1 alasan harus dipilih"); return; } } if (rdoTanggal.Checked) { if (!DateTimeHelper.IsValidRangeTanggal(dtpTanggalMulai.Value, dtpTanggalSelesai.Value)) { MsgHelper.MsgNotValidRangeTanggal(); return; } var tanggalMulai = DateTimeHelper.DateToString(dtpTanggalMulai.Value); var tanggalSelesai = DateTimeHelper.DateToString(dtpTanggalSelesai.Value); periode = dtpTanggalMulai.Value == dtpTanggalSelesai.Value ? string.Format("Periode : {0}", tanggalMulai) : string.Format("Periode : {0} s.d {1}", tanggalMulai, tanggalSelesai); listOfReportPenyesuaianStokProduk = reportBll.GetPenyesuaianStokByTanggal(dtpTanggalMulai.Value, dtpTanggalSelesai.Value); } else { periode = string.Format("Periode : {0} {1}", cmbBulan.Text, cmbTahun.Text); var bulan = cmbBulan.SelectedIndex + 1; var tahun = int.Parse(cmbTahun.Text); listOfReportPenyesuaianStokProduk = reportBll.GetPenyesuaianStokByBulan(bulan, tahun); } if (listOfAlasanPenyesuaianStokId.Count > 0 && listOfReportPenyesuaianStokProduk.Count > 0) { listOfReportPenyesuaianStokProduk = listOfReportPenyesuaianStokProduk.Where(f => listOfAlasanPenyesuaianStokId.Contains(f.alasan_penyesuaian_stok_id)) .ToList(); } if (listOfReportPenyesuaianStokProduk.Count > 0) { var reportDataSource = new ReportDataSource { Name = "ReportPenyesuaianStok", Value = listOfReportPenyesuaianStokProduk }; var parameters = new List <ReportParameter>(); parameters.Add(new ReportParameter("periode", periode)); base.ShowReport(this.Text, "RvPenyesuaianStok", reportDataSource, parameters); } else { MsgHelper.MsgInfo("Maaf laporan data penyesuaian stok tidak ditemukan"); } }
protected override void Simpan() { if (this._customer == null || txtCustomer.Text.Length == 0) { MsgHelper.MsgWarning("'Customer' tidak boleh kosong !"); txtCustomer.Focus(); return; } var total = SumGrid(this._listOfItemJual); if (!(total > 0)) { MsgHelper.MsgWarning("Anda belum melengkapi inputan data produk !"); return; } if (rdoKredit.Checked) { if (!DateTimeHelper.IsValidRangeTanggal(dtpTanggal.Value, dtpTanggalTempo.Value)) { MsgHelper.MsgNotValidRangeTanggal(); return; } total = NumberHelper.StringToDouble(lblTotal.Text); if (this._customer != null) { if (this._customer.plafon_piutang > 0) { if (!(this._customer.plafon_piutang >= (total + this._customer.sisa_piutang))) { var msg = string.Empty; if (this._customer.sisa_piutang > 0) { msg = "Maaf, maksimal plafon piutang customer '{0}' adalah : {1}" + "\nSaat ini customer '{0}' masih mempunyai piutang sebesar : {2}"; msg = string.Format(msg, this._customer.nama_customer, NumberHelper.NumberToString(this._customer.plafon_piutang), NumberHelper.NumberToString(this._customer.sisa_piutang)); } else { msg = "Maaf, maksimal plafon piutang customer '{0}' adalah : {1}"; msg = string.Format(msg, this._customer.nama_customer, NumberHelper.NumberToString(this._customer.plafon_piutang)); } MsgHelper.MsgWarning(msg); return; } } } } if (!MsgHelper.MsgKonfirmasi("Apakah proses ingin dilanjutkan ?")) { return; } if (_isNewData) { _jual = new JualProduk(); } _jual.pengguna_id = this._pengguna.pengguna_id; _jual.Pengguna = this._pengguna; _jual.customer_id = this._customer.customer_id; _jual.Customer = this._customer; _jual.nota = txtNota.Text; _jual.tanggal = dtpTanggal.Value; _jual.tanggal_tempo = DateTimeHelper.GetNullDateTime(); _jual.is_tunai = rdoTunai.Checked; if (rdoKredit.Checked) // penjualan kredit { _jual.tanggal_tempo = dtpTanggalTempo.Value; } _jual.ppn = NumberHelper.StringToDouble(txtPPN.Text); _jual.diskon = NumberHelper.StringToDouble(txtDiskon.Text); _jual.keterangan = txtKeterangan.Text; _jual.item_jual = this._listOfItemJual.Where(f => f.Produk != null).ToList(); foreach (var item in _jual.item_jual) { if (!(item.harga_beli > 0)) { item.harga_beli = item.Produk.harga_beli; } if (!(item.harga_jual > 0)) { item.harga_jual = item.Produk.harga_jual; } } if (!_isNewData) // update { _jual.item_jual_deleted = _listOfItemJualDeleted; } var result = 0; var validationError = new ValidationError(); using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { if (_isNewData) { result = _bll.Save(_jual, ref validationError); } else { result = _bll.Update(_jual, ref validationError); } if (result > 0) { if (chkCetakNotaJual.Checked) { CetakNota(_jual.jual_id); } Listener.Ok(this, _isNewData, _jual); _customer = null; _listOfItemJual.Clear(); _listOfItemJualDeleted.Clear(); this.Close(); } else { if (validationError.Message.Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { MsgHelper.MsgUpdateError(); } } } }
protected override void Simpan() { if (this._customer == null || txtCustomer.Text.Length == 0) { MsgHelper.MsgWarning("'Customer' tidak boleh kosong !"); txtCustomer.Focus(); return; } var total = SumGrid(this._listOfItemPembayaranPiutang); if (!(total > 0)) { MsgHelper.MsgWarning("Anda belum melengkapi inputan data pembayaran !"); return; } if (!MsgHelper.MsgKonfirmasi("Apakah proses ingin dilanjutkan ?")) { return; } if (_isNewData) { _pembayaranPiutang = new PembayaranPiutangProduk(); } _pembayaranPiutang.pengguna_id = this._pengguna.pengguna_id; _pembayaranPiutang.Pengguna = this._pengguna; _pembayaranPiutang.customer_id = this._customer.customer_id; _pembayaranPiutang.Customer = this._customer; _pembayaranPiutang.nota = txtNota.Text; _pembayaranPiutang.tanggal = dtpTanggal.Value; _pembayaranPiutang.keterangan = txtKeterangan.Text; _pembayaranPiutang.item_pembayaran_piutang = this._listOfItemPembayaranPiutang.Where(f => f.JualProduk != null).ToList(); if (!_isNewData) // update { _pembayaranPiutang.item_pembayaran_piutang_deleted = _listOfItemPembayaranPiutangDeleted; } var result = 0; var validationError = new ValidationError(); using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { if (_isNewData) { result = _bll.Save(_pembayaranPiutang, false, ref validationError); } else { result = _bll.Update(_pembayaranPiutang, false, ref validationError); } if (result > 0) { Listener.Ok(this, _isNewData, _pembayaranPiutang); _customer = null; _listOfItemPembayaranPiutang.Clear(); _listOfItemPembayaranPiutangDeleted.Clear(); this.Close(); } else { if (validationError.Message.Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { MsgHelper.MsgUpdateError(); } } } }
protected override void Simpan() { if (_isNewData) { _gaji = new GajiKaryawan(); if (this._karyawan == null) { MsgHelper.MsgWarning("Karyawan belum dipilih"); return; } _gaji.karyawan_id = _karyawan.karyawan_id; _gaji.Karyawan = _karyawan; _gaji.bulan = DayMonthHelper.GetBulanAngka(cmbBulan.Text); _gaji.tahun = int.Parse(cmbTahun.Text); } _gaji.pengguna_id = this._pengguna.pengguna_id; _gaji.Pengguna = this._pengguna; _gaji.nota = txtNota.Text; _gaji.tanggal = dtpTanggal.Value; _gaji.kehadiran = int.Parse(txtKehadiran.Text); _gaji.absen = int.Parse(txtAbsen.Text); _gaji.jumlah_hari = int.Parse(txtJumlahHari.Text); _gaji.gaji_pokok = NumberHelper.StringToDouble(txtGaji.Text); _gaji.tunjangan = NumberHelper.StringToDouble(txtTunjangan.Text); _gaji.bonus = NumberHelper.StringToDouble(txtBonus.Text); _gaji.jam = int.Parse(txtJam.Text); _gaji.lembur = NumberHelper.StringToDouble(txtLembur.Text); _gaji.potongan = NumberHelper.StringToDouble(txtPotongan.Text); var result = 0; var validationError = new ValidationError(); using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { if (_isNewData) { result = _bll.Save(_gaji, ref validationError); } else { result = _bll.Update(_gaji, ref validationError); } if (result > 0) { Listener.Ok(this, _isNewData, _gaji); if (_isNewData) { cmbKaryawan.SelectedIndex = 0; cmbKaryawan.Focus(); txtNota.Text = _bll.GetLastNota(); } else { this.Close(); } } else { if (validationError.Message.NullToString().Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { var pesan = string.Format("Maaf, Data yang Anda masukkan gagal disimpan !\nCek apakah data gaji '{0}' sudah diinputkan.", _gaji.Karyawan.nama_karyawan); MsgHelper.MsgWarning(pesan); } } } }
protected override void Simpan() { if (_isNewData) { _produk = new Produk(); } if (_produk.list_of_harga_grosir.Count == 0) { var index = 0; foreach (var item in _listOfTxtHargaGrosir) { var txtHargaGrosir = _listOfTxtHargaGrosir[index]; var txtJumlahMinGrosir = _listOfTxtJumlahGrosir[index]; var txtDiskonGrosir = _listOfTxtDiskonGrosir[index]; var hargaGrosir = new HargaGrosir { harga_ke = index + 1, harga_grosir = NumberHelper.StringToDouble(txtHargaGrosir.Text), jumlah_minimal = NumberHelper.StringToDouble(txtJumlahMinGrosir.Text, true), diskon = NumberHelper.StringToDouble(txtDiskonGrosir.Text, true) }; _produk.list_of_harga_grosir.Add(hargaGrosir); index++; } } else { var index = 0; foreach (var item in _produk.list_of_harga_grosir) { var txtHargaGrosir = _listOfTxtHargaGrosir[index]; var txtJumlahMinGrosir = _listOfTxtJumlahGrosir[index]; var txtDiskonGrosir = _listOfTxtDiskonGrosir[index]; item.harga_grosir = NumberHelper.StringToDouble(txtHargaGrosir.Text); item.jumlah_minimal = NumberHelper.StringToDouble(txtJumlahMinGrosir.Text, true); item.diskon = NumberHelper.StringToDouble(txtDiskonGrosir.Text, true); index++; } } var golongan = _listOfGolongan[cmbGolongan.SelectedIndex]; _produk.golongan_id = golongan.golongan_id; _produk.Golongan = golongan; _produk.kode_produk = txtKodeProduk.Text; _produk.nama_produk = txtNamaProduk.Text; _produk.satuan = txtSatuan.Text; _produk.harga_beli = NumberHelper.StringToDouble(txtHargaBeli.Text); _produk.harga_jual = NumberHelper.StringToDouble(txtHargaJual.Text); _produk.diskon = NumberHelper.StringToDouble(txtDiskon.Text, true); _produk.persentase_keuntungan = NumberHelper.StringToDouble(txtKeuntungan.Text, true); _produk.stok = NumberHelper.StringToDouble(txtStok.Text, true); _produk.stok_gudang = NumberHelper.StringToDouble(txtStokGudang.Text, true); _produk.minimal_stok_gudang = NumberHelper.StringToDouble(txtMinStokGudang.Text, true); var result = 0; var validationError = new ValidationError(); using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { if (_isNewData) { result = _bll.Save(_produk, ref validationError); } else { result = _bll.Update(_produk, ref validationError); } if (result > 0) { Listener.Ok(this, _isNewData, _produk); if (_isNewData) { base.ResetForm(this); txtKodeProduk.Text = this._bll.GetLastKodeProduk(); txtKodeProduk.Focus(); } else { this.Close(); } } else { if (validationError.Message.NullToString().Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { MsgHelper.MsgDuplicate("kode produk"); txtKodeProduk.Focus(); txtKodeProduk.SelectAll(); } } } }
private void gridControl_CurrentCellKeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (this._jual == null || txtNotaJual.Text.Length == 0) { MsgHelper.MsgWarning("Maaf isian data belum lengkap !"); txtNotaJual.Focus(); return; } var grid = (GridControl)sender; var rowIndex = grid.CurrentCell.RowIndex; var colIndex = grid.CurrentCell.ColIndex; GridCurrentCell cc; ItemJualProduk itemJual; switch (colIndex) { case 2: // kode produk _isValidKodeProduk = false; cc = grid.CurrentCell; var kodeProduk = cc.Renderer.ControlValue.ToString(); if (kodeProduk.Length == 0) { GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1); } else { itemJual = this._jual.item_jual.Where(f => f.Produk.kode_produk.ToLower() == kodeProduk.ToLower() && f.jumlah > f.jumlah_retur) .SingleOrDefault(); if (itemJual == null) { MsgHelper.MsgWarning("Data produk tidak ditemukan"); GridListControlHelper.SelectCellText(grid, rowIndex, colIndex); return; } _isValidKodeProduk = true; if (!IsExist(itemJual.produk_id)) { SetItemProduk(grid, rowIndex, colIndex, itemJual, itemJual.jumlah - itemJual.jumlah_retur, itemJual.harga_jual); grid.Refresh(); RefreshTotal(); GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 2); } else { GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 2); } } break; case 3: // nama produk cc = grid.CurrentCell; var namaProduk = cc.Renderer.ControlValue.ToString(); if (!_isValidKodeProduk) { var listOfItemJual = this._jual.item_jual.Where(f => f.Produk.nama_produk.ToLower().Contains(namaProduk.ToLower()) && f.jumlah > f.jumlah_retur) .ToList(); if (listOfItemJual.Count == 0) { MsgHelper.MsgWarning("Data produk tidak ditemukan"); GridListControlHelper.SelectCellText(grid, rowIndex, colIndex); } else if (listOfItemJual.Count == 1) { itemJual = listOfItemJual[0]; if (!IsExist(itemJual.produk_id)) { SetItemProduk(grid, rowIndex, colIndex, itemJual, itemJual.jumlah - itemJual.jumlah_retur, itemJual.harga_jual); grid.Refresh(); GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1); } else { MsgHelper.MsgWarning("Data produk sudah diinputkan"); GridListControlHelper.SelectCellText(grid, rowIndex, colIndex); } } else // data lebih dari satu { _rowIndex = rowIndex; _colIndex = colIndex; var frmLookup = new FrmLookupItemNota("Item Penjualan", listOfItemJual); frmLookup.Listener = this; frmLookup.ShowDialog(); } } break; case 4: _isValidJumlahRetur = false; try { cc = grid.CurrentCell; double jumlahRetur = NumberHelper.StringToDouble(cc.Renderer.ControlValue.ToString(), true); var jumlahJual = _listOfItemRetur[rowIndex - 1].jumlah; if (jumlahRetur <= jumlahJual) { _isValidJumlahRetur = true; GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1); } else { MsgHelper.MsgWarning("Maaf, jumlah retur tidak boleh melebihi jumlah jual"); } } catch { } break; case 5: if (grid.RowCount == rowIndex) { _listOfItemRetur.Add(new ItemReturJualProduk()); grid.RowCount = _listOfItemRetur.Count; } GridListControlHelper.SetCurrentCell(grid, rowIndex + 1, 2); // fokus ke kolom nama produk break; default: break; } } }
protected override void Simpan() { if (txtKodeProduk.Text.Length == 0) { MsgHelper.MsgWarning("'Kode Produk' tidak boleh kosong !"); txtKodeProduk.Focus(); return; } if (this._produk == null) { MsgHelper.MsgWarning("'Kode Produk' tidak ditemukan !"); txtKodeProduk.Focus(); return; } if (_isNewData) { _penyesuaianStok = new PenyesuaianStok(); } _penyesuaianStok.produk_id = this._produk.produk_id; _penyesuaianStok.Produk = this._produk; var alasanPenyesuaian = _listOfAlasanPenyesuaian[cmbAlasanPenyesuaian.SelectedIndex]; _penyesuaianStok.alasan_penyesuaian_id = alasanPenyesuaian.alasan_penyesuaian_stok_id; _penyesuaianStok.AlasanPenyesuaianStok = alasanPenyesuaian; _penyesuaianStok.tanggal = dtpTanggal.Value; _penyesuaianStok.penambahan_stok = NumberHelper.StringToDouble(txtPenambahanStokEtalase.Text); _penyesuaianStok.penambahan_stok_gudang = NumberHelper.StringToDouble(txtPenambahanStokGudang.Text); _penyesuaianStok.pengurangan_stok = NumberHelper.StringToDouble(txtPenguranganStokEtalase.Text); _penyesuaianStok.pengurangan_stok_gudang = NumberHelper.StringToDouble(txtPenguranganStokGudang.Text); _penyesuaianStok.keterangan = txtKeterangan.Text; var result = 0; var validationError = new ValidationError(); if (_isNewData) { result = _bll.Save(_penyesuaianStok, ref validationError); } else { result = _bll.Update(_penyesuaianStok, ref validationError); } if (result > 0) { Listener.Ok(this, _isNewData, _penyesuaianStok); if (_isNewData) { base.ResetForm(this); this._produk = null; txtKodeProduk.Focus(); } else { this.Close(); } } else { if (validationError.Message.Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { MsgHelper.MsgUpdateError(); } } }
private void gridControl_CurrentCellKeyDown(object sender, KeyEventArgs e) { if (KeyPressHelper.IsEnter(e)) { var grid = (GridControl)sender; var rowIndex = grid.CurrentCell.RowIndex; var colIndex = grid.CurrentCell.ColIndex; JenisPengeluaran jenisPengeluaran = null; switch (colIndex) { case 2: // pencarian berdasarkan nama jenis pengeluaran GridCurrentCell cc = grid.CurrentCell; var namaProduk = cc.Renderer.ControlValue.ToString(); IJenisPengeluaranBll bll = new JenisPengeluaranBll(_log); var listOfJenisPengeluaran = bll.GetByName(namaProduk); if (listOfJenisPengeluaran.Count == 0) { MsgHelper.MsgWarning("Data jenis pengeluaran tidak ditemukan"); GridListControlHelper.SelectCellText(grid, rowIndex, colIndex); } else if (listOfJenisPengeluaran.Count == 1) { jenisPengeluaran = listOfJenisPengeluaran[0]; if (!IsExist(jenisPengeluaran.jenis_pengeluaran_id)) { SetItemJenisPengeluaran(grid, rowIndex, colIndex, jenisPengeluaran); grid.Refresh(); RefreshTotal(); GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1); } else { MsgHelper.MsgWarning("Data jenis pengeluaran sudah diinputkan"); GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex); } } else // data lebih dari satu, tampilkan form lookup { _rowIndex = rowIndex; _colIndex = colIndex; var frmLookup = new FrmLookupReferensi("Data Jenis Pengeluaran", listOfJenisPengeluaran); frmLookup.Listener = this; frmLookup.ShowDialog(); } break; case 3: GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1); break; case 4: if (grid.RowCount == rowIndex) { _listOfItemPengeluaran.Add(new ItemPengeluaranBiaya()); grid.RowCount = _listOfItemPengeluaran.Count; } GridListControlHelper.SetCurrentCell(grid, rowIndex + 1, 2); // fokus ke kolom kode produk break; default: break; } } }
protected override void Simpan() { var msg = "'{0}' tidak boleh kosong !"; var bayarTunai = 0; var bayarKartu = 0; if (chkBayarViaKartu.Checked) // pembayaran via kartu { bayarKartu = (int)NumberHelper.StringToNumber(txtBayarKartu.Text); if (!(bayarKartu > 0)) { MsgHelper.MsgWarning(string.Format(msg, "Bayar via Kartu")); txtBayarKartu.Focus(); return; } } // pembayaran tunai bayarTunai = (int)NumberHelper.StringToNumber(txtBayarTunai.Text); if (bayarTunai == 0 && bayarKartu == 0) { MsgHelper.MsgWarning(string.Format(msg, "Bayar Tunai")); txtBayarTunai.Focus(); return; } _jual.bayar_tunai = bayarTunai; _jual.bayar_kartu = bayarKartu; if ((_jual.jumlah_bayar - _jual.grand_total) < 0) { MsgHelper.MsgWarning("Maaf jumlah bayar kurang"); if (bayarTunai > 0) { txtBayarTunai.Focus(); txtBayarTunai.SelectAll(); return; } if (bayarKartu > 0) { txtBayarKartu.Focus(); txtBayarKartu.SelectAll(); return; } } if (!MsgHelper.MsgKonfirmasi("Apakah proses penyimpanan ingin di lanjutkan ?")) { return; } _jual.mesin_id = MainProgram.mesinId; _jual.ppn = NumberHelper.StringToDouble(txtPPN.Text); _jual.diskon = NumberHelper.StringToDouble(txtDiskon.Text); if (_jual.bayar_kartu > 0) { var kartu = _listOfKartu[cmbKartu.SelectedIndex]; _jual.kartu_id = kartu.kartu_id; _jual.Kartu = kartu; _jual.nomor_kartu = txtNoKartu.Text; } var result = 0; var validationError = new ValidationError(); using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { result = _bll.Save(_jual, ref validationError); if (result > 0) { Listener.Ok(this, _jual); this.Close(); } else { if (validationError.Message != null && validationError.Message.Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { MsgHelper.MsgUpdateError(); } } } }
protected override void Simpan() { if (txtPassword.Text.Length > 0 && txtKonfirmasiPassword.Text.Length > 0) { if (txtPassword.Text != txtKonfirmasiPassword.Text) { MsgHelper.MsgWarning("Password dan konfirmasi password harus sama"); txtPassword.Focus(); txtPassword.SelectAll(); return; } } if (_isNewData) { _operator = new Pengguna(); } _operator.nama_pengguna = txtNama.Text; _operator.pass_pengguna = txtPassword.Text; if (txtKonfirmasiPassword.Text.Length > 0) { _operator.konf_pass_pengguna = CryptoHelper.GetMD5Hash(txtKonfirmasiPassword.Text, MainProgram.securityCode); } var role = listOfRole[cmbRole.SelectedIndex]; _operator.role_id = role.role_id; _operator.Role = role; _operator.is_active = rdoAktif.Checked; var result = 0; var validationError = new ValidationError(); if (_isNewData) { result = _bll.Save(_operator, ref validationError); } else { result = _bll.Update(_operator); } if (result > 0) { Listener.Ok(this, _isNewData, _operator); if (_isNewData) { base.ResetForm(this); txtNama.Focus(); } else { this.Close(); } } else { if (validationError.Message.NullToString().Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { MsgHelper.MsgUpdateError(); } } }
private void btnLogin_Click(object sender, EventArgs e) { var isConnected = false; SaveAppConfig(); // tes koneksi ke server using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { IDbConnectionHelper dbConn = new DbConnectionHelper(); isConnected = dbConn.IsOpenConnection(); } if (!isConnected) { var msg = "Maaf koneksi ke database gagal !!!\n\n" + "Disarankan untuk menginstall OpenRetail di 'Drive D'.\n" + "Silahkan uninstall dulu OpenRetailnya, kemudian install lagi di 'Drive D'."; MsgHelper.MsgError(msg); return; } using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { IPenggunaBll penggunaBll = new PenggunaBll(_log); var pass = CryptoHelper.GetMD5Hash(txtPassword.Text, MainProgram.securityCode); var isLogin = penggunaBll.IsValidPengguna(txtUserName.Text, pass); if (isLogin) { UpgradeDatabase(DatabaseVersionHelper.DatabaseVersion); log4net.GlobalContext.Properties["UserName"] = txtUserName.Text; MainProgram.pengguna = penggunaBll.GetByID(txtUserName.Text); SetProfil(); SetPengaturanUmum(); SetPengaturanBarcode(); SetPengaturanLabelHarga(); SetSettingPort(); SetSettingCustomerDisplay(); LoadKabupaten(); LoadWilayah(); if (MainProgram.pengaturanUmum.is_show_minimal_stok) { LoadInfoMinimalStokProduk(); } this.DialogResult = DialogResult.OK; this.Close(); } else { MsgHelper.MsgWarning("User name atau password salah !!!"); txtUserName.Focus(); } } }
protected override void Simpan() { if (_isNewData) { _customer = new Customer(); } _customer.nama_customer = txtCustomer.Text; _customer.provinsi_id = null; _customer.Provinsi = null; if (cmbProvinsi.SelectedIndex > 0) { var provinsi = _listOfProvinsi[cmbProvinsi.SelectedIndex - 1]; _customer.provinsi_id = provinsi.provinsi_id; _customer.Provinsi = provinsi; } _customer.kabupaten_id = null; _customer.Kabupaten = null; if (cmbKabupaten.SelectedIndex > 0) { var kabupaten = _listOfKabupaten[cmbKabupaten.SelectedIndex - 1]; _customer.kabupaten_id = kabupaten.kabupaten_id; _customer.Kabupaten = kabupaten; } _customer.kecamatan_id = null; _customer.Kecamatan = null; if (cmbKecamatan.SelectedIndex > 0) { var kecamatan = _listOfKecamatan[cmbKecamatan.SelectedIndex - 1]; _customer.kecamatan_id = kecamatan.kecamatan_id; _customer.Kecamatan = kecamatan; } _customer.alamat = txtAlamat.Text; _customer.desa = string.Empty; _customer.kelurahan = string.Empty; _customer.kota = string.Empty; _customer.kode_pos = txtKodePos.Text; _customer.kontak = txtKontak.Text; _customer.telepon = txtTelepon.Text; _customer.diskon = NumberHelper.StringToDouble(txtDiskon.Text, true); _customer.plafon_piutang = NumberHelper.StringToDouble(txtPlafonPiutang.Text); var result = 0; var validationError = new ValidationError(); using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { if (_isNewData) { result = _bll.Save(_customer, ref validationError); } else { result = _bll.Update(_customer, ref validationError); } if (result > 0) { Listener.Ok(this, _isNewData, _customer); if (_isNewData) { base.ResetForm(this); txtCustomer.Focus(); } else { this.Close(); } } else { if (validationError.Message.NullToString().Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { MsgHelper.MsgUpdateError(); } } } }
protected override void Simpan() { if (_isNewData) { _produk = new Produk(); } var golongan = _listOfGolongan[cmbGolongan.SelectedIndex]; _produk.golongan_id = golongan.golongan_id; _produk.Golongan = golongan; _produk.kode_produk = txtKodeProduk.Text; _produk.nama_produk = txtNamaProduk.Text; _produk.satuan = txtSatuan.Text; _produk.harga_beli = NumberHelper.StringToDouble(txtHargaBeli.Text); _produk.harga_jual = NumberHelper.StringToDouble(txtHargaJual.Text); _produk.diskon = NumberHelper.StringToDouble(txtDiskon.Text, true); _produk.stok = NumberHelper.StringToDouble(txtStok.Text, true); _produk.stok_gudang = NumberHelper.StringToDouble(txtStokGudang.Text, true); _produk.minimal_stok_gudang = NumberHelper.StringToDouble(txtMinStokGudang.Text, true); var result = 0; var validationError = new ValidationError(); if (_isNewData) { result = _bll.Save(_produk, ref validationError); } else { result = _bll.Update(_produk, ref validationError); } if (result > 0) { Listener.Ok(this, _isNewData, _produk); if (_isNewData) { base.ResetForm(this); txtKodeProduk.Text = this._bll.GetLastKodeProduk(); txtKodeProduk.Focus(); } else { this.Close(); } } else { if (validationError.Message != null && validationError.Message.Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { MsgHelper.MsgDuplicate("kode produk"); txtKodeProduk.Focus(); txtKodeProduk.SelectAll(); } } }
private void gridControl_CurrentCellKeyDown(object sender, KeyEventArgs e) { if (KeyPressHelper.IsEnter(e)) { var grid = (GridControl)sender; var rowIndex = grid.CurrentCell.RowIndex; var colIndex = grid.CurrentCell.ColIndex; IProdukBll bll = new ProdukBll(_log); Produk produk = null; GridCurrentCell cc; switch (colIndex) { case 2: // kode produk _isValidKodeProduk = false; cc = grid.CurrentCell; var kodeProduk = cc.Renderer.ControlValue.ToString(); if (kodeProduk.Length == 0) // kode produk kosong { // fokus ke kolom nama produk GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1); } else { // pencarian berdasarkan kode produk produk = bll.GetByKode(kodeProduk); if (produk == null) { MsgHelper.MsgWarning("Data produk tidak ditemukan"); GridListControlHelper.SelectCellText(grid, rowIndex, colIndex); return; } _isValidKodeProduk = true; if (!IsExist(produk.produk_id)) { SetItemProduk(grid, rowIndex, colIndex, produk); grid.Refresh(); RefreshTotal(); GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 2); } else { MsgHelper.MsgWarning("Data produk sudah diinputkan"); GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex); } } break; case 3: // pencarian berdasarkan nama produk cc = grid.CurrentCell; var namaProduk = cc.Renderer.ControlValue.ToString(); if (!_isValidKodeProduk) { var listOfProduk = bll.GetByName(namaProduk); if (listOfProduk.Count == 0) { MsgHelper.MsgWarning("Data produk tidak ditemukan"); GridListControlHelper.SelectCellText(grid, rowIndex, colIndex); } else if (listOfProduk.Count == 1) { produk = listOfProduk[0]; if (!IsExist(produk.produk_id)) { SetItemProduk(grid, rowIndex, colIndex, produk); grid.Refresh(); RefreshTotal(); GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1); } else { MsgHelper.MsgWarning("Data produk sudah diinputkan"); GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex); } } else // data lebih dari satu { _rowIndex = rowIndex; _colIndex = colIndex; var frmLookup = new FrmLookupReferensi("Data Produk", listOfProduk); frmLookup.Listener = this; frmLookup.ShowDialog(); } } else { GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1); } break; case 4: GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1); break; case 5: if (grid.RowCount == rowIndex) { _listOfItemJual.Add(new ItemJualProduk()); grid.RowCount = _listOfItemJual.Count; } GridListControlHelper.SetCurrentCell(grid, rowIndex + 1, 2); // fokus ke kolom kode produk break; default: break; } } }
protected override void Simpan() { if (this._supplier == null || txtSupplier.Text.Length == 0) { MsgHelper.MsgWarning("'Supplier' tidak boleh kosong !"); txtSupplier.Focus(); return; } var total = SumGrid(this._listOfItemBeli); if (!(total > 0)) { MsgHelper.MsgWarning("Anda belum melengkapi inputan data produk !"); return; } if (rdoKredit.Checked) { if (!DateTimeHelper.IsValidRangeTanggal(dtpTanggal.Value, dtpTanggalTempo.Value)) { MsgHelper.MsgNotValidRangeTanggal(); return; } } if (!MsgHelper.MsgKonfirmasi("Apakah proses ingin dilanjutkan ?")) { return; } if (_isNewData) { _beli = new BeliProduk(); } _beli.pengguna_id = this._pengguna.pengguna_id; _beli.Pengguna = this._pengguna; _beli.supplier_id = this._supplier.supplier_id; _beli.Supplier = this._supplier; _beli.nota = txtNota.Text; _beli.tanggal = dtpTanggal.Value; _beli.tanggal_tempo = DateTimeHelper.GetNullDateTime(); _beli.is_tunai = rdoTunai.Checked; if (rdoKredit.Checked) // pembelian kredit { _beli.tanggal_tempo = dtpTanggalTempo.Value; } _beli.ppn = NumberHelper.StringToDouble(txtPPN.Text); _beli.diskon = NumberHelper.StringToDouble(txtDiskon.Text); _beli.keterangan = txtKeterangan.Text; _beli.item_beli = this._listOfItemBeli.Where(f => f.Produk != null).ToList(); foreach (var item in _beli.item_beli) { if (!(item.harga > 0)) { item.harga = item.Produk.harga_beli; } } if (!_isNewData) // update { _beli.item_beli_deleted = _listOfItemBeliDeleted; } var result = 0; var validationError = new ValidationError(); using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { if (_isNewData) { result = _bll.Save(_beli, ref validationError); } else { result = _bll.Update(_beli, ref validationError); } if (result > 0) { if (chkCetakNotaBeli.Checked) { CetakNota(_beli.beli_produk_id); } Listener.Ok(this, _isNewData, _beli); _supplier = null; _listOfItemBeli.Clear(); _listOfItemBeliDeleted.Clear(); this.Close(); } else { if (validationError.Message.Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { MsgHelper.MsgUpdateError(); } } } }
protected override void Simpan() { var total = SumGrid(this._listOfItemPengeluaran); if (!(total > 0)) { MsgHelper.MsgWarning("Anda belum melengkapi inputan data produk !"); return; } if (!MsgHelper.MsgKonfirmasi("Apakah proses ingin dilanjutkan ?")) { return; } if (_isNewData) { _pengeluaran = new PengeluaranBiaya(); } _pengeluaran.pengguna_id = this._pengguna.pengguna_id; _pengeluaran.Pengguna = this._pengguna; _pengeluaran.nota = txtNota.Text; _pengeluaran.tanggal = dtpTanggal.Value; _pengeluaran.keterangan = txtKeterangan.Text; _pengeluaran.item_pengeluaran_biaya = this._listOfItemPengeluaran.Where(f => f.JenisPengeluaran != null).ToList(); if (!_isNewData) // update { _pengeluaran.item_pengeluaran_biaya_deleted = _listOfItemPengeluaranDeleted; } var result = 0; var validationError = new ValidationError(); using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { if (_isNewData) { result = _bll.Save(_pengeluaran, ref validationError); } else { result = _bll.Update(_pengeluaran, ref validationError); } if (result > 0) { Listener.Ok(this, _isNewData, _pengeluaran); _listOfItemPengeluaran.Clear(); _listOfItemPengeluaranDeleted.Clear(); this.Close(); } else { if (validationError.Message.Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { MsgHelper.MsgUpdateError(); } } } }
private void PreviewReport() { var periode = string.Empty; IReportKartuStokBll reportBll = new ReportKartuStokBll(_log); IList <ReportKartuStok> listOfReport = new List <ReportKartuStok>(); if (rdoTanggal.Checked) { if (!DateTimeHelper.IsValidRangeTanggal(dtpTanggalMulai.Value, dtpTanggalSelesai.Value)) { MsgHelper.MsgNotValidRangeTanggal(); return; } var tanggalMulai = DateTimeHelper.DateToString(dtpTanggalMulai.Value); var tanggalSelesai = DateTimeHelper.DateToString(dtpTanggalSelesai.Value); periode = dtpTanggalMulai.Value == dtpTanggalSelesai.Value ? string.Format("Periode : {0}", tanggalMulai) : string.Format("Periode : {0} s.d {1}", tanggalMulai, tanggalSelesai); if (chkFilterTambahan.Checked) { IList <string> listOfKode = GetListKodeProduk(_listOfProduk); if (listOfKode.Count == 0) { MsgHelper.MsgWarning("Minimal satu nama produk harus dipilih !"); txtNamaProduk.Focus(); return; } listOfReport = reportBll.GetByTanggal(dtpTanggalMulai.Value, dtpTanggalSelesai.Value, listOfKode); } else { listOfReport = reportBll.GetByTanggal(dtpTanggalMulai.Value, dtpTanggalSelesai.Value); } } else { periode = string.Format("Periode : {0} {1}", cmbBulan.Text, cmbTahun.Text); var bulan = cmbBulan.SelectedIndex + 1; var tahun = int.Parse(cmbTahun.Text); if (chkFilterTambahan.Checked) { IList <string> listOfKode = GetListKodeProduk(_listOfProduk); if (listOfKode.Count == 0) { MsgHelper.MsgWarning("Minimal satu nama produk harus dipilih !"); txtNamaProduk.Focus(); return; } listOfReport = reportBll.GetByBulan(bulan, tahun, listOfKode); } else { listOfReport = reportBll.GetByBulan(bulan, tahun); } } if (listOfReport.Count > 0) { var reportDataSource = new ReportDataSource { Name = "DsReportKartuStok", Value = listOfReport }; var parameters = new List <ReportParameter>(); parameters.Add(new ReportParameter("periode", periode)); base.ShowReport(this.Text, "RvKartuStok", reportDataSource, parameters); } else { MsgHelper.MsgInfo("Maaf laporan data kartu stok tidak ditemukan"); } }
protected override void Simpan() { if (_isNewData) { _karyawan = new Karyawan(); } _karyawan.nama_karyawan = txtNama.Text; _karyawan.alamat = txtAlamat.Text; _karyawan.telepon = txtTelepon.Text; _karyawan.is_active = rdoAktif.Checked ? true : false; var jabatan = _listOfJabatan[cmbJabatan.SelectedIndex]; _karyawan.jabatan_id = jabatan.jabatan_id; _karyawan.Jabatan = jabatan; _karyawan.jenis_gajian = (JenisGajian)cmbJenisGaji.SelectedIndex; _karyawan.gaji_pokok = NumberHelper.StringToDouble(txtGajiPokok.Text); _karyawan.gaji_lembur = NumberHelper.StringToDouble(txtLembur.Text); var result = 0; var validationError = new ValidationError(); using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { if (_isNewData) { result = _bll.Save(_karyawan, ref validationError); } else { result = _bll.Update(_karyawan, ref validationError); } if (result > 0) { Listener.Ok(this, _isNewData, _karyawan); if (_isNewData) { base.ResetForm(this); txtNama.Focus(); } else { this.Close(); } } else { if (validationError.Message.NullToString().Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { MsgHelper.MsgUpdateError(); } } } }
protected override void Simpan() { if (this._supplier == null || txtSupplier.Text.Length == 0) { MsgHelper.MsgWarning("'Supplier' tidak boleh kosong !"); txtSupplier.Focus(); return; } var total = SumGrid(this._listOfItemRetur); if (!(total > 0)) { MsgHelper.MsgWarning("Anda belum melengkapi inputan data produk !"); return; } if (!MsgHelper.MsgKonfirmasi("Apakah proses ingin dilanjutkan ?")) { return; } if (_isNewData) { _retur = new ReturBeliProduk(); } _retur.beli_produk_id = this._beli.beli_produk_id; _retur.BeliProduk = this._beli; _retur.pengguna_id = this._pengguna.pengguna_id; _retur.Pengguna = this._pengguna; _retur.supplier_id = this._supplier.supplier_id; _retur.Supplier = this._supplier; _retur.nota = txtNota.Text; _retur.tanggal = dtpTanggal.Value; _retur.keterangan = txtKeterangan.Text; _retur.item_retur = this._listOfItemRetur.Where(f => f.Produk != null).ToList(); if (!_isNewData) // update { _retur.item_retur_deleted = _listOfItemReturDeleted; } var result = 0; var validationError = new ValidationError(); using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { if (_isNewData) { result = _bll.Save(_retur, ref validationError); } else { result = _bll.Update(_retur, ref validationError); } if (result > 0) { Listener.Ok(this, _isNewData, _retur); _supplier = null; _listOfItemRetur.Clear(); _listOfItemReturDeleted.Clear(); this.Close(); } else { if (validationError.Message.Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { MsgHelper.MsgUpdateError(); } } } }
private void InitGridControl(GridControl grid) { var gridListProperties = new List <GridListControlProperties>(); gridListProperties.Add(new GridListControlProperties { Header = "No", Width = 30 }); gridListProperties.Add(new GridListControlProperties { Header = "Kode Produk", Width = 120 }); gridListProperties.Add(new GridListControlProperties { Header = "Nama Produk", Width = 240 }); gridListProperties.Add(new GridListControlProperties { Header = "Jumlah Retur", Width = 60 }); gridListProperties.Add(new GridListControlProperties { Header = "Harga", Width = 90 }); gridListProperties.Add(new GridListControlProperties { Header = "Sub Total", Width = 110 }); gridListProperties.Add(new GridListControlProperties { Header = "Aksi" }); GridListControlHelper.InitializeGridListControl <ItemReturJualProduk>(grid, _listOfItemRetur, gridListProperties, 30); grid.PushButtonClick += delegate(object sender, GridCellPushButtonClickEventArgs e) { if (e.ColIndex == 7) { if (grid.RowCount == 1) { MsgHelper.MsgWarning("Minimal 1 produk harus diinputkan !"); return; } if (MsgHelper.MsgDelete()) { var itemRetur = _listOfItemRetur[e.RowIndex - 1]; itemRetur.entity_state = EntityState.Deleted; _listOfItemReturDeleted.Add(itemRetur); _listOfItemRetur.Remove(itemRetur); grid.RowCount = _listOfItemRetur.Count(); grid.Refresh(); RefreshTotal(); } } }; grid.QueryCellInfo += delegate(object sender, GridQueryCellInfoEventArgs e) { // Make sure the cell falls inside the grid if (e.RowIndex > 0) { if (!(_listOfItemRetur.Count > 0)) { return; } var itemRetur = _listOfItemRetur[e.RowIndex - 1]; var produk = itemRetur.Produk; if (e.RowIndex % 2 == 0) { e.Style.BackColor = ColorCollection.BACK_COLOR_ALTERNATE; } switch (e.ColIndex) { case 1: // no urut e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; e.Style.Enabled = false; e.Style.CellValue = e.RowIndex.ToString(); break; case 2: if (produk != null) { e.Style.CellValue = produk.kode_produk; } break; case 3: // nama produk if (produk != null) { e.Style.CellValue = produk.nama_produk; } break; case 4: // jumlah retur e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; e.Style.CellValue = itemRetur.jumlah_retur; break; case 5: // harga e.Style.HorizontalAlignment = GridHorizontalAlignment.Right; e.Style.CellValue = NumberHelper.NumberToString(itemRetur.harga_jual); break; case 6: // subtotal e.Style.HorizontalAlignment = GridHorizontalAlignment.Right; e.Style.Enabled = false; e.Style.CellValue = NumberHelper.NumberToString(itemRetur.jumlah_retur * itemRetur.harga_jual); break; case 7: // button hapus e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; e.Style.CellType = GridCellTypeName.PushButton; e.Style.Enabled = true; e.Style.Description = "Hapus"; break; default: break; } e.Handled = true; // we handled it, let the grid know } }; var colIndex = 2; // kolom nama produk grid.CurrentCell.MoveTo(1, colIndex, GridSetCurrentCellOptions.BeginEndUpdate); }
protected override void Simpan() { if (_isNewData) { _golongan = new Golongan(); } if (rbBarang.Checked) { _golongan.tipe = true; } else { _golongan.tipe = false; } _golongan.nama_golongan = txtGolongan.Text; _golongan.persentase_keuntungan = NumberHelper.StringToDouble(txtKeuntungan.Text, true); _golongan.diskon = NumberHelper.StringToDouble(txtDiskon.Text, true); var result = 0; var validationError = new ValidationError(); using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { if (_isNewData) { result = _bll.Save(_golongan, ref validationError); } else { result = _bll.Update(_golongan, ref validationError); } if (result > 0) { Listener.Ok(this, _isNewData, _golongan); if (_isNewData) { base.ResetForm(this); rbBarang.Checked = true; txtGolongan.Focus(); } else { this.Close(); } } else { if (validationError.Message.NullToString().Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { MsgHelper.MsgUpdateError(); } } } }
private void InitGridControl(GridControl grid) { var gridListProperties = new List <GridListControlProperties>(); gridListProperties.Add(new GridListControlProperties { Header = "No", Width = 30 }); gridListProperties.Add(new GridListControlProperties { Header = "Nota Jual", Width = 100 }); gridListProperties.Add(new GridListControlProperties { Header = "Total", Width = 100, IsEditable = false, HorizontalAlignment = GridHorizontalAlignment.Right }); gridListProperties.Add(new GridListControlProperties { Header = "Kekurangan", Width = 100, IsEditable = false, HorizontalAlignment = GridHorizontalAlignment.Right }); gridListProperties.Add(new GridListControlProperties { Header = "Pembayaran", Width = 100, HorizontalAlignment = GridHorizontalAlignment.Right }); gridListProperties.Add(new GridListControlProperties { Header = "Keterangan", Width = 200 }); gridListProperties.Add(new GridListControlProperties { Header = "Aksi" }); GridListControlHelper.InitializeGridListControl <ItemPembayaranPiutangProduk>(grid, _listOfItemPembayaranPiutang, gridListProperties); grid.PushButtonClick += delegate(object sender, GridCellPushButtonClickEventArgs e) { if (e.ColIndex == 7) { if (grid.RowCount == 1) { MsgHelper.MsgWarning("Minimal 1 nota harus diinputkan !"); return; } if (MsgHelper.MsgDelete()) { var pembayaranPiutang = _listOfItemPembayaranPiutang[e.RowIndex - 1]; pembayaranPiutang.entity_state = EntityState.Deleted; _listOfItemPembayaranPiutangDeleted.Add(pembayaranPiutang); _listOfItemPembayaranPiutang.Remove(pembayaranPiutang); grid.RowCount = _listOfItemPembayaranPiutang.Count(); grid.Refresh(); RefreshTotal(); } } }; grid.QueryCellInfo += delegate(object sender, GridQueryCellInfoEventArgs e) { // Make sure the cell falls inside the grid if (e.RowIndex > 0) { if (!(_listOfItemPembayaranPiutang.Count > 0)) { return; } double grand_total = 0; double sisaNota = 0; var itemPembayaran = _listOfItemPembayaranPiutang[e.RowIndex - 1]; var jual = itemPembayaran.JualProduk; if (jual != null) { grand_total = jual.grand_total;; sisaNota = jual.sisa_nota; } switch (e.ColIndex) { case 1: // no urut e.Style.CellValue = e.RowIndex.ToString(); break; case 2: // nota jual if (jual != null) { e.Style.CellValue = jual.nota; } if (jual != null) { if (jual.tanggal_tempo.IsNull()) // nota tunai nominalnya tidak bisa diedit { e.Style.Enabled = false; e.Style.BackColor = ColorCollection.DEFAULT_FORM_COLOR; base.SetButtonSimpanToFalse(true); } } break; case 3: // total e.Style.CellValue = NumberHelper.NumberToString(grand_total); break; case 4: // kekurangan e.Style.CellValue = NumberHelper.NumberToString(sisaNota); break; case 5: // pembayaran if (jual != null) { if (jual.tanggal_tempo.IsNull()) // nota tunai nominalnya tidak bisa diedit { e.Style.Enabled = false; e.Style.BackColor = ColorCollection.DEFAULT_FORM_COLOR; } } e.Style.CellValue = NumberHelper.NumberToString(itemPembayaran.nominal); break; case 6: // keterangan e.Style.CellValue = itemPembayaran.keterangan; break; case 7: // button hapus e.Style.CellType = GridCellTypeName.PushButton; e.Style.HorizontalAlignment = GridHorizontalAlignment.Center; e.Style.Description = "Hapus"; if (jual != null) { e.Style.Enabled = !jual.tanggal_tempo.IsNull(); } break; default: break; } e.Handled = true; // we handled it, let the grid know } }; var colIndex = 2; // kolom nama produk grid.CurrentCell.MoveTo(1, colIndex, GridSetCurrentCellOptions.BeginEndUpdate); }
private void PreviewReportHeader() { var periode = string.Empty; IReportHutangBeliProdukBll reportBll = new ReportHutangBeliProdukBll(_log); IList <ReportHutangPembelianProdukHeader> listOfReportHutangPembelian = new List <ReportHutangPembelianProdukHeader>(); IList <string> listOfSupplierId = new List <string>(); if (chkBoxTitle.Checked) { listOfSupplierId = base.GetSupplierId(_listOfSupplier); if (listOfSupplierId.Count == 0) { MsgHelper.MsgWarning("Minimal 1 supplier harus dipilih"); return; } } if (rdoTanggal.Checked) { if (!DateTimeHelper.IsValidRangeTanggal(dtpTanggalMulai.Value, dtpTanggalSelesai.Value)) { MsgHelper.MsgNotValidRangeTanggal(); return; } var tanggalMulai = DateTimeHelper.DateToString(dtpTanggalMulai.Value); var tanggalSelesai = DateTimeHelper.DateToString(dtpTanggalSelesai.Value); periode = dtpTanggalMulai.Value == dtpTanggalSelesai.Value ? string.Format("Periode : {0}", tanggalMulai) : string.Format("Periode : {0} s.d {1}", tanggalMulai, tanggalSelesai); listOfReportHutangPembelian = reportBll.GetByTanggal(dtpTanggalMulai.Value, dtpTanggalSelesai.Value); } else { periode = string.Format("Periode : {0} {1}", cmbBulan.Text, cmbTahun.Text); var bulan = cmbBulan.SelectedIndex + 1; var tahun = int.Parse(cmbTahun.Text); listOfReportHutangPembelian = reportBll.GetByBulan(bulan, tahun); } if (listOfSupplierId.Count > 0 && listOfReportHutangPembelian.Count > 0) { listOfReportHutangPembelian = listOfReportHutangPembelian.Where(f => listOfSupplierId.Contains(f.supplier_id)) .ToList(); } if (listOfReportHutangPembelian.Count > 0) { var reportDataSource = new ReportDataSource { Name = "ReportHutangPembelianProdukHeader", Value = listOfReportHutangPembelian }; var parameters = new List <ReportParameter>(); parameters.Add(new ReportParameter("periode", periode)); base.ShowReport(this.Text, "RvHutangPembelianProdukHeader", reportDataSource, parameters); } else { MsgHelper.MsgInfo("Maaf laporan data hutang pembelian tidak ditemukan"); } }
private void gridControl_CurrentCellKeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { var grid = (GridControl)sender; var rowIndex = grid.CurrentCell.RowIndex; var colIndex = grid.CurrentCell.ColIndex; switch (colIndex) { case 2: // kolom nota if (this._customer == null || txtCustomer.Text.Length == 0) { MsgHelper.MsgWarning("Nama Customer belum diinputkan"); txtCustomer.Focus(); return; } var cc = grid.CurrentCell; var nota = cc.Renderer.ControlValue.ToString(); IList <JualProduk> listOfJual = null; IJualProdukBll bll = new JualProdukBll(_log); if (nota.Length > 0) // menampilkan nota kredit berdasarkan nota { listOfJual = bll.GetNotaKreditByNota(this._customer.customer_id, nota); } else { listOfJual = bll.GetNotaKreditByCustomer(this._customer.customer_id, false); } if (listOfJual.Count == 0) { MsgHelper.MsgWarning("Data penjualan kredit tidak ditemukan"); GridListControlHelper.SelectCellText(grid, rowIndex, colIndex); } else if (listOfJual.Count == 1) { var jual = listOfJual[0]; if (!IsExist(jual.nota)) { SetItemBayar(grid, rowIndex, colIndex, jual); grid.Refresh(); GridListControlHelper.SetCurrentCell(grid, rowIndex, 5); // kolom pembayaran } else { MsgHelper.MsgWarning("Data pembayaran sudah diinputkan"); GridListControlHelper.SelectCellText(grid, rowIndex, colIndex); } } else // data nota lebih dari satu, tampilkan di form lookup { _rowIndex = rowIndex; _colIndex = colIndex; var frmLookup = new FrmLookupNota("Data Nota Penjualan", listOfJual); frmLookup.Listener = this; frmLookup.ShowDialog(); } break; case 6: // keterangan if (grid.RowCount == rowIndex) { _listOfItemPembayaranPiutang.Add(new ItemPembayaranPiutangProduk()); grid.RowCount = _listOfItemPembayaranPiutang.Count; } GridListControlHelper.SetCurrentCell(grid, rowIndex + 1, 2); // fokus ke kolom nota jual break; default: break; } } }
private void PreviewReportHeader() { var periode = string.Empty; IReportBeliProdukBll reportBll = new ReportBeliProdukBll(_log); IList <BeliProduk> listOfBeli = new List <BeliProduk>(); var listOfSupplierId = new List <string>(); if (chkBoxTitle.Checked) { for (int i = 0; i < chkListBox.Items.Count; i++) { if (chkListBox.GetItemChecked(i)) { var supplier = _listOfSupplier[i]; listOfSupplierId.Add(supplier.supplier_id); } } if (listOfSupplierId.Count == 0) { MsgHelper.MsgWarning("Minimal 1 supplier harus dipilih"); return; } } if (rdoTanggal.Checked) { if (!DateTimeHelper.IsValidRangeTanggal(dtpTanggalMulai.Value, dtpTanggalSelesai.Value)) { MsgHelper.MsgNotValidRangeTanggal(); return; } if (dtpTanggalMulai.Value == dtpTanggalSelesai.Value) { periode = string.Format("Periode : {0}", DateTimeHelper.DateToString(dtpTanggalMulai.Value)); } else { periode = string.Format("Periode : {0} s.d {1}", DateTimeHelper.DateToString(dtpTanggalMulai.Value), DateTimeHelper.DateToString(dtpTanggalSelesai.Value)); } listOfBeli = reportBll.GetByTanggal(dtpTanggalMulai.Value, dtpTanggalSelesai.Value); } else { periode = string.Format("Periode : {0} {1}", cmbBulan.Text, cmbTahun.Text); var bulan = cmbBulan.SelectedIndex + 1; var tahun = int.Parse(cmbTahun.Text); listOfBeli = reportBll.GetByBulan(bulan, tahun); } if (listOfSupplierId.Count > 0 && listOfBeli.Count > 0) { listOfBeli = listOfBeli.Where(f => f.Supplier != null && listOfSupplierId.Contains(f.supplier_id)) .ToList(); } if (listOfBeli.Count > 0) { var listOfSupplier = listOfBeli.Select(f => f.Supplier).ToList() .GroupBy(gb => gb.supplier_id).Select(g => g.First()).ToList(); var listOfPengguna = listOfBeli.Select(f => f.Supplier).ToList() .GroupBy(gb => gb.supplier_id).Select(g => g.First()).ToList(); var listOfBeliDto = Mapper.Map <IList <BeliProdukDto> >(listOfBeli); var rpt = new CrPembelianProdukHeader(); rpt.Database.Tables["Supplier"].SetDataSource(listOfSupplier); rpt.Database.Tables["Pengguna"].SetDataSource(listOfPengguna); rpt.Database.Tables["BeliProduk"].SetDataSource(listOfBeliDto); rpt.SetParameterValue("periode", periode); var frmPreview = new FrmPreviewReport(this.Text, rpt); frmPreview.ShowDialog(); } else { MsgHelper.MsgInfo("Maaf data pembelian tidak ditemukan"); } }