private void UpdateNumericData(MCostCenter viewModel, FormCollection formCollection) { if (!string.IsNullOrEmpty(formCollection["CostCenterTotalBudget"])) { string CostCenterTotalBudget = formCollection["CostCenterTotalBudget"].Replace(",", ""); viewModel.CostCenterTotalBudget = Convert.ToDecimal(CostCenterTotalBudget); } else { viewModel.CostCenterTotalBudget = null; } }
public static ReportParamViewModel CreateReportParamViewModel(IMCostCenterRepository mCostCenterRepository, IMWarehouseRepository mWarehouseRepository, IMSupplierRepository mSupplierRepository, ITRecPeriodRepository tRecPeriodRepository, IMItemRepository mItemRepository) { ReportParamViewModel viewModel = new ReportParamViewModel(); IList <MCostCenter> list = mCostCenterRepository.GetAll(); MCostCenter costCenter = new MCostCenter(); costCenter.CostCenterName = "-Semua Cost Center-"; list.Insert(0, costCenter); viewModel.CostCenterList = new SelectList(list, "Id", "CostCenterName"); IList <MWarehouse> listWarehouse = mWarehouseRepository.GetAll(); MWarehouse account = new MWarehouse(); account.WarehouseName = "-Semua Gudang-"; listWarehouse.Insert(0, account); viewModel.WarehouseList = new SelectList(listWarehouse, "Id", "WarehouseName"); IList <MSupplier> listSupplier = mSupplierRepository.GetAll(); MSupplier supplier = new MSupplier(); supplier.SupplierName = "-Semua Supplier-"; listSupplier.Insert(0, supplier); viewModel.SupplierList = new SelectList(listSupplier, "Id", "SupplierName"); IList <TRecPeriod> listRecPeriod = tRecPeriodRepository.GetAll(); //TRecPeriod recPeriod = new TRecPeriod(); //recPeriod.PeriodDesc = "-Pilih Period-"; //listRecPeriod.Insert(0, recPeriod); viewModel.RecPeriodList = new SelectList(listRecPeriod, "Id", "PeriodDesc"); IList <MItem> listItem = mItemRepository.GetAll(); MItem item = new MItem(); item.ItemName = "-Semua Item-"; listItem.Insert(0, item); viewModel.ItemList = new SelectList(listItem, "Id", "ItemName"); ArrayList arr = new ArrayList(); for (int i = 1; i <= 5; i++) { var sel = new { Id = i }; arr.Add(sel); } viewModel.ShiftNoList = new SelectList(arr, "Id", "Id"); viewModel.DateFrom = DateTime.Today; viewModel.DateTo = DateTime.Today; return(viewModel); }
public TReal GetByCostCenterAndDate(MCostCenter costCenter, DateTime dateFrom, DateTime dateTo) { ICriteria criteria = Session.CreateCriteria(typeof(TReal)); criteria.Add(Expression.Eq("CostCenterId", costCenter)); criteria.Add(Expression.Between("RealDate", dateFrom, dateTo)); criteria.AddOrder(Order.Desc("RealDate")); IList <TReal> list = criteria.List <TReal>(); if (list.Count > 0) { return(list[0] as TReal); } return(null); }
public static PaymentViewModel Create(EnumPaymentType paymentType, ITPaymentRepository tPaymentRepository, ITPaymentDetRepository tPaymentDetRepository, IMSupplierRepository mSupplierRepository, IMCustomerRepository mCustomerRepository, IMCostCenterRepository mCostCenterRepository) { PaymentViewModel viewModel = new PaymentViewModel(); TPayment p = new TPayment(); p.SetAssignedIdTo(Guid.NewGuid().ToString()); p.PaymentDate = DateTime.Today; p.PaymentDesc = string.Empty; p.PaymentType = paymentType.ToString(); viewModel.Payment = p; viewModel.Title = string.Format("Pembayaran {0}", paymentType.ToString()); IList <MCostCenter> list = mCostCenterRepository.GetAll(); MCostCenter costCenter = new MCostCenter(); costCenter.CostCenterName = "-Pilih Cost Center-"; list.Insert(0, costCenter); viewModel.CostCenterList = new SelectList(list, "Id", "CostCenterName"); //get label text switch (paymentType) { case EnumPaymentType.Piutang: viewModel.CashAccountLabel = "Deposit ke : "; //fill cust var values = from MCustomer cust in mCustomerRepository.GetAll() select new { Id = cust.Id, Name = cust.PersonId != null ? cust.PersonId.PersonName : "-Pilih Konsumen-" }; viewModel.TransByList = new SelectList(values, "Id", "Name"); break; case EnumPaymentType.Hutang: viewModel.CashAccountLabel = "Deposit dari : "; IList <MSupplier> listAcc = mSupplierRepository.GetAll(); MSupplier supplier = new MSupplier(); supplier.SupplierName = "-Pilih Supplier-"; listAcc.Insert(0, supplier); viewModel.TransByList = new SelectList(listAcc, "Id", "SupplierName"); break; } return(viewModel); }
public static CashFormViewModel CreateCashFormViewModel(ITJournalRepository tJournalRepository, IMCostCenterRepository mCostCenterRepository, IMAccountRepository mAccountRepository) { CashFormViewModel viewModel = new CashFormViewModel(); IList <MCostCenter> list = mCostCenterRepository.GetAll(); MCostCenter costCenter = new MCostCenter(); costCenter.CostCenterName = "-Pilih Cost Center-"; list.Insert(0, costCenter); viewModel.CostCenterList = new SelectList(list, "Id", "CostCenterName"); IList <MAccount> listAcc = mAccountRepository.GetAll(); MAccount account = new MAccount(); account.AccountName = "-Pilih Akun Kas-"; listAcc.Insert(0, account); viewModel.AccountList = new SelectList(listAcc, "Id", "AccountName"); return(viewModel); }
protected TJournal SaveJournalHeader(MCostCenter costCenterId, string newVoucher, string journalPic, DateTime?journalDate, string journalEvidenceNo, string desc) { TJournal j = new TJournal(); j.SetAssignedIdTo(Guid.NewGuid().ToString()); j.CostCenterId = costCenterId; j.JournalType = EnumJournalType.GeneralLedger.ToString(); j.JournalVoucherNo = newVoucher; j.JournalPic = journalPic; j.JournalDate = journalDate; j.JournalEvidenceNo = journalEvidenceNo; //j.JournalAmmount = ammount; j.JournalDesc = desc; j.DataStatus = EnumDataStatus.New.ToString(); j.CreatedBy = UserName; j.CreatedDate = DateTime.Now; j.JournalDets.Clear(); return(j); }
public static UnitSalesFormViewModel CreateUnitSalesFormViewModel(IMCustomerRepository mCustomerRepository, IMCostCenterRepository mCostCenterRepository, ITTransUnitRepository tTransUnitRepository, string unitId) { UnitSalesFormViewModel viewModel = new UnitSalesFormViewModel(); TTransUnit t = null; if (!string.IsNullOrEmpty(unitId)) { t = tTransUnitRepository.GetByUnitId(unitId); } if (t == null) { t = new TTransUnit(); t.SetAssignedIdTo(Guid.NewGuid().ToString()); t.TransUnitDate = DateTime.Today; } viewModel.TransUnit = t; IList <MCustomer> listCust = mCustomerRepository.GetAll(); var vals = from customer in listCust select new { ID = customer.Id, Name = customer.PersonId.PersonName }; //MCustomer cust = new MCustomer(); //cust.CustomerDesc = "-Pilih Pembeli-"; //vals.Union( .Insert(0, cust)); viewModel.CustomerList = new SelectList(vals, "ID", "Name", t.CustomerId != null ? t.CustomerId.Id : null); IList <MCostCenter> list = mCostCenterRepository.GetAll(); MCostCenter costCenter = new MCostCenter(); costCenter.CostCenterName = "-Pilih Cost Center-"; list.Insert(0, costCenter); viewModel.CostCenterList = new SelectList(list, "Id", "CostCenterName", t.CostCenterId != null ? t.CostCenterId.Id : null); var values = from EnumPaymentMethod e in Enum.GetValues(typeof(EnumPaymentMethod)) select new { ID = e, Name = e.ToString() }; viewModel.PaymentMethodList = new SelectList(values, "Id", "Name", t.TransUnitPaymentMethod); return(viewModel); }
public ActionResult Delete(MCostCenter viewModel, FormCollection formCollection) { MCostCenter mCompanyToDelete = _mCostCenterRepository.Get(viewModel.Id); if (mCompanyToDelete != null) { _mCostCenterRepository.Delete(mCompanyToDelete); } try { _mCostCenterRepository.DbContext.CommitChanges(); } catch (Exception e) { _mCostCenterRepository.DbContext.RollbackTransaction(); return(Content(e.GetBaseException().Message)); } return(Content("success")); }
public IList <TRecAccount> GetByAccountType(string accountCatType, MCostCenter costCenter, TRecPeriod recPeriod) { StringBuilder sql = new StringBuilder(); sql.AppendLine(@" select rec from TRecAccount as rec left outer join rec.AccountId acc, MAccountCat cat where acc.AccountCatId = cat.Id"); if (!string.IsNullOrEmpty(accountCatType)) { sql.AppendLine(@" and cat.AccountCatType = :accountCatType"); } if (costCenter != null) { sql.AppendLine(@" and rec.CostCenterId = :costCenter"); } if (recPeriod != null) { sql.AppendLine(@" and rec.RecPeriodId = :recPeriod"); } sql.AppendLine(@" order by rec.CostCenterId, cat.Id"); IQuery q = Session.CreateQuery(sql.ToString()); if (!string.IsNullOrEmpty(accountCatType)) { q.SetString("accountCatType", accountCatType); } if (costCenter != null) { q.SetEntity("costCenter", costCenter); } if (recPeriod != null) { q.SetEntity("recPeriod", recPeriod); } return(q.List <TRecAccount>()); }
public ActionResult Update(MCostCenter viewModel, FormCollection formCollection) { UpdateNumericData(viewModel, formCollection); MCostCenter mCompanyToUpdate = _mCostCenterRepository.Get(viewModel.Id); TransferFormValuesTo(mCompanyToUpdate, viewModel); mCompanyToUpdate.ModifiedDate = DateTime.Now; mCompanyToUpdate.ModifiedBy = User.Identity.Name; mCompanyToUpdate.DataStatus = EnumDataStatus.Updated.ToString(); _mCostCenterRepository.Update(mCompanyToUpdate); try { _mCostCenterRepository.DbContext.CommitChanges(); } catch (Exception e) { _mCostCenterRepository.DbContext.RollbackTransaction(); return(Content(e.GetBaseException().Message)); } return(Content("success")); }
public IEnumerable <TReal> GetPagedList(string orderCol, string orderBy, int pageIndex, int maxRows, ref int totalRows, MCostCenter costCenter) { ICriteria criteria = Session.CreateCriteria(typeof(TReal)); criteria.Add(Expression.Eq("CostCenterId", costCenter)); //calculate total rows totalRows = Session.CreateCriteria(typeof(TReal)) .Add(Expression.Eq("CostCenterId", costCenter)) .SetProjection(Projections.RowCount()) .FutureValue <int>().Value; //get list results if (maxRows != 0) { criteria.SetMaxResults(maxRows) .SetFirstResult((pageIndex - 1) * maxRows); } criteria.AddOrder(new Order(orderCol, orderBy.Equals("asc") ? true : false)); return(criteria.List <TReal>()); ; }