void showByDate() { DateTime fromdate = DateTime.ParseExact(dtFrom.Text, "dd-MM-yyyy", null); DateTime todate = DateTime.ParseExact(dtTo.Text, "dd-MM-yyyy", null); List <DetailSettlementVM> modelList = new List <DetailSettlementVM>(); List <tbl_PurchaseMaster> data = new List <tbl_PurchaseMaster>(); #region PurchaseData _entities = new KBBQEntities(); data = _entities.tbl_PurchaseMaster.Where(x => x.date >= fromdate && x.date <= todate).ToList(); int rowNo = 1; foreach (var item in data) { DetailSettlementVM model = new DetailSettlementVM(); model.rowNo = rowNo; DateTime dt = Convert.ToDateTime(item.date).Date; model.monthYear = dt.Date.ToString("dd-MM-yyyy"); model.AmountPaid = Convert.ToDecimal(amtFormat.comma(item.totalAmt)); model.KOT = item.refNo; rowNo++; modelList.Add(model); ttlAmt += Convert.ToDecimal(item.totalAmt); } DetailSettlementVM models = new DetailSettlementVM(); models.totalAmount = Convert.ToDecimal(ttlAmt); modelList.Add(models); ReportDataSource datasource = new ReportDataSource("DataSet1", modelList); this.reportViewer1.LocalReport.DataSources.Clear(); this.reportViewer1.LocalReport.DataSources.Add(datasource); #endregion }
void showByDate() { _entities = new KBBQEntities(); DateTime fromdate = DateTime.ParseExact(dtFrom.Text, "dd-MM-yyyy", null); DateTime todate = DateTime.ParseExact(dtTo.Text, "dd-MM-yyyy", null); List <PurchaseMasterVM> modelList = new List <PurchaseMasterVM>(); List <tbl_PurchaseMaster> data = new List <tbl_PurchaseMaster>(); List <DetailSettlementVM> modelListSales = new List <DetailSettlementVM>(); List <detailsSettlement> dataSales = new List <detailsSettlement>(); #region Salesregion ttlAmt = 0; int rowNo = 1; dataSales = new List <detailsSettlement>(); dataSales = _entities.detailsSettlements.Where(x => x.paidDate >= fromdate && x.paidDate <= todate).ToList(); foreach (var item in dataSales) { DetailSettlementVM model = new DetailSettlementVM(); model.rowNo = rowNo; DateTime dt = Convert.ToDateTime(item.paidDate).Date; model.monthYear = dt.Date.ToString("dd-MM-yyyy"); model.AmountPaid = Convert.ToDecimal(amtFormat.comma(item.bill)); model.KOT = item.receiptno; rowNo++; modelListSales.Add(model); ttlAmt += Convert.ToDecimal(item.bill); _entities = new KBBQEntities(); var checkForAdvancePay = _entities.tblAdvBookings.Where(x => x.recptNo == item.receiptno).FirstOrDefault(); if (checkForAdvancePay != null) { ttlAmt += checkForAdvancePay.advancePayment; model.advancePaid = checkForAdvancePay.advancePayment; } else { model.advancePaid = 0; } // lblSalesTotalAmt.Text = amtFormat.comma(ttlAmt).ToString(); } DetailSettlementVM models = new DetailSettlementVM(); models.totalAmount = Convert.ToDecimal(ttlAmt); modelListSales.Add(models); ReportDataSource datasource = new ReportDataSource("DataSet1", modelListSales); this.reportViewer1.LocalReport.DataSources.Clear(); this.reportViewer1.LocalReport.DataSources.Add(datasource); #endregion }
void showReport() { try { ttlAmt = 0; int rowNo = 1; _entities = new KBBQEntities(); List <DetailSettlementVM> modelListSales = new List <DetailSettlementVM>(); List <detailsSettlement> dataSales = new List <detailsSettlement>(); if (type == "--All--") { #region Salesregion ttlAmt = 0; rowNo = 1; dataSales = new List <detailsSettlement>(); dataSales = _entities.detailsSettlements.ToList(); foreach (var item in dataSales) { DetailSettlementVM model = new DetailSettlementVM(); model.rowNo = rowNo; DateTime dt = Convert.ToDateTime(item.paidDate).Date; model.monthYear = dt.Date.ToString("dd-MM-yyyy"); model.AmountPaid = Convert.ToDecimal(amtFormat.comma(item.bill)); model.KOT = item.receiptno; rowNo++; ttlAmt += Convert.ToDecimal(item.bill); _entities = new KBBQEntities(); var checkForAdvancePay = _entities.tblAdvBookings.Where(x => x.recptNo == item.receiptno).FirstOrDefault(); if (checkForAdvancePay != null) { ttlAmt += checkForAdvancePay.advancePayment; model.advancePaid = checkForAdvancePay.advancePayment; } else { model.advancePaid = 0; } modelListSales.Add(model); // lblSalesTotalAmt.Text = amtFormat.comma(ttlAmt).ToString(); } DetailSettlementVM models = new DetailSettlementVM(); models.totalAmount = Convert.ToDecimal(ttlAmt); modelListSales.Add(models); ReportDataSource datasource = new ReportDataSource("DataSet1", modelListSales); this.reportViewer1.LocalReport.DataSources.Clear(); this.reportViewer1.LocalReport.DataSources.Add(datasource); #endregion } else if (type == "Month") { string dates = ""; decimal?amt = 0; int rowId = -1; #region Sales Data ttlAmt = 0; rowNo = 1; _entities = new KBBQEntities(); dataSales = new List <detailsSettlement>(); dataSales = _entities.detailsSettlements.ToList(); int dataSaleCount = dataSales.Count(); int count = 0; dates = ""; amt = 0; rowId = -1; decimal? advPaid = 0; DetailSettlementVM model = new DetailSettlementVM(); foreach (var item in dataSales) { var date = Convert.ToDateTime(item.paidDate).Date; string dd = date.ToString("MMM"); if (dd != dates) { model = new DetailSettlementVM(); model.rowNo = rowNo; model.monthYear = dd; model.KOT = "--"; //modelListSales.Add(model); //dgSalesReport.Rows.Add("0", rowNo, dd); dates = dd; amt = 0; rowId++; } amt += item.bill; model.AmountPaid = Convert.ToDecimal(amtFormat.comma(amt)); if (dd != dates) { modelListSales.Add(model); } rowNo++; count++; ttlAmt += item.bill; _entities = new KBBQEntities(); var checkForAdvancePay = _entities.tblAdvBookings.Where(x => x.recptNo == item.receiptno).FirstOrDefault(); if (checkForAdvancePay != null) { ttlAmt += checkForAdvancePay.advancePayment; advPaid += Convert.ToDecimal(checkForAdvancePay.advancePayment); model.advancePaid = advPaid; } if (dataSaleCount == count) { modelListSales.Add(model); } } DetailSettlementVM models = new DetailSettlementVM(); models.totalAmount = Convert.ToDecimal(ttlAmt); modelListSales.Add(models); ReportDataSource datasource = new ReportDataSource("DataSet1", modelListSales); this.reportViewer1.LocalReport.DataSources.Clear(); this.reportViewer1.LocalReport.DataSources.Add(datasource); #endregion } else { string dates = ""; decimal?amt = 0; int rowId = -1; #region Sales Data ttlAmt = 0; rowNo = 1; _entities = new KBBQEntities(); dataSales = new List <detailsSettlement>(); dataSales = _entities.detailsSettlements.ToList(); int dataSaleCount = dataSales.Count(); int count = 0; dates = ""; amt = 0; rowId = -1; decimal? advPaid = 0; DetailSettlementVM model = new DetailSettlementVM(); foreach (var item in dataSales) { var date = Convert.ToDateTime(item.paidDate).Date; string dd = date.ToString("yyyy"); if (dd != dates) { model = new DetailSettlementVM(); model.rowNo = rowNo; model.monthYear = dd; model.KOT = "--"; //modelListSales.Add(model); //dgSalesReport.Rows.Add("0", rowNo, dd); dates = dd; amt = 0; rowId++; } amt += item.bill; model.AmountPaid = Convert.ToDecimal(amtFormat.comma(amt)); if (dd != dates) { modelListSales.Add(model); } rowNo++; count++; ttlAmt += item.bill; _entities = new KBBQEntities(); var checkForAdvancePay = _entities.tblAdvBookings.Where(x => x.recptNo == item.receiptno).FirstOrDefault(); if (checkForAdvancePay != null) { ttlAmt += checkForAdvancePay.advancePayment; advPaid += Convert.ToDecimal(checkForAdvancePay.advancePayment); model.advancePaid = advPaid; } if (dataSaleCount == count) { modelListSales.Add(model); } } DetailSettlementVM models = new DetailSettlementVM(); models.totalAmount = Convert.ToDecimal(ttlAmt); modelListSales.Add(models); ReportDataSource datasource = new ReportDataSource("DataSet1", modelListSales); this.reportViewer1.LocalReport.DataSources.Clear(); this.reportViewer1.LocalReport.DataSources.Add(datasource); #endregion } } catch (Exception x) { } }
private void datagridBind(string type) { try { dgPurchaseReport.AutoGenerateColumns = false; dgSalesReport.AutoGenerateColumns = false; ttlAmt = 0; int rowNo = 1; _entities = new KBBQEntities(); List <PurchaseMasterVM> modelList = new List <PurchaseMasterVM>(); List <tbl_PurchaseMaster> data = new List <tbl_PurchaseMaster>(); List <DetailSettlementVM> modelListSales = new List <DetailSettlementVM>(); List <detailsSettlement> dataSales = new List <detailsSettlement>(); if (type == "--All--") { #region PurchaseData data = _entities.tbl_PurchaseMaster.ToList(); foreach (var item in data) { PurchaseMasterVM model = new PurchaseMasterVM(); model.rowNo = rowNo; DateTime dt = Convert.ToDateTime(item.date).Date; model.monthYear = dt.Date.ToString("dd-MM-yyyy"); model.totalAmt = Convert.ToDecimal(amtFormat.comma(item.totalAmt)); model.KOT = item.refNo; rowNo++; modelList.Add(model); ttlAmt += Convert.ToDecimal(item.totalAmt); lblTotalAmt.Text = amtFormat.comma(ttlAmt).ToString(); } dgPurchaseReport.DataSource = modelList; lblTotalRows.Text = modelList.Count.ToString(); #endregion #region Salesregion ttlAmt = 0; rowNo = 1; dataSales = new List <detailsSettlement>(); dataSales = _entities.detailsSettlements.ToList(); foreach (var item in dataSales) { DetailSettlementVM model = new DetailSettlementVM(); model.rowNo = rowNo; DateTime dt = Convert.ToDateTime(item.paidDate).Date; model.monthYear = dt.Date.ToString("dd-MM-yyyy"); model.AmountPaid = Convert.ToDecimal(amtFormat.comma(item.bill)); model.KOT = item.receiptno; rowNo++; modelListSales.Add(model); ttlAmt += Convert.ToDecimal(item.bill); _entities = new KBBQEntities(); var checkForAdvancePay = _entities.tblAdvBookings.Where(x => x.recptNo == item.receiptno).FirstOrDefault(); if (checkForAdvancePay != null) { ttlAmt += checkForAdvancePay.advancePayment; model.advancePaid = checkForAdvancePay.advancePayment; } else { model.advancePaid = 0; } lblSalesTotalAmt.Text = amtFormat.comma(ttlAmt).ToString(); } dgSalesReport.DataSource = modelListSales; lblSalesRow.Text = modelList.Count.ToString(); #endregion } else if (type == "Month") { #region Purchase Data ttlAmt = 0; rowNo = 1; dgPurchaseReport.DataSource = null; dgPurchaseReport.Rows.Clear(); _entities = new KBBQEntities(); data = new List <tbl_PurchaseMaster>(); data = _entities.tbl_PurchaseMaster.ToList(); string dates = ""; decimal?amt = 0; int rowId = -1; foreach (var item in data) { var date = Convert.ToDateTime(item.date).Date; string dd = date.ToString("MMM"); if (dd != dates) { dgPurchaseReport.Rows.Add("0", rowNo, "--", dd); dates = dd; amt = 0; rowId++; } amt += item.totalAmt; dgPurchaseReport.Rows[rowId].Cells[4].Value = amtFormat.comma(amt); rowNo++; ttlAmt += item.totalAmt; lblTotalAmt.Text = amtFormat.comma(ttlAmt).ToString(); } lblTotalRows.Text = modelList.Count.ToString(); #endregion #region Sales Data ttlAmt = 0; rowNo = 1; dgSalesReport.DataSource = null; dgSalesReport.Rows.Clear(); _entities = new KBBQEntities(); dataSales = new List <detailsSettlement>(); dataSales = _entities.detailsSettlements.ToList(); dates = ""; amt = 0; rowId = -1; decimal?advPay = 0; foreach (var item in dataSales) { var date = Convert.ToDateTime(item.paidDate).Date; string dd = date.ToString("MMM"); if (dd != dates) { dgSalesReport.Rows.Add("0", rowNo, "--", dd); dates = dd; amt = 0; rowId++; } amt += item.bill; dgSalesReport.Rows[rowId].Cells[5].Value = amtFormat.comma(amt); ttlAmt += item.bill; _entities = new KBBQEntities(); var checkForAdvancePay = _entities.tblAdvBookings.Where(x => x.recptNo == item.receiptno).FirstOrDefault(); if (checkForAdvancePay != null) { ttlAmt += checkForAdvancePay.advancePayment; advPay += checkForAdvancePay.advancePayment; dgSalesReport.Rows[rowId].Cells[4].Value = advPay; } rowNo++; lblSalesTotalAmt.Text = amtFormat.comma(ttlAmt).ToString(); } lblSalesRow.Text = modelList.Count.ToString(); #endregion } else { #region Purchase Data ttlAmt = 0; rowNo = 1; dgPurchaseReport.DataSource = null; dgPurchaseReport.Rows.Clear(); _entities = new KBBQEntities(); data = new List <tbl_PurchaseMaster>(); data = _entities.tbl_PurchaseMaster.ToList(); string dates = ""; decimal?amt = 0; int rowId = -1; foreach (var item in data) { var date = Convert.ToDateTime(item.date).Date; string dd = date.ToString("yyyy"); if (dd != dates) { dgPurchaseReport.Rows.Add("0", rowNo, "--", dd); dates = dd; amt = 0; rowId++; } amt += item.totalAmt; dgPurchaseReport.Rows[rowId].Cells[4].Value = amtFormat.comma(amt); rowNo++; ttlAmt += item.totalAmt; lblTotalAmt.Text = amtFormat.comma(ttlAmt).ToString(); } lblTotalRows.Text = modelList.Count.ToString(); #endregion #region Sales Data ttlAmt = 0; rowNo = 1; dgSalesReport.DataSource = null; dgSalesReport.Rows.Clear(); _entities = new KBBQEntities(); dataSales = new List <detailsSettlement>(); dataSales = _entities.detailsSettlements.ToList(); dates = ""; amt = 0; rowId = -1; decimal?advPay = 0; foreach (var item in dataSales) { var date = Convert.ToDateTime(item.paidDate).Date; string dd = date.ToString("yyyy"); if (dd != dates) { dgSalesReport.Rows.Add("0", rowNo, "--", dd); dates = dd; amt = 0; rowId++; } amt += item.bill; dgSalesReport.Rows[rowId].Cells[5].Value = amtFormat.comma(amt); rowNo++; ttlAmt += item.bill; _entities = new KBBQEntities(); var checkForAdvancePay = _entities.tblAdvBookings.Where(x => x.recptNo == item.receiptno).FirstOrDefault(); if (checkForAdvancePay != null) { ttlAmt += checkForAdvancePay.advancePayment; advPay += checkForAdvancePay.advancePayment; dgSalesReport.Rows[rowId].Cells[4].Value = advPay; } lblSalesTotalAmt.Text = amtFormat.comma(ttlAmt).ToString(); } lblSalesRow.Text = modelList.Count.ToString(); #endregion } } catch (Exception x) { } }
private void btnDatSearcsh_Click(object sender, EventArgs e) { DateTime fromdate = DateTime.ParseExact(dtpFromDate.Text, "dd-MM-yyyy", null); DateTime todate = DateTime.ParseExact(dtpToDate.Text, "dd-MM-yyyy", null); if (todate.Date < fromdate.Date) { MessageBox.Show("Invalid Date Entered", "Error - King Bar beque Restaurant", MessageBoxButtons.OK, MessageBoxIcon.Error); dtpToDate.Focus(); return; } List <PurchaseMasterVM> modelList = new List <PurchaseMasterVM>(); List <tbl_PurchaseMaster> data = new List <tbl_PurchaseMaster>(); List <DetailSettlementVM> modelListSales = new List <DetailSettlementVM>(); List <detailsSettlement> dataSales = new List <detailsSettlement>(); #region PurchaseData _entities = new KBBQEntities(); data = _entities.tbl_PurchaseMaster.Where(x => x.date >= fromdate && x.date <= todate).ToList(); int rowNo = 1; foreach (var item in data) { PurchaseMasterVM model = new PurchaseMasterVM(); model.rowNo = rowNo; DateTime dt = Convert.ToDateTime(item.date).Date; model.monthYear = dt.Date.ToString("dd-MM-yyyy"); model.totalAmt = Convert.ToDecimal(amtFormat.comma(item.totalAmt)); model.KOT = item.refNo; rowNo++; modelList.Add(model); ttlAmt += Convert.ToDecimal(item.totalAmt); lblTotalAmt.Text = amtFormat.comma(ttlAmt).ToString(); } dgPurchaseReport.DataSource = modelList; lblTotalRows.Text = modelList.Count.ToString(); #endregion #region Salesregion ttlAmt = 0; rowNo = 1; dataSales = new List <detailsSettlement>(); dataSales = _entities.detailsSettlements.Where(x => x.paidDate >= fromdate && x.paidDate <= todate).ToList(); foreach (var item in dataSales) { DetailSettlementVM model = new DetailSettlementVM(); model.rowNo = rowNo; DateTime dt = Convert.ToDateTime(item.paidDate).Date; model.monthYear = dt.Date.ToString("dd-MM-yyyy"); model.AmountPaid = Convert.ToDecimal(amtFormat.comma(item.bill)); model.KOT = item.receiptno; rowNo++; modelListSales.Add(model); ttlAmt += Convert.ToDecimal(item.bill); lblSalesTotalAmt.Text = amtFormat.comma(ttlAmt).ToString(); } dgSalesReport.DataSource = modelListSales; lblSalesRow.Text = modelList.Count.ToString(); #endregion }
void showReport() { try { ttlAmt = 0; int rowNo = 1; _entities = new KBBQEntities(); List <DetailSettlementVM> modelList = new List <DetailSettlementVM>(); List <tbl_PurchaseMaster> data = new List <tbl_PurchaseMaster>(); if (type == "--All--") { #region PurchaseData data = _entities.tbl_PurchaseMaster.ToList(); foreach (var item in data) { DetailSettlementVM model = new DetailSettlementVM(); model.rowNo = rowNo; DateTime dt = Convert.ToDateTime(item.date).Date; model.monthYear = dt.Date.ToString("dd-MM-yyyy"); model.AmountPaid = Convert.ToDecimal(amtFormat.comma(item.totalAmt)); model.KOT = item.refNo; rowNo++; ttlAmt += Convert.ToDecimal(item.totalAmt); modelList.Add(model); } DetailSettlementVM models = new DetailSettlementVM(); models.totalAmount = Convert.ToDecimal(ttlAmt); modelList.Add(models); ReportDataSource datasource = new ReportDataSource("DataSet1", modelList); this.reportViewer1.LocalReport.DataSources.Clear(); this.reportViewer1.LocalReport.DataSources.Add(datasource); #endregion } else if (type == "Month") { string dates = ""; decimal?amt = 0; int rowId = -1; #region Purchase Data ttlAmt = 0; rowNo = 1; _entities = new KBBQEntities(); data = new List <tbl_PurchaseMaster>(); data = _entities.tbl_PurchaseMaster.ToList(); int dataSaleCount = data.Count(); int count = 0; DetailSettlementVM model = new DetailSettlementVM(); foreach (var item in data) { var date = Convert.ToDateTime(item.date).Date; string dd = date.ToString("MMM"); if (dd != dates) { model = new DetailSettlementVM(); model.rowNo = rowNo; model.monthYear = dd; model.KOT = "--"; //modelListSales.Add(model); //dgSalesReport.Rows.Add("0", rowNo, dd); dates = dd; amt = 0; rowId++; } amt += item.totalAmt; model.AmountPaid = Convert.ToDecimal(amtFormat.comma(amt)); if (dd != dates) { modelList.Add(model); } rowNo++; count++; ttlAmt += item.totalAmt; if (dataSaleCount == count) { modelList.Add(model); } } DetailSettlementVM models = new DetailSettlementVM(); models.totalAmount = Convert.ToDecimal(ttlAmt); modelList.Add(models); ReportDataSource datasource = new ReportDataSource("DataSet1", modelList); this.reportViewer1.LocalReport.DataSources.Clear(); this.reportViewer1.LocalReport.DataSources.Add(datasource); #endregion } else { string dates = ""; decimal?amt = 0; int rowId = -1; #region Purchase Data ttlAmt = 0; rowNo = 1; _entities = new KBBQEntities(); data = new List <tbl_PurchaseMaster>(); data = _entities.tbl_PurchaseMaster.ToList(); int dataSaleCount = data.Count(); int count = 0; DetailSettlementVM model = new DetailSettlementVM(); foreach (var item in data) { var date = Convert.ToDateTime(item.date).Date; string dd = date.ToString("yyyy"); if (dd != dates) { model = new DetailSettlementVM(); model.rowNo = rowNo; model.monthYear = dd; model.KOT = "--"; //modelListSales.Add(model); //dgSalesReport.Rows.Add("0", rowNo, dd); dates = dd; amt = 0; rowId++; } amt += item.totalAmt; model.AmountPaid = Convert.ToDecimal(amtFormat.comma(amt)); if (dd != dates) { modelList.Add(model); } rowNo++; count++; ttlAmt += item.totalAmt; if (dataSaleCount == count) { modelList.Add(model); } } DetailSettlementVM models = new DetailSettlementVM(); models.totalAmount = Convert.ToDecimal(ttlAmt); modelList.Add(models); ReportDataSource datasource = new ReportDataSource("DataSet1", modelList); this.reportViewer1.LocalReport.DataSources.Clear(); this.reportViewer1.LocalReport.DataSources.Add(datasource); #endregion } } catch (Exception x) { } }