public IEnumerable<LaundryHeaderDataEntity> GetClaimedItemsReport(CustomerDataEntity customer, DateTime fromDateTime, DateTime toDateTime, bool b_isAll) { using(var session = NHibernateHelper.OpenSession()) { using(var transaction = session.BeginTransaction()) { if (b_isAll) { var query = session.CreateCriteria<LaundryHeaderDataEntity>("header") .Add(Restrictions.Between("header.ReceivedDate", fromDateTime, toDateTime)) .Add(Restrictions.Eq("header.ClaimFlag", true)) .Add(Restrictions.Eq("header.VoidFlag", false)) .AddOrder(Order.Asc("header.ReceivedDate")) .List<LaundryHeaderDataEntity>(); return query; } else { var query = session.CreateCriteria<LaundryHeaderDataEntity>("header") .Add(Restrictions.Eq("header.Customer", customer)) .Add(Restrictions.Between("header.ReceivedDate", fromDateTime, toDateTime)) .Add(Restrictions.Eq("header.ClaimFlag", true)) .Add(Restrictions.Eq("header.VoidFlag", false)) .AddOrder(Order.Asc("header.ReceivedDate")) .List<LaundryHeaderDataEntity>(); return query; } } } }
public LaundryCustomerSearchViewPresenter(ILaundryCustomerSearchView p_view, CustomerDataEntity p_customer) { m_view = p_view; m_dao = new LaundryReportDao(); m_customer = p_customer; }
public IEnumerable<RefillDaySummaryDataEntity> GetCustomerSalesReport(CustomerDataEntity customer, DateTime fromDateTime, DateTime toDateTime, bool b_isAll) { using(var session = NHibernateHelper.OpenSession()) { using(var transaction = session.BeginTransaction()) { if(b_isAll) { var query = session.QueryOver<RefillDaySummaryDataEntity>() .WhereRestrictionOn(x => x.DayStamp).IsBetween(fromDateTime).And(toDateTime) .OrderBy(x => x.DayStamp).Asc .List<RefillDaySummaryDataEntity>(); return query; } else { var query = session.CreateCriteria<RefillHeaderDataEntity>("header") .Add(Restrictions.Eq("header.Customer",customer)) .CreateAlias("header.PaymentDetailEntities","paymentdetails") .SetProjection(Projections.ProjectionList() .Add(Projections.GroupProperty(Projections.Cast(NHibernateUtil.Date ,Projections.GroupProperty("paymentdetails.PaymentDate"))),"DayStamp") .Add(Projections.Sum("paymentdetails.Amount"),"TotalSales") .Add(Projections.CountDistinct("RefillHeaderID"),"TransCount")) .Add(Restrictions.Between("paymentdetails.PaymentDate",fromDateTime,toDateTime)) .AddOrder(Order.Asc("paymentdetails.PaymentDate")) .SetResultTransformer(Transformers.AliasToBean(typeof(RefillDaySummaryDataEntity))) .List<RefillDaySummaryDataEntity>(); return query; } } } }
public RefillCustInventoryHeaderDataEntity GetByCustomer(CustomerDataEntity customer) { using(var session = NHibernateHelper.OpenSession()) { var query = session.Query<RefillCustInventoryHeaderDataEntity>() .Where(x => x.Customer == customer) .SingleOrDefault(); return query; } }
public void SaveOrUpdateCustomer(CustomerDataEntity customer) { try { m_customerDao.SaveOrUpdate(customer); } catch(Exception ex) { throw ex; } }
public void DeleteCustomer(CustomerDataEntity customer) { try { m_customerDao.Delete(customer); } catch(Exception ex) { throw ex; } }
public RefillingReturnPaymentPresenter(IRefillReturnPaymentView m_view) { this.m_view = m_view; m_customerDao = new CustomerDao(); m_refillDao = new RefillDao(); m_refillReportDao = new RefillReportDao(); m_custInvDao = new RefillCustomerInventoryDao(); m_daysummaryDao = new RefillDaySummaryDao(); m_invDao = new RefillInventoryDao(); customer = new CustomerDataEntity(); custInv = new RefillCustInventoryHeaderDataEntity(); }
public IEnumerable<RefillHeaderDataEntity> GetByCustomer(CustomerDataEntity customer) { using(var session = NHibernateHelper.OpenSession()) { using(var transaction = session.BeginTransaction()) { var query = session.Query<RefillHeaderDataEntity>() .Where(x => x.Customer == customer) .FetchMany(x => x.DetailEntities) .ToList(); return query; } } }
public LaundryCustomerSearchView(CustomerDataEntity p_customer) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // Resource.setIcon(this, System.IO.Directory.GetCurrentDirectory() + "/images/user1.ico"); this.SetTitle("Laundry Customer Record"); m_customer = p_customer; m_presenter = new LaundryCustomerSearchViewPresenter(this, p_customer); }
public void RunReport(string wndTitle, string selectedReport, CustomerDataEntity customer, DateTime fromDateTime, DateTime toDateTime, bool b_isAll, string product) { switch(wndTitle) { case ReportConstants.LAUNDRY_WINDOW: RunLaundryReport(selectedReport, customer, fromDateTime, toDateTime, b_isAll); break; case ReportConstants.REFILL_WINDOW: RunRefillReport(selectedReport, customer, fromDateTime, toDateTime, b_isAll, product); break; default: break; } }
public void Delete(CustomerDataEntity p_customer) { using(var session = NHibernateHelper.OpenSession()) { using(var transaction = session.BeginTransaction()) { try { session.Delete(p_customer); transaction.Commit(); } catch(Exception ex) { transaction.Rollback(); throw ex; } } } }
public bool VerifyCustomerPendingTransaction(CustomerDataEntity customer) { List<LaundryHeaderDataEntity> laundryHeader = null; List<RefillHeaderDataEntity> refillHeader = null; if((laundryHeader = m_laundryReport.GetUnclaimedItemsReport(customer) as List<LaundryHeaderDataEntity>).Count > 0) { return true; } if((laundryHeader = m_laundryReport.GetUnpaidTransactionsReport(customer) as List<LaundryHeaderDataEntity>).Count > 0) { return true; } if((refillHeader = m_refillReport.GetUnpaidTransactionsReport(customer) as List<RefillHeaderDataEntity>).Count > 0) { return true; } return false; }
public void GetRefillJOsByCustomer(string customerName) { try { customer = m_customerDao.GetByName(customerName) as CustomerDataEntity; List<RefillHeaderDataEntity> refillHeaders = m_refillReportDao.GetUnpaidTransactionsReport(customer) as List<RefillHeaderDataEntity>; custInv = m_custInvDao.GetByCustomer(customer) as RefillCustInventoryHeaderDataEntity; if((custInv == null || (custInv.BottlesOnHand == 0 && custInv.CapsOnHand == 0)) && refillHeaders.Count == 0) { MessageService.ShowInfo("No records found for customer: " + customerName); return; } m_view.LoadRefillHeaderAndInventoryData(refillHeaders, custInv); } catch(Exception ex) { MessageService.ShowError("Unable to display data; an unexpected error occurred.\n" + "Please check error log for details.\n", ex); } }
public IEnumerable<RefillCustInventoryHeaderDataEntity> GetCustomerInventoryReport(CustomerDataEntity customer, bool b_isAll) { using (var session = NHibernateHelper.OpenSession()) { using (var transaction = session.BeginTransaction()) { if(b_isAll) { var query = session.CreateCriteria<RefillCustInventoryHeaderDataEntity>("header") .CreateAlias("header.Customer","customer") .AddOrder(Order.Asc("customer.Name")) .List<RefillCustInventoryHeaderDataEntity>(); return query; } else{ var query = session.QueryOver<RefillCustInventoryHeaderDataEntity>() .Where(x => x.Customer == customer) .List<RefillCustInventoryHeaderDataEntity>(); return query; } } } }
public void saveNewHeaderAndUpdateDaySummary() { // test for new header but with existing daysummary // should not save new record for daysummary // should only update existing daysummary with transcount and sales DateTime sampleDay = Convert.ToDateTime(DateTime.Now.ToShortDateString()); // daystamp in daysummary should be date only (no time); RefillDaySummaryDao summarydao = new RefillDaySummaryDao(); RefillDaySummaryDataEntity summary = summarydao.GetByDay(sampleDay); if(summary!= null) { RefillHeaderDataEntity header = new RefillHeaderDataEntity(); RefillDetailDataEntity detail = new RefillDetailDataEntity(); RefillTransactionTypeDataEntity transactionType = new RefillTransactionTypeDao().GetByName("Delivery"); RefillProductTypeDataEntity productType = new RefillProductTypeDao().GetByName("5 Gal at 15"); CustomerDao custdao = new CustomerDao(); CustomerDataEntity customer = custdao.GetByName("John Dee"); if(customer == null) { customer = new CustomerDataEntity(); customer.Name = "John Dee"; customer.Address = "Cebu"; customer.ContactNumber = "111-1111"; } header.Customer = customer; header.Date = DateTime.Now; header.TransactionType = transactionType; detail.Header = header; // set header entity in detail for nhibernate to pickup and map detail.ProductType = productType; detail.Qty = 20; detail.Amount = productType.Price * Convert.ToDecimal(detail.Qty); detail.StoreBottleQty = 10; detail.StoreCapQty = 10; header.DetailEntities.Add(detail); // add detail to header details list header.AmountDue = detail.Amount; header.TotalQty = detail.Qty; header.AmountTender += 25.00M; // accumulate amount tender with current amount tender // TODO: should update paidflag in header if total balance = 0. // set paymentdetail RefillPaymentDetailDataEntity paymentdetail = new RefillPaymentDetailDataEntity(); paymentdetail.Amount = header.AmountTender; paymentdetail.PaymentDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()); paymentdetail.Header = header; header.PaymentDetailEntities.Add(paymentdetail); summary.TransCount += 1; summary.TotalSales += header.AmountTender; header.DaySummary = summary; // update daysummary with transcount and totalsales RefillDaySummaryDao dao = new RefillDaySummaryDao(); dao.Update(summary); // save header,details,etc. RefillDao ldao = new RefillDao(); ldao.SaveOrUpdate(header); } }
private List<ReportParameter> SetReportParameters(CustomerDataEntity customer, bool b_isAll) { List<ReportParameter> parameters = new List<ReportParameter>(); if(customer.Name == null) { parameters.Add(new ReportParameter("customerName", "")); } else{ parameters.Add(new ReportParameter("customerName", customer.Name)); } parameters.Add(new ReportParameter("isAll", b_isAll.ToString())); return parameters; }
private void RunRefillReport(string selectedReport, CustomerDataEntity customer, DateTime fromDateTime, DateTime toDateTime, bool b_isAll, string product) { List<ReportDataSource> datasources = new List<ReportDataSource>(); List<ReportParameter> parameters = new List<ReportParameter>(); switch(selectedReport) { case ReportConstants.SALES_REPORT: List<RefillDaySummaryDataEntity> salesReport = m_refillReportDao .GetCustomerSalesReport(customer, fromDateTime, toDateTime, b_isAll) as List<RefillDaySummaryDataEntity>; parameters = SetReportParameters(customer, fromDateTime, toDateTime, b_isAll); datasources.Add(new ReportDataSource(ReportConstants.DS_REFILLDAYSUMMARY, salesReport)); m_view.DisplayReport(salesReport, datasources, parameters, ReportConstants.ES_REFILL_SALES_REPORT); break; case ReportConstants.UNPAID_TRANSACTIONS_REPORT: List<RefillHeaderDataEntity> unpaidReport = m_refillReportDao .GetUnpaidTransactionsReport(customer, fromDateTime, toDateTime, b_isAll) as List<RefillHeaderDataEntity>; parameters = SetReportParameters(customer, fromDateTime, toDateTime, b_isAll); datasources.Add(new ReportDataSource(ReportConstants.DS_REFILLHEADER, unpaidReport)); m_view.DisplayReport(unpaidReport, datasources, parameters, ReportConstants.ES_REFILL_UNPAIDTRANSACTIONS_REPORT); break; case ReportConstants.INVENTORY_ACTIVITY_REPORT: List<RefillInventoryReportDataEntity> invActReport = m_refillReportDao .GetInventoryActivityReport(fromDateTime, toDateTime, product) as List<RefillInventoryReportDataEntity>; parameters = SetReportParameters(fromDateTime, toDateTime); datasources.Add(new ReportDataSource(ReportConstants.DS_REFILLINVENTORYDETAIL, invActReport)); m_view.DisplayReport(invActReport, datasources, parameters, ReportConstants.ES_REFILL_INVENTORYACTIVITY_REPORT); break; case ReportConstants.INVENTORY_REPORT: List<RefillInventoryHeaderDataEntity> invHeader = m_refillReportDao .GetInventoryReport(product) as List<RefillInventoryHeaderDataEntity>; datasources.Add(new ReportDataSource(ReportConstants.DS_REFILLINVENTORYHEADER, invHeader)); m_view.DisplayReport(invHeader, datasources, parameters, ReportConstants.ES_REFILL_INVENTORY_REPORT); break; case ReportConstants.CUSTINVENTORY_REPORT: List<RefillCustInventoryHeaderDataEntity> custInvReport = m_refillReportDao .GetCustomerInventoryReport(customer, b_isAll) as List<RefillCustInventoryHeaderDataEntity>; parameters = SetReportParameters(customer, b_isAll); datasources.Add(new ReportDataSource(ReportConstants.DS_REFILLCUSTINVENTORY, custInvReport)); m_view.DisplayReport(custInvReport, datasources, parameters, ReportConstants.ES_REFILL_CUSTINVENTORY_REPORT); break; case ReportConstants.VOID_TRANSACTIONS_REPORT: List<RefillHeaderDataEntity> voidReport = m_refillReportDao .GetVoidTransactionsReport(customer, fromDateTime, toDateTime, b_isAll) as List<RefillHeaderDataEntity>; parameters = SetReportParameters(customer, fromDateTime, toDateTime, b_isAll); datasources.Add(new ReportDataSource(ReportConstants.DS_REFILLHEADER, voidReport)); m_view.DisplayReport(voidReport, datasources, parameters, ReportConstants.ES_REFILL_VOIDTRANSACTIONS_REPORT); break; default: break; } datasources.Clear(); }
private void RunLaundryReport(string selectedReport, CustomerDataEntity customer, DateTime fromDateTime, DateTime toDateTime, bool b_isAll) { List<ReportDataSource> datasources = new List<ReportDataSource>(); List<ReportParameter> parameters = SetReportParameters(customer, fromDateTime, toDateTime, b_isAll); switch(selectedReport) { case ReportConstants.SALES_REPORT: List<LaundryDaySummaryDataEntity> salesReport = m_laundryReportDao .GetCustomerSalesReport(customer, fromDateTime, toDateTime, b_isAll) as List<LaundryDaySummaryDataEntity>; datasources.Add(new ReportDataSource(ReportConstants.DS_LAUNDRYDAYSUMMARY, salesReport)); m_view.DisplayReport(salesReport, datasources, parameters, ReportConstants.ES_LAUNDRY_SALES_REPORT); break; case ReportConstants.UNCLAIMED_ITEMS_REPORT: List<LaundryHeaderDataEntity> unclaimedReport = m_laundryReportDao .GetUnclaimedItemsReport(customer, fromDateTime, toDateTime, b_isAll) as List<LaundryHeaderDataEntity>; datasources.Add(new ReportDataSource(ReportConstants.DS_LAUNDRYHEADER, unclaimedReport)); m_view.DisplayReport(unclaimedReport, datasources, parameters, ReportConstants.ES_LAUNDRY_UNCLAIMEDITEMS_REPORT); break; case ReportConstants.CLAIMED_ITEMS_REPORT: List<LaundryHeaderDataEntity> claimedReport = m_laundryReportDao .GetClaimedItemsReport(customer, fromDateTime, toDateTime, b_isAll) as List<LaundryHeaderDataEntity>; datasources.Add(new ReportDataSource(ReportConstants.DS_LAUNDRYHEADER, claimedReport)); m_view.DisplayReport(claimedReport, datasources, parameters, ReportConstants.ES_LAUNDRY_CLAIMEDITEMS_REPORT); break; case ReportConstants.UNPAID_TRANSACTIONS_REPORT: List<LaundryHeaderDataEntity> unpaidReport = m_laundryReportDao .GetUnpaidTransactionsReport(customer, fromDateTime, toDateTime, b_isAll) as List<LaundryHeaderDataEntity>; datasources.Add(new ReportDataSource(ReportConstants.DS_LAUNDRYHEADER, unpaidReport)); m_view.DisplayReport(unpaidReport, datasources, parameters, ReportConstants.ES_LAUNDRY_UNPAIDTRANSACTIONS_REPORT); break; case ReportConstants.VOID_TRANSACTIONS_REPORT: List<LaundryHeaderDataEntity> voidReport = m_laundryReportDao .GetVoidTransactionsReport(customer, fromDateTime, toDateTime, b_isAll) as List<LaundryHeaderDataEntity>; datasources.Add(new ReportDataSource(ReportConstants.DS_LAUNDRYHEADER, voidReport)); m_view.DisplayReport(voidReport, datasources, parameters, ReportConstants.ES_LAUNDRY_VOIDTRANSACTIONS_REPORT); break; default: break; } datasources.Clear(); }
public void saveNewHeaderAndNewDaySummary() { // test for new header and new day // should create new record for daysummary LaundryHeaderDataEntity header = new LaundryHeaderDataEntity(); LaundryDetailDataEntity detail = new LaundryDetailDataEntity(); LaundryJobChargesDataEntity jobcharge = new LaundryJobChargesDataEntity(); LaundryCategoryDataEntity category = new LaundryCategoryDao().GetByName("Colored Garments"); LaundryServiceDataEntity service = new LaundryServiceDao().GetByName("Wash - Dry - Fold"); LaundryPriceSchemeDataEntity pricescheme = new LaundryPriceSchemeDao().GetByCategoryService(service,category); CustomerDao custdao = new CustomerDao(); CustomerDataEntity customer = custdao.GetByName("John Dee"); if(customer == null) { customer = new CustomerDataEntity(); customer.Name = "John Dee"; customer.Address = "Cebu"; customer.ContactNumber = "111-1111"; } header.Customer = customer; header.ReceivedDate = DateTime.Now; header.DueDate = DateTime.Now.AddDays(5); // add 5 days for due date detail.Header = header; // set header entity in detail for nhibernate to pickup and map detail.Category = category; detail.Service = service; detail.Kilo = 5; detail.Amount = pricescheme.Price * Convert.ToDecimal(detail.Kilo); detail.ItemQty = 20; jobcharge.Charge = new LaundryChargeDao().GetByName("Delivery"); jobcharge.Header = header; // set header entity in jobcharge for nhibernate to pickup and map header.DetailEntities.Add(detail); // add detail to header details list header.JobChargeEntities.Add(jobcharge); // add charges to header charges list header.ClaimFlag = false; header.AmountDue = detail.Amount; header.TotalItemQty = detail.ItemQty; header.TotalCharge = jobcharge.Charge.Amount; header.TotalDiscount = 0; header.TotalAmountDue = (header.AmountDue + header.TotalCharge) - header.TotalDiscount; header.TotalPayment = header.TotalAmountDue; if(header.TotalPayment == header.TotalAmountDue){ header.PaidFlag = true; } else{ header.PaidFlag = false; } // set paymentdetail LaundryPaymentDetailDataEntity paymentdetail = new LaundryPaymentDetailDataEntity(); paymentdetail.Amount = header.TotalPayment; paymentdetail.PaymentDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()); paymentdetail.Header = header; header.PaymentDetailEntities.Add(paymentdetail); // set daysummary LaundryDaySummaryDataEntity daysummary = new LaundryDaySummaryDataEntity(); daysummary.DayStamp = Convert.ToDateTime(DateTime.Now.ToShortDateString()); daysummary.TotalSales += header.TotalPayment; daysummary.TransCount += 1; daysummary.HeaderEntities.Add(header); // set header entity in daysummary for nhibernate to pickup and map header.DaySummary = daysummary; // set daysummary entity in header for nhibernate to pickup and map custdao.SaveOrUpdate(customer); // save or update customer // save daysummary record; no need to explicitly save header,detail,jobcharges,paymentdetail, etc for new daysummary record // this will handle the saving for the linked tables // FIX: save new header & new daysummary thru laundrydao instead of laundrydaysummary LaundryDao dao = new LaundryDao(); dao.SaveOrUpdate(header); }
public void saveNewHeaderAndUpdateDaySummary() { // test for new header but with existing daysummary // should not save new record for daysummary // should only update existing daysummary with transcount and sales DateTime sampleDay = Convert.ToDateTime(DateTime.Now.ToShortDateString()); // daystamp in daysummary should be date only (no time); LaundryDaySummaryDao summarydao = new LaundryDaySummaryDao(); LaundryDaySummaryDataEntity summary = summarydao.GetByDay(sampleDay); if(summary!= null) { LaundryHeaderDataEntity header = new LaundryHeaderDataEntity(); LaundryDetailDataEntity detail = new LaundryDetailDataEntity(); LaundryJobChargesDataEntity jobcharge = new LaundryJobChargesDataEntity(); LaundryCategoryDataEntity category = new LaundryCategoryDao().GetByName("White Garments"); LaundryServiceDataEntity service = new LaundryServiceDao().GetByName("Wash - Dry - Press"); LaundryPriceSchemeDataEntity pricescheme = new LaundryPriceSchemeDao().GetByCategoryService(service,category); CustomerDao custdao = new CustomerDao(); CustomerDataEntity customer = custdao.GetByName("John Dee"); if(customer == null) { customer = new CustomerDataEntity(); customer.Name = "John Dee"; customer.Address = "Cebu"; customer.ContactNumber = "111-1111"; } header.Customer = customer; header.ReceivedDate = DateTime.Now; header.DueDate = DateTime.Now.AddDays(5); // add 5 days for due date detail.Header = header; // set header entity in detail for nhibernate to pickup and map detail.Category = category; detail.Service = service; detail.Kilo = 100; detail.Amount = pricescheme.Price * Convert.ToDecimal(detail.Kilo); detail.ItemQty = 300; jobcharge.Charge = new LaundryChargeDao().GetByName("Delivery"); jobcharge.Header = header; // set header entity in jobcharge for nhibernate to pickup and map header.DetailEntities.Add(detail); // add detail to header details list header.JobChargeEntities.Add(jobcharge); // add charges to header charges list header.ClaimFlag = false; header.AmountDue = detail.Amount; header.TotalItemQty = detail.ItemQty; header.TotalCharge = jobcharge.Charge.Amount; header.TotalDiscount = 50.00M; header.TotalAmountDue = (header.AmountDue + header.TotalCharge) - header.TotalDiscount; header.TotalPayment += 50.00M; // accumulate amount tender with current amount tender // TODO: should update paidflag in header if total balance = 0. // set paymentdetail LaundryPaymentDetailDataEntity paymentdetail = new LaundryPaymentDetailDataEntity(); paymentdetail.Amount = header.TotalPayment; paymentdetail.PaymentDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()); paymentdetail.Header = header; header.PaymentDetailEntities.Add(paymentdetail); summary.TransCount += 1; summary.TotalSales += header.TotalPayment; header.DaySummary = summary; // update daysummary with transcount and totalsales LaundryDaySummaryDao dao = new LaundryDaySummaryDao(); dao.Update(summary); // save header,details,etc. LaundryDao ldao = new LaundryDao(); ldao.SaveOrUpdate(header); } }
void BtnDeleteCustomerClick(object sender, EventArgs e) { CustomerDataEntity customer = new CustomerDataEntity(); string pendingCustomers = string.Empty; if(dgvCustomerList.SelectedRows.Count > 0) { if(MessageService.ShowYesNo("Are you sure you want to remove the selected customer from the list?", "Remove Customer")) { try { foreach(DataGridViewRow currentRow in dgvCustomerList.SelectedRows) { int ID = (int)dgvCustomerList.Rows[currentRow.Index].Cells["CustomerID"].Value; customer = m_customersEntity.Find(m_customer => m_customer.CustomerID == ID); customer.VoidFlag = true; if(!m_presenter.VerifyCustomerPendingTransaction(customer)) { m_presenter.SaveOrUpdateCustomer(customer); dgvCustomerList.Rows.Remove(dgvCustomerList.Rows[currentRow.Index]); } else { pendingCustomers += customer.Name + ", "; } } if(!pendingCustomers.Equals(string.Empty)) { MessageService.ShowWarning("Unable to delete customer: " + pendingCustomers.Remove(pendingCustomers.LastIndexOf(',')).Trim() + " due to pending transaction.", "Pending transaction"); } m_presenter.SetAllCustomerList(); } catch(Exception ex) { MessageService.ShowError("Unable to delete data; an unexpected error occurred.\n" + "Please check error log for details.\n", ex); } } } }
void BtnSaveClick(object sender, EventArgs e) { if(txtName.Text.Trim() == "") { errorProvider.SetError(txtName, "Name is required."); return; } else { errorProvider.SetError(txtName, ""); CustomerDataEntity customer = new CustomerDataEntity(); string name = txtName.Text.ToString().Trim(); string address = txtAddress.Text.ToString().Trim(); string number = txtNumber.Text.ToString().Trim(); if(selectedIndex != -1) { int ID = (int)dgvCustomerList.Rows[selectedIndex].Cells["CustomerID"].Value; customer = m_customersEntity.Find(m_customer => m_customer.CustomerID == ID); } else { customer = m_customersEntity.Find(m_customer => m_customer.Name.ToUpper() == name.ToUpper()); if(customer != null && customer.CustomerID != 0) { MessageService.ShowWarning("Unable to insert duplicate name: " + name); return; } else { customer = new CustomerDataEntity(); } } customer.Name = name; customer.Address = address; customer.ContactNumber = number; customer.VoidFlag = false; try { m_presenter.SaveOrUpdateCustomer(customer); selectedIndex = -1; ClearData(); m_presenter.SetAllCustomerList(); MessageService.ShowInfo("Successfully saved/updated customer details"); } catch(Exception ex) { MessageService.ShowError("Unable to save data; an unexpected error occurred.\n" + "Please check error log for details.\n", ex); ; } } }
public IEnumerable<LaundryHeaderDataEntity> GetUnclaimedItemsReport(CustomerDataEntity customer) { using(var session = NHibernateHelper.OpenSession()) { using(var transaction = session.BeginTransaction()) { var query = session.CreateCriteria<LaundryHeaderDataEntity>("header") .Add(Restrictions.Eq("header.Customer", customer)) .Add(Restrictions.Eq("header.ClaimFlag", false)) .Add(Restrictions.Eq("header.VoidFlag",false)) .AddOrder(Order.Asc("header.ReceivedDate")) .List<LaundryHeaderDataEntity>(); return query; } } }
public void saveNewHeaderAndNewDaySummary() { // test for new header and new day // should create new record for daysummary RefillHeaderDataEntity header = new RefillHeaderDataEntity(); RefillDetailDataEntity detail = new RefillDetailDataEntity(); RefillTransactionTypeDataEntity transactionType = new RefillTransactionTypeDao().GetByName("Delivery"); RefillProductTypeDataEntity productType = new RefillProductTypeDao().GetByName("5 Gal at 25"); CustomerDao custdao = new CustomerDao(); CustomerDataEntity customer = custdao.GetByName("Vanessa Dee"); if(customer == null) { customer = new CustomerDataEntity(); customer.Name = "Vanessa Dee"; customer.Address = "Cebu"; customer.ContactNumber = "111-1111"; } header.Date = DateTime.Now; header.TransactionType = transactionType; detail.Header = header; // set header entity in detail for nhibernate to pickup and map detail.ProductType = productType; detail.Qty = 10; detail.Amount = productType.Price * Convert.ToDecimal(detail.Qty); detail.StoreBottleQty = 10; detail.StoreCapQty = 10; // update main inventory // TODO: fix proper handling of inventory per type of bottle??? RefillInventoryDao refillInvDao = new RefillInventoryDao(); RefillInventoryHeaderDataEntity inv = new RefillInventoryHeaderDataEntity(); //inv = refillInvDao.GetByName("Cap"); //inv.TotalQty = 500; //inv.QtyOnHand -= detail.StoreCapQty; //inv.QtyReleased += detail.StoreCapQty; //refillInvDao.Update(inv); inv = refillInvDao.GetByName("5 Gal Bottle"); inv.QtyOnHand -= detail.StoreBottleQty; inv.QtyReleased += detail.StoreBottleQty; refillInvDao.Update(inv); // update cust inventory RefillCustomerInventoryDao custInvDao = new RefillCustomerInventoryDao(); RefillCustInventoryHeaderDataEntity custInv= new RefillCustInventoryHeaderDataEntity(); custInv.Customer = customer; custInv.CapsOnHand += detail.StoreCapQty; custInv.BottlesOnHand += detail.StoreBottleQty; header.Customer = customer; header.DetailEntities.Add(detail); // add detail to header details list header.AmountDue = detail.Amount; header.TotalQty = detail.Qty; header.AmountTender = header.AmountDue; if(header.AmountTender == header.AmountTender){ header.PaidFlag = true; } else{ header.PaidFlag = false; } // set paymentdetail RefillPaymentDetailDataEntity paymentdetail = new RefillPaymentDetailDataEntity(); paymentdetail.Amount = header.AmountTender; paymentdetail.PaymentDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()); paymentdetail.Header = header; header.PaymentDetailEntities.Add(paymentdetail); // set daysummary RefillDaySummaryDataEntity daysummary = new RefillDaySummaryDataEntity(); daysummary.DayStamp = Convert.ToDateTime(DateTime.Now.ToShortDateString()); daysummary.TotalSales += header.AmountTender; daysummary.TransCount += 1; daysummary.HeaderEntities.Add(header); // set header entity in daysummary for nhibernate to pickup and map header.DaySummary = daysummary; // set daysummary entity in header for nhibernate to pickup and map custdao.SaveOrUpdate(customer); // save or update customer custInvDao.SaveOrUpdate(custInv); // save daysummary record; no need to explicitly save header,detail,jobcharges,paymentdetail, etc for new daysummary record // this will handle the saving for the linked tables RefillDao ldao = new RefillDao(); ldao.SaveOrUpdate(header); }
public IEnumerable<RefillHeaderDataEntity> GetUnpaidTransactionsReport(CustomerDataEntity customer) { using(var session = NHibernateHelper.OpenSession()) { using(var transaction = session.BeginTransaction()) { var query = session.CreateCriteria<RefillHeaderDataEntity>("header") .Add(Restrictions.Eq("header.Customer", customer)) .Add(Restrictions.Eq("header.PaidFlag", false)) .Add(Restrictions.Eq("header.VoidFlag",false)) .AddOrder(Order.Asc("header.Date")) .List<RefillHeaderDataEntity>(); return query; } } }