public void SetData() { try { // populate data var model = Factories.CreateDailySale().Get(dailySaleID); dtDate.Value = model.Date; txtOutletSale1.Text = model.OutletSale1.ToString(); txtOutletSale2.Text = model.OutletSale2.ToString(); txtProcessingSale.Text = model.ProcessingSale.ToString(); // Total Cash Sale Dairy Product txtTotalCashSale.Text = model.TotalCashSales.ToString(); txtRawMilkSales.Text = model.RawMilkSales.ToString(); txtSalesOnAccount.Text = model.SaleOnAccount.ToString(); txtTotalSaleDairyProducts.Text = model.TotalSaleForDairyProduct.ToString(); // Total Sale Over All Sale txtTotalSale.Text = model.TotalSales.ToString(); txtDebtor.Text = model.Debtor.ToString(); } catch (Exception ex) { LocalUtils.ShowErrorMessage(this, ex.ToString()); } }
public void Delete() { try { if (gridList.SelectedRows.Count > 0) { dailySaleID = int.Parse(gridList.SelectedRows[0].Cells[0].Value.ToString()); if (dailySaleID != 0) { DialogResult result = MetroMessageBox.Show(this, "Are you sure you want to delete this record?", "Milk Collection", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { Factories.CreateDailySale().Delete(dailySaleID); LocalUtils.ShowDeleteSuccessMessage(this); ShowMainGrid(); dailySaleID = 0; } } else { LocalUtils.ShowNoRecordFoundMessage(this); } } else { LocalUtils.ShowNoRecordSelectedMessage(this); } } catch (Exception) { throw; } }
public void LoadMainGrid() { try { var date = dtSearchDate.Value; var models = Factories.CreateDailySale().GetAllByMonth(date); gridList.Rows.Clear(); int count = 0; foreach (var item in models) { count++; gridList.Rows.Add(new string[] { item.ID.ToString(), count.ToString(), item.Date.ToShortDateString(), item.OutletSale1.ToString(), item.OutletSale2.ToString(), item.ProcessingSale.ToString(), item.TotalCashSales.ToString(), item.SaleOnAccount.ToString(), item.TotalSaleForDairyProduct.ToString(), item.TotalSales.ToString(), item.Debtor }); } //use 0 id to avoid null exception while click edit button ////Adds space //var summaryModels = mainLogic.GetAllSummary(date); //gridList.Rows.Add(new string[] { "0","", // "", // "Total", // summaryModels.TotalMilkSold .ToString() , // summaryModels.TotalMilkSoldAmount .ToString() , // summaryModels.TotalB1plus1 .ToString() , // summaryModels.TotalDiscountSale .ToString() , // summaryModels.TotalEcoBag .ToString() , // summaryModels.TotalOutletSale1 .ToString() , // summaryModels.TotalOutletSale2 .ToString() , // summaryModels.TotalProcessingSale .ToString() , // summaryModels.GrandTotalCashSale .ToString() , // summaryModels.TotalSaleOnAccount .ToString() , // summaryModels.GrandTotalSaleDairyProduct .ToString() , // }); SetGridListCustomDesign(); } catch (Exception ex) { LocalUtils.ShowErrorMessage(this, ex.ToString()); } }
public void SetInitialData() { try { // populate data var model = Factories.CreateDailySale().GetInitial(dtDate.Value); dtDate.Value = model.Date; txtOutletSale1.Text = model.OutletSale1.ToString(); txtOutletSale2.Text = model.OutletSale2.ToString(); txtRawMilkSales.Text = model.RawMilkSales.ToString(); } catch (Exception ex) { LocalUtils.ShowErrorMessage(this, ex.ToString()); } }
public void Save() { try { if (!ValidateFields()) { LocalUtils.ShowValidationFailedMessage(this); } else { var model = new DailySaleRecordModel(); model.Debtor = txtDebtor.Text; model.Date = dtDate.Value; model.ProcessingSale = LocalUtils.ConvertToDouble(txtProcessingSale.Text); model.SaleOnAccount = LocalUtils.ConvertToDouble(txtSalesOnAccount.Text); // get id if (dailySaleID != 0) { Factories.CreateDailySale().Edit(dailySaleID, model); LocalUtils.ShowSaveMessage(this); } else { Factories.CreateDailySale().Add(model); dailySaleID = model.ID; LocalUtils.ShowSaveMessage(this); } } } catch (ApplicationException ex) { LocalUtils.ShowErrorMessage(this, ex.Message); } catch (Exception ex) { LocalUtils.ShowErrorMessage(this, ex.ToString()); } }
private void Compute() { try { var outletSale1 = LocalUtils.ConvertToDouble(txtOutletSale1.Text); var outletSale2 = LocalUtils.ConvertToDouble(txtOutletSale2.Text); var processingSale = LocalUtils.ConvertToDouble(txtProcessingSale.Text); var saleOnAccount = LocalUtils.ConvertToDouble(txtSalesOnAccount.Text); var rawMilkSale = LocalUtils.ConvertToDouble(txtRawMilkSales.Text); var totalSaleDairyProduct = LocalUtils.ConvertToDouble(txtTotalSaleDairyProducts.Text); var c_totalCashSale = Factories.CreateDailySale().ComputeTotalCashSale(outletSale1, outletSale2, processingSale); var c_totalSale = Factories.CreateDailySale().ComputeTotalSale(outletSale1, outletSale2, processingSale, saleOnAccount, rawMilkSale); var c_totalSaleDairyProduct = Factories.CreateDailySale().ComputeTotalSaleDairyProduct(outletSale1, outletSale2, processingSale, saleOnAccount); txtTotalSale.Text = c_totalSale.ToString(); txtTotalCashSale.Text = c_totalCashSale.ToString(); txtTotalSaleDairyProducts.Text = c_totalSaleDairyProduct.ToString(); } catch (Exception ex) { LocalUtils.ShowErrorMessage(this, ex.ToString()); } }