private void SaveJournal(object sender, EventArgs e) { if (ValidateJournalHeader()) { simpanToolStripButton.Enabled = false; TJournal jur; //save journal detail for (int i = 0; i < tJournalDataGridView.RowCount; i++) { jur = new TJournal(); jur.JournalDate = journalDateDateTimePicker.Value; jur.JournalDesc = tJournalDataGridView.Rows[i].Cells[4].Value.ToString(); jur.JournalJumlah = Convert.ToDecimal(tJournalDataGridView.Rows[i].Cells[2].Value); jur.JournalPic = string.Empty; jur.JournalStatus = tJournalDataGridView.Rows[i].Cells[3].Value.ToString(); jur.SubAccountId = tJournalDataGridView.Rows[i].Cells[0].Value.ToString(); jur.VoucherNo = voucherNoTextBox.Text; jur.ModifiedBy = lbl_UserName.Text; jur.ModifiedDate = DateTime.Now; AppCode.SaveTJournal(jur); } MessageBox.Show(this.Text + " berhasil disimpan", AppCode.AssemblyProduct, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void UpdatePiHutang(object sender, EventArgs e) { if (!ValidatePiHutang()) { return; } simpanToolStripButton.Enabled = false; TJournal jur = new TJournal(); jur.JournalDate = journalDateDateTimePicker.Value; jur.JournalDesc = journalDescTextBox.Text; jur.JournalJumlah = journalJumlahNumericUpDown.Value; jur.JournalPic = piHutangPicComboBox.SelectedValue.ToString(); if (!IsDelete) { if (PiHutang == ListOfPiHutangStatus.Piutang) { jur.JournalStatus = ListOfJournalStatus.Debet.ToString(); } else if (PiHutang == ListOfPiHutangStatus.Hutang) { jur.JournalStatus = ListOfJournalStatus.Kredit.ToString(); } } else { if (PiHutang == ListOfPiHutangStatus.Piutang) { jur.JournalStatus = ListOfJournalStatus.Kredit.ToString(); } else if (PiHutang == ListOfPiHutangStatus.Hutang) { jur.JournalStatus = ListOfJournalStatus.Debet.ToString(); } } //if (IsDelete) //{ // jur.SubAccountId = subAccountIdComboBox.SelectedValue.ToString(); //} //else //{ jur.SubAccountId = subAccountIdComboBox.SelectedValue.ToString(); //} jur.VoucherNo = voucherNoTextBox.Text; jur.ModifiedBy = lbl_UserName.Text; jur.ModifiedDate = DateTime.Now; AppCode.SaveTJournal(jur); TPiHutang piHut; for (int i = 0; i < tPiHutangDataGridView.RowCount; i++) { if (Convert.ToBoolean(tPiHutangDataGridView.Rows[i].Cells[0].Value) == true) { piHut = (TPiHutang)DataMaster.GetObjectByProperty(typeof(TPiHutang), TPiHutang.ColumnNames.PiHutangId, Convert.ToDecimal(tPiHutangDataGridView.Rows[i].Cells[7].Value)); piHut.PiHutangDibayar += Convert.ToDecimal(tPiHutangDataGridView.Rows[i].Cells[6].Value); piHut.PiHutangSisa = piHut.PiHutangJumlah - piHut.PiHutangRetur - piHut.PiHutangDibayar; if (piHut.PiHutangSisa == decimal.Zero) { piHut.PiHutangLunasDate = journalDateDateTimePicker.Value; if (piHutang == ListOfPiHutangStatus.Piutang && !IsDelete) { ShareCommissionInterface(piHut.TransactionId); } } piHut.ModifiedBy = lbl_UserName.Text; piHut.ModifiedDate = DateTime.Now; DataMaster.UpdatePersistence(piHut); jur = new TJournal(); jur.JournalDate = journalDateDateTimePicker.Value; jur.JournalDesc = journalDescTextBox.Text; jur.JournalJumlah = Convert.ToDecimal(tPiHutangDataGridView.Rows[i].Cells[6].Value); jur.JournalPic = piHutangPicComboBox.SelectedValue.ToString(); if (!IsDelete) { if (PiHutang == ListOfPiHutangStatus.Piutang) { jur.JournalStatus = ListOfJournalStatus.Kredit.ToString(); } else if (PiHutang == ListOfPiHutangStatus.Hutang) { jur.JournalStatus = ListOfJournalStatus.Debet.ToString(); } } else { if (PiHutang == ListOfPiHutangStatus.Piutang) { jur.JournalStatus = ListOfJournalStatus.Debet.ToString(); } else if (PiHutang == ListOfPiHutangStatus.Hutang) { jur.JournalStatus = ListOfJournalStatus.Kredit.ToString(); } } jur.SubAccountId = tPiHutangDataGridView.Rows[i].Cells[8].Value.ToString(); jur.VoucherNo = voucherNoTextBox.Text; jur.ModifiedBy = lbl_UserName.Text; jur.ModifiedDate = DateTime.Now; AppCode.SaveTJournal(jur); } } MessageBox.Show(this.Text + " berhasil disimpan", AppCode.AssemblyProduct, MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void CalculateItemValue() { //IList listGudang = DataMaster.GetAll(typeof(MGudang)); //MGudang gud; //IList listItemStok; //ItemGudangStok stok; //MItem item; //decimal itemvalue = 0; //for (int i = 0; i < listGudang.Count; i++) //{ // gud = (MGudang)listGudang[i]; // listItemStok = DataMaster.GetListEq(typeof(ItemGudangStok), ItemGudangStok.ColumnNames.GudangId, gud.GudangId); // for (int j = 0; j < listItemStok.Count; j++) // { // stok = (ItemGudangStok)listItemStok[j]; // item = (MItem)DataMaster.GetObjectByProperty(typeof(MItem), MItem.ColumnNames.ItemId, stok.ItemId); // if (item != null) // { // itemvalue += stok.ItemStok * item.ItemPricePurchaseAvg; // } // } //} //IList listTrans = DataMaster.GetListBetweenValue(typeof(TTransaction), TTransaction.ColumnNames.TransactionDate, from, to); //IList listDet; //TTransaction trans; //TTransactionDetail det; //decimal salesTot = 0; //decimal retSalesTot = 0; //decimal hppSalesTot = 0; //decimal hppRetSalesTot = 0; ////decimal purTot = 0; ////decimal retPurTot = 0; //for (int i = 0; i < listTrans.Count; i++) //{ // trans = (TTransaction)listTrans[i]; // if (trans.TransactionStatus == ListOfTransaction.Sales.ToString() || trans.TransactionStatus == ListOfTransaction.ReturSales.ToString()) // { // listDet = DataMaster.GetListEq(typeof(TTransactionDetail), TTransactionDetail.ColumnNames.TransactionId, trans.TransactionId); // for (int j = 0; j < listDet.Count; j++) // { // det = (TTransactionDetail)listDet[j]; // if (trans.TransactionStatus == ListOfTransaction.Sales.ToString()) // hppSalesTot += det.CostPrice; // else if (trans.TransactionStatus == ListOfTransaction.ReturSales.ToString()) // hppRetSalesTot += det.CostPrice; // } // } //} //decimal hppNet = hppSalesTot - hppRetSalesTot; //string voucherno = AppCode.GetVoucherNo(); //TJournal jur = new TJournal(); //jur.JournalDate = DateTime.Today; //jur.JournalDesc = "Harga Pokok Penjualan bulan " + comboBox_Month.Text + " " + numericUpDown_Year.Value.ToString(); //jur.JournalJumlah = hppNet; //jur.JournalPic = string.Empty; //jur.JournalStatus = ListOfJournalStatus.Debet.ToString(); //jur.SubAccountId = AppCode.GetHPPAccountNo(); //jur.VoucherNo = voucherno; //jur.ModifiedBy = lbl_UserName.Text; //jur.ModifiedDate = DateTime.Now; //AppCode.SaveTJournal(jur); //jur = new TJournal(); //jur.JournalDate = DateTime.Today; //jur.JournalDesc = "Ikhtiar Rugi Laba bulan " + comboBox_Month.Text + " " + numericUpDown_Year.Value.ToString(); //jur.JournalJumlah = hppNet; //jur.JournalPic = string.Empty; //jur.JournalStatus = ListOfJournalStatus.Kredit.ToString(); //jur.SubAccountId = AppCode.GetIkhtiarRLAccountNo(); //jur.VoucherNo = voucherno; //jur.ModifiedBy = lbl_UserName.Text; //jur.ModifiedDate = DateTime.Now; //AppCode.SaveTJournal(jur); IList listSubAcc = DataMaster.GetAll(typeof(MSubAccount)); MSubAccount sub; MAccount acc; decimal rl = 0; for (int i = 0; i < listSubAcc.Count; i++) { sub = (MSubAccount)listSubAcc[i]; SaveRekap(sub.AccountId, sub.SubAccountId, sub.SubAccountName, sub.SubAccountSaldo); acc = (MAccount)DataMaster.GetObjectByProperty(typeof(MAccount), MAccount.ColumnNames.AccountId, sub.AccountId); if (acc != null) { if (acc.AccountPosition == ListOfAccountPosition.RugiLaba.ToString()) { rl += sub.SubAccountSaldo; } } } string voucherno = AppCode.GetVoucherNo(); if (comboBox_Month.SelectedValue.ToString() == "12") { TJournal jur; IList listAcc = DataMaster.GetListEq(typeof(MAccount), MAccount.ColumnNames.AccountPosition, ListOfAccountPosition.RugiLaba.ToString()); for (int i = 0; i < listAcc.Count; i++) { acc = (MAccount)listAcc[i]; listSubAcc = DataMaster.GetListEq(typeof(MSubAccount), MSubAccount.ColumnNames.AccountId, acc.AccountId); for (int j = 0; j < listSubAcc.Count; j++) { sub = (MSubAccount)listSubAcc[j]; jur = new TJournal(); jur.JournalDate = DateTime.Today; jur.JournalDesc = "Jurnal Pembalik periode " + numericUpDown_Year.Value.ToString(); jur.JournalJumlah = sub.SubAccountSaldo; jur.JournalPic = lbl_UserName.Text; jur.JournalStatus = ListOfJournalStatus.Debet.ToString(); jur.SubAccountId = sub.SubAccountId; jur.VoucherNo = voucherno; jur.ModifiedBy = lbl_UserName.Text; jur.ModifiedDate = DateTime.Now; AppCode.SaveTJournal(jur); } } sub = (MSubAccount)DataMaster.GetObjectByProperty(typeof(MSubAccount), MSubAccount.ColumnNames.SubAccountId, AppCode.GetLabaDitahanAccountNo()); jur = new TJournal(); jur.JournalDate = DateTime.Today; jur.JournalDesc = "Laba Tahun " + numericUpDown_Year.Value.ToString(); jur.JournalJumlah = rl; jur.JournalPic = lbl_UserName.Text; jur.JournalStatus = ListOfJournalStatus.Kredit.ToString(); jur.SubAccountId = sub.SubAccountId; jur.VoucherNo = voucherno; jur.ModifiedBy = lbl_UserName.Text; jur.ModifiedDate = DateTime.Now; AppCode.SaveTJournal(jur); SaveRekap(sub.AccountId, sub.SubAccountId, sub.SubAccountName, rl); } else { SaveRekap("", "", "Laba/Rugi Periode Berjalan", rl); } }