/// <summary> /// /// </summary> /// <param name="sw"></param> /// <param name="entity"></param> public void DateWiseCommodityIssueMemoReport(StreamWriter sw, CommonEntity entity) { try { int count = 8; int i = 1; AddHeader(sw, entity); decimal TotalAmount = 0; foreach (DataRow row in entity.dataSet.Tables[0].Rows) { if (count >= 50) { //Add header again count = 8; sw.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------------------"); sw.WriteLine((char)12); AddHeader(sw, entity); } sw.Write(report.StringFormatWithoutPipe(row["GodownName"].ToString(), 25, 2)); sw.Write(report.StringFormatWithoutPipe(row["Coop"].ToString(), 33, 2)); sw.Write(report.StringFormatWithoutPipe(row["Dono"].ToString(), 10, 2)); sw.Write(report.StringFormatWithoutPipe(report.FormatDirectDate(row["Dodate"].ToString()), 10, 2)); sw.Write(report.StringFormatWithoutPipe(row["Comodity"].ToString(), 26, 2)); sw.Write(report.StringFormatWithoutPipe(row["Scheme"].ToString(), 12, 2)); sw.Write(report.StringFormatWithoutPipe(report.DecimalformatForWeight(row["Quantity"].ToString()), 12, 1) + " "); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(row["Rate"].ToString()), 6, 1) + " "); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(row["Amount"].ToString()), 10, 1)); sw.WriteLine(""); TotalAmount += Convert.ToDecimal(report.Decimalformat(row["Amount"].ToString())); i = i + 1; count = count + 1; } sw.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------------------"); sw.Write(report.StringFormatWithoutPipe(" ", 33, 2)); sw.Write(report.StringFormatWithoutPipe(" ", 35, 2)); sw.Write(report.StringFormatWithoutPipe(" ", 10, 2)); sw.Write(report.StringFormatWithoutPipe(" ", 26, 2)); sw.Write(report.StringFormatWithoutPipe(" ", 12, 2)); sw.Write(report.StringFormatWithoutPipe(" ", 12, 1) + " "); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(TotalAmount.ToString()), 18, 1)); sw.WriteLine(""); sw.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------------------"); sw.WriteLine((char)12); } catch (Exception ex) { AuditLog.WriteError(ex.Message); } }
/// <summary> /// Write text file for item wise abstract data /// </summary> /// <param name="sw">Text Streamwriter</param> /// <param name="hullingReportList">DOReg entity</param> /// <param name="entity">Common Entity</param> public void HullingDetailsAbstract(StreamWriter sw, List <HullingReportEntity> hullingReportList, CommonEntity entity) { try { int iCount = 11; var myResultItem = from a in hullingReportList group a by new { a.ITDescription, a.DepositorName } into gValue select new { Nkgs = gValue.Sum(s => s.Nkgs), NoPacking = gValue.Sum(s => s.NoPacking), GroupByNames = gValue.Key }; double dAmount = 0; AddHeaderforAbstractDetails(sw, entity); foreach (var item in myResultItem) { if (iCount >= 50) { iCount = 11; sw.WriteLine("----------------------------------------------------------------------------------------------------------------------|"); sw.WriteLine((char)12); AddHeaderforAbstractDetails(sw, entity); } sw.Write(report.StringFormat(item.GroupByNames.DepositorName, 37, 2)); sw.Write(report.StringFormat(item.GroupByNames.ITDescription, 26, 2)); sw.Write(report.StringFormat(report.Decimalformat(item.NoPacking.ToString()), 12, 1)); sw.Write(report.StringFormat(report.Decimalformat(item.Nkgs.ToString()), 27, 1)); // sw.Write(report.StringFormat(report.Decimalformat(item.Itemamount.ToString()), 20, 1)); dAmount = dAmount + item.Nkgs; iCount++; sw.WriteLine(""); sw.WriteLine(""); } // Add toal values sw.WriteLine("---------------------------------------------------------------------------------------------------------|"); sw.Write(report.StringFormat("Total Amount", 64, 1)); sw.Write(report.StringFormat(report.Decimalformat(dAmount.ToString()), 40, 1)); sw.WriteLine(""); sw.WriteLine("---------------------------------------------------------------------------------------------------------|"); sw.WriteLine((char)12); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " : " + ex.StackTrace); } }
/// <summary> /// /// </summary> /// <param name="sw"></param> /// <param name="entity"></param> public void DateWiseCommodityIssueMemoReport(StreamWriter sw, CommonEntity entity) { try { int count = 10; int i = 1; AddHeader(sw, entity); decimal TotalAmount = 0; foreach (DataRow row in entity.dataSet.Tables[0].Rows) { if (count >= 50) { //Add header again count = 11; sw.WriteLine("-----------------------------------------------------------------------------------------------------------------------------------------------------"); sw.WriteLine((char)12); AddHeader(sw, entity); } sw.Write(" "); sw.Write(report.StringFormatWithoutPipe(i.ToString(), 4, 2)); sw.Write(report.StringFormatWithoutPipe(row["ReceivedFrom"].ToString(), 40, 2)); sw.Write(report.StringFormatWithoutPipe(row["ReceiptNo"].ToString(), 11, 2)); sw.Write(report.StringFormatWithoutPipe(report.FormatDirectDate(row["Date"].ToString()), 10, 2)); sw.Write(report.StringFormatWithoutPipe(row["PaymentType"].ToString(), 3, 2)); sw.Write(report.StringFormatWithoutPipe(row["DDNo"].ToString(), 15, 2)); sw.Write(report.StringFormatWithoutPipe(row["DDDate"].ToString(), 10, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(row["Amount"].ToString()), 15, 1)); sw.Write(report.StringFormatWithoutPipe(row["Bank"].ToString(), 32, 2)); sw.WriteLine(""); TotalAmount += Convert.ToDecimal(report.Decimalformat(row["Amount"].ToString())); i = i + 1; count = count + 1; } sw.WriteLine("-----------------------------------------------------------------------------------------------------------------------------------------------------"); sw.Write(" TOTAL AMOUNT "); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(TotalAmount.ToString()), 15, 1)); sw.WriteLine(""); sw.WriteLine("-----------------------------------------------------------------------------------------------------------------------------------------------------"); sw.WriteLine((char)12); } catch (Exception ex) { AuditLog.WriteError(ex.Message); } }
/// <summary> /// /// </summary> /// <param name="sw"></param> /// <param name="entity"></param> public void DateWiseCommodityIssueMemoReport(StreamWriter sw, CommonEntity entity, DataTable ndt) { try { int count = 8; // var dateList = entity.dataSet.Tables[0].DefaultView.ToTable(true, "Issue_Date"); int pageNo = 1; decimal Payment = 0; decimal Ceral = 0; decimal NonCeral = 0; AddHeader(sw, entity, pageNo); foreach (DataRow row in ndt.Rows) { if (count >= 50) { //Add header again pageNo++; count = 8; sw.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------------------------"); sw.WriteLine((char)12); AddHeader(sw, entity, pageNo); } sw.Write(" "); sw.Write(report.StringFormatWithoutPipe(row["GodownName"].ToString(), 24, 2)); sw.Write(report.StringFormatWithoutPipe(row["Society"].ToString(), 34, 2)); sw.Write(report.StringFormatWithoutPipe(row["Dono"].ToString(), 10, 2)); sw.Write(report.StringFormatWithoutPipe(row["Dodate"].ToString(), 10, 2) + " "); sw.Write(report.StringFormatWithoutPipe(row["Chequeno"].ToString(), 10, 2)); sw.Write(report.StringFormatWithoutPipe(row["Chequedate"].ToString(), 10, 2)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(row["PaymentAmount"].ToString()), 12, 1) + " "); sw.Write(report.StringFormatWithoutPipe(row["Bank"].ToString(), 14, 2)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(row["Cereal"].ToString()), 12, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(row["NonCereal"].ToString()), 12, 1)); sw.WriteLine(""); count = count + 1; Payment += !string.IsNullOrEmpty(row["PaymentAmount"].ToString()) ? Convert.ToDecimal(row["PaymentAmount"]) : 0; Ceral += !string.IsNullOrEmpty(row["Cereal"].ToString()) ? Convert.ToDecimal(row["Cereal"]) : 0; NonCeral += !string.IsNullOrEmpty(row["NonCereal"].ToString()) ? Convert.ToDecimal(row["NonCereal"]) : 0; } sw.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------------------------"); sw.Write(report.StringFormatWithoutPipe(" ", 25, 2)); sw.Write(report.StringFormatWithoutPipe(" ", 34, 2)); sw.Write(report.StringFormatWithoutPipe(" ", 10, 2)); sw.Write(report.StringFormatWithoutPipe(" ", 10, 2) + " "); sw.Write(report.StringFormatWithoutPipe(" ", 10, 2)); sw.Write(report.StringFormatWithoutPipe("Total", 10, 2)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(Convert.ToString(Payment)), 12, 1) + " "); sw.Write(report.StringFormatWithoutPipe("", 14, 2)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(Convert.ToString(Ceral)), 12, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(Convert.ToString(NonCeral)), 12, 1)); sw.WriteLine(""); sw.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------------------------"); sw.WriteLine((char)12); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " " + ex.StackTrace); } }
/// <summary> /// Write text file for Date wise record. /// </summary> /// <param name="sw">Text Streamwriter</param> /// <param name="entity">Common Entity</param> public void WriteDORegForDateWise(StreamWriter sw, CommonEntity entity) { int iCount = 10; var distinctDate = entity.dataTable.DefaultView.ToTable(true, "DeliveryOrderDate"); //Date wise DO report int i = 1; string sIssuer = string.Empty; bool CheckRepeatValue = false; string sDoNo = string.Empty; foreach (DataRow dateValue in distinctDate.Rows) { iCount = 11; string sDoNo1 = string.Empty; DataRow[] datas = entity.dataTable.Select("DeliveryOrderDate='" + dateValue["DeliveryOrderDate"] + "'"); AddHeader(sw, Convert.ToString(dateValue["DeliveryOrderDate"])); foreach (DataRow dr in datas) { if (iCount >= 50) { //Add header again iCount = 11; sw.WriteLine("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|"); sw.WriteLine((char)12); AddHeader(sw, Convert.ToString(dateValue["DeliveryOrderDate"])); } sDoNo1 = dr["Dono"].ToString(); if (sDoNo == sDoNo1) { CheckRepeatValue = true; } else { CheckRepeatValue = false; sDoNo = sDoNo1; } sIssuer = Convert.ToString(dr["To_Whom_Issued"]).Trim(); sw.Write(report.StringFormat(CheckRepeatValue == false ? i.ToString() : " ", 4, 2)); sw.Write(report.StringFormat(CheckRepeatValue == false ? sDoNo1 : " ", 11, 1)); sw.Write(report.StringFormat(CheckRepeatValue == false ? report.Decimalformat(Convert.ToString(dr["Totals"])) : "-", 17, 1)); sw.Write(report.StringFormat(CheckRepeatValue == false ? sIssuer : " ", 15, 2)); sw.Write(report.StringFormat(dr["Cheque_DD"].ToString(), 11, 2)); sw.Write(report.StringFormat(report.Decimalformat(dr["PaymentAmount"].ToString()), 15, 1)); sw.Write(report.StringFormat(dr["Scheme"].ToString(), 13, 2)); sw.Write(report.StringFormat(dr["Commodity"].ToString(), 14, 2)); sw.Write(report.StringFormat(report.DecimalformatForWeight(dr["Netwt_Kgs"].ToString()), 11, 1)); sw.Write(report.StringFormat(report.Decimalformat(dr["Rate_Rs"].ToString()), 14, 1)); sw.Write(report.StringFormat(report.Decimalformat(dr["Itemamount"].ToString()), 15, 1)); sw.Write(report.StringFormat(report.Decimalformat(dr["PreviousAmount"].ToString()), 15, 1)); sw.Write(report.StringFormat(report.Decimalformat(dr["Adjusted"].ToString()), 13, 1)); sw.Write(report.StringFormat(report.Decimalformat(dr["Balance"].ToString()), 14, 1)); sw.Write(report.StringFormat(report.Decimalformat(dr["MarginAmount"].ToString()), 12, 1)); sw.WriteLine(""); int addedLines = 0; if (!CheckRepeatValue) { addedLines = report.AddMoreContent(sw, sIssuer, 15, 35); } sw.WriteLine(" | | | | | | | | | | | | | | |"); iCount = iCount + 2 + addedLines; i = CheckRepeatValue == false ? i + 1 : i; } sw.WriteLine("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|"); sw.WriteLine((char)12); } }
/// <summary> /// Add receipt item details /// </summary> /// <param name="streamWriter"></param> /// <param name="stockReceipt"></param> public void AddPaymentDetails(StreamWriter streamWriter, DocumentDeliveryOrderEntity deliveryOrderList) { double dTotal = 0, dTotalADJ = 0; int i = 0; foreach (var item in deliveryOrderList.deliveryPaymentDetails) { if (i == 0) { streamWriter.WriteLine("|PAYMENT DETAILS |"); streamWriter.WriteLine("| |"); streamWriter.WriteLine("||------------------------------------------------------| |"); streamWriter.WriteLine("||CHQ/DD NO | DATE | BANK NAME | AMOUNT | |"); streamWriter.WriteLine("||------------------------------------------------------| |"); } i = 1; streamWriter.Write("||"); streamWriter.Write(manageReport.StringFormat(item.ChequeNo, 10, 2)); streamWriter.Write(manageReport.StringFormat(manageReport.FormatIndianDate(item.ChDate), 10, 2)); streamWriter.Write(manageReport.StringFormat(item.bank, 20, 2)); streamWriter.Write(manageReport.StringFormat(item.PaymentAmount.ToString(), 11, 2)); streamWriter.Write(" |"); streamWriter.WriteLine(" "); dTotal = dTotal + Convert.ToDouble(item.PaymentAmount); } if (i == 1) { streamWriter.WriteLine("||------------------------------------------------------| |"); streamWriter.Write("|| TOTAL |"); streamWriter.Write(manageReport.StringFormat(dTotal.ToString(), 11, 2)); streamWriter.Write(" |"); streamWriter.WriteLine(" "); streamWriter.WriteLine("||------------------------------------------------------| |"); } streamWriter.WriteLine("| |"); int j = 0; foreach (var item in deliveryOrderList.deliveryAdjustmentDetails) { if (j == 0) { streamWriter.WriteLine("|ADJUSTMENT |"); streamWriter.WriteLine("| |"); streamWriter.WriteLine("||--------------------------------------------------------------------------------------| |"); streamWriter.WriteLine("|| PREVIOUS | PREVIOUS | BY ADJUSTMENT | Pre.AMT.BAL | OTHER.AMT. | BALANCE** | |"); streamWriter.WriteLine("|| D.O.BO. | D.O.DT. | | Cr./Dr. | ADJ. | | |"); streamWriter.WriteLine("||--------------------------------------------------------------------------------------| |"); } j = 1; streamWriter.Write("||"); streamWriter.Write(manageReport.StringFormat(item.AdjustedDoNo, 11, 2)); streamWriter.Write(manageReport.StringFormat(manageReport.FormatIndianDate(item.AdjustDate), 11, 2)); streamWriter.Write(manageReport.StringFormat(item.AdjustmentType, 13, 2)); streamWriter.Write(manageReport.StringFormat(manageReport.Decimalformat(item.Amount.ToString()), 15, 1)); streamWriter.Write(manageReport.StringFormat(manageReport.Decimalformat(item.AmountNowAdjusted.ToString()), 15, 1)); streamWriter.Write(manageReport.StringFormat(manageReport.Decimalformat(item.Balance.ToString()), 16, 1)); streamWriter.Write(" |"); streamWriter.WriteLine(" "); dTotalADJ = dTotalADJ + Convert.ToDouble(item.Balance); } if (j == 1) { streamWriter.WriteLine("||--------------------------------------------------------------------------------------| |"); streamWriter.Write("|| TOTAL |"); streamWriter.Write(manageReport.StringFormat(manageReport.Decimalformat(dTotalADJ.ToString()), 16, 1)); streamWriter.Write(" |"); streamWriter.WriteLine(" "); streamWriter.WriteLine("||--------------------------------------------------------------------------------------| |"); } streamWriter.WriteLine("|==========================================================================================================|"); }
/// <summary> /// /// </summary> /// <param name="sw"></param> /// <param name="entity"></param> public void SocietyWiseDOAllSchemeReport(StreamWriter sw, CommonEntity entity) { int count = 10; int i = 1; string doNo = string.Empty; string fromWhomRcd = string.Empty; bool isDataAvailable = false; decimal Qty = 0; decimal Rate = 0; decimal C_Amount = 0; decimal NC_Amount = 0; decimal Toatal_C_Amount = 0; decimal Total_NC_Amount = 0; decimal Amount = 0; decimal GrandTotal_C = 0; decimal GrandTotal_NC = 0; decimal GrandTotal = 0; count = 11; try { // dateList = entity.dataSet.Tables[0].DefaultView.ToTable(true, new string[] { "Coop", "Comodity" }); var dateList = entity.dataSet.Tables[0].DefaultView.ToTable(true, "Coop"); foreach (DataRow date in dateList.Rows) { Qty = 0; Rate = 0; C_Amount = 0; NC_Amount = 0; Amount = 0; Toatal_C_Amount = 0; Total_NC_Amount = 0; GrandTotal_C = 0; GrandTotal_NC = 0; GrandTotal = 0; isDataAvailable = true; string doNoNext = string.Empty; string coop = string.Empty; AddHeader(sw, entity); coop = Convert.ToString(date["Coop"]); DataRow[] data = entity.dataSet.Tables[0].Select("Coop='" + coop + "'"); var distinctCommodity = report.ConvertDataRowToTable(data, entity.dataSet.Tables[0]).DefaultView.ToTable(true, "Comodity"); sw.WriteLine(report.StringFormatWithoutPipe(coop, 50, 2)); foreach (DataRow item in distinctCommodity.Rows) { Qty = 0; Rate = 0; C_Amount = 0; NC_Amount = 0; Amount = 0; Toatal_C_Amount = 0; Total_NC_Amount = 0; DataRow[] ndata = entity.dataSet.Tables[0].Select("Coop='" + coop + "' and Comodity='" + Convert.ToString(item["Comodity"]) + "'"); foreach (DataRow row in ndata) { C_Amount = 0; NC_Amount = 0; if (count >= 50) { //Add header again count = 11; sw.WriteLine("---------------------------------------------------------------------------------------------------------------------------------"); sw.WriteLine((char)12); AddHeader(sw, entity); } doNoNext = row["Dono"].ToString(); C_Amount = (row["C_Nc"].ToString() == "C") ? Convert.ToDecimal(row["Amount"]) : 0; NC_Amount = (row["C_Nc"].ToString() == "NC") ? Convert.ToDecimal(row["Amount"]) : 0; sw.Write(report.StringFormatWithoutPipe(row["GodownName"].ToString(), 25, 2)); sw.Write(report.StringFormatWithoutPipe(doNoNext, 11, 1)); sw.Write(report.StringFormatWithoutPipe(report.FormatDirectDate(row["Dodate"].ToString()), 10, 2)); sw.Write(report.StringFormatWithoutPipe(row["Comodity"].ToString(), 15, 2)); sw.Write(report.StringFormatWithoutPipe(row["Scheme"].ToString(), 11, 2)); sw.Write(report.StringFormatWithoutPipe(report.DecimalformatForWeight(row["Quantity"].ToString()), 11, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(row["Rate"].ToString()), 10, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(Convert.ToString(C_Amount)), 11, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(Convert.ToString(NC_Amount)), 11, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(row["Amount"].ToString()), 11, 1)); sw.WriteLine(""); Rate += !string.IsNullOrEmpty(Convert.ToString(row["Rate"])) ? Convert.ToDecimal(row["Rate"].ToString()) : 0; Toatal_C_Amount += !string.IsNullOrEmpty(Convert.ToString(C_Amount)) ? C_Amount : 0; Total_NC_Amount += !string.IsNullOrEmpty(Convert.ToString(NC_Amount)) ? NC_Amount : 0; Amount += !string.IsNullOrEmpty(Convert.ToString(row["Amount"])) ? Convert.ToDecimal(row["Amount"].ToString()) : 0; Qty += !string.IsNullOrEmpty(Convert.ToString(row["Quantity"])) ? Convert.ToDecimal(row["Quantity"].ToString()) : 0; i = i + 1; count++; } sw.WriteLine("---------------------------------------------------------------------------------------------------------------------------------"); sw.Write(report.StringFormatWithoutPipe("", 36, 2)); sw.Write(report.StringFormatWithoutPipe("", 10, 2)); sw.Write(report.StringFormatWithoutPipe("", 15, 2)); sw.Write(report.StringFormatWithoutPipe(" Total ", 11, 1)); sw.Write(report.StringFormatWithoutPipe(Qty.ToString(), 11, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(Rate.ToString()), 10, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(Toatal_C_Amount.ToString()), 11, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(Total_NC_Amount.ToString()), 11, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(Amount.ToString()), 11, 1)); GrandTotal_C += Toatal_C_Amount; GrandTotal_NC += Total_NC_Amount; GrandTotal += Amount; sw.WriteLine(""); sw.WriteLine("---------------------------------------------------------------------------------------------------------------------------------"); } sw.WriteLine("---------------------------------------------------------------------------------------------------------------------------------"); sw.Write(report.StringFormatWithoutPipe("", 36, 2)); sw.Write(report.StringFormatWithoutPipe("", 10, 2)); sw.Write(report.StringFormatWithoutPipe("", 15, 2)); sw.Write(report.StringFormatWithoutPipe(" Demand ", 11, 1)); sw.Write(report.StringFormatWithoutPipe(" ", 11, 1)); sw.Write(report.StringFormatWithoutPipe(" ", 10, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(GrandTotal_C.ToString()), 11, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(GrandTotal_NC.ToString()), 11, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(GrandTotal.ToString()), 11, 1)); sw.WriteLine(""); sw.WriteLine("---------------------------------------------------------------------------------------------------------------------------------"); //Check Collections sw.WriteLine((char)12); } if (!isDataAvailable) { sw.WriteLine("---------------------------------------------------------------------------------------------------------------"); sw.WriteLine((char)12); } } catch (Exception ex) { AuditLog.WriteError(ex.Message); } }
/// <summary> /// /// </summary> /// <param name="sw"></param> /// <param name="entity"></param> public void SocietyWiseDOAllSchemeReport(StreamWriter sw, CommonEntity entity) { int count = 8; int i = 1; string doNo = string.Empty; string fromWhomRcd = string.Empty; bool isDataAvailable = false; decimal Due = 0; decimal Paid = 0; decimal AdvanceCollection = 0; decimal Debit = 0; decimal GrandTotal_Due = 0; decimal GrandTotal_Paid = 0; decimal GrandTotal_ADV = 0; decimal GrandTotal_Debit = 0; try { // dateList = entity.dataSet.Tables[0].DefaultView.ToTable(true, new string[] { "Coop", "Comodity" }); var dateList = entity.dataSet.Tables[0].DefaultView.ToTable(true, "issuername"); AddHeader(sw, entity); foreach (DataRow date in dateList.Rows) { Due = 0; Paid = 0; AdvanceCollection = 0; Debit = 0; isDataAvailable = true; string doNoNext = string.Empty; string coop = string.Empty; coop = Convert.ToString(date["issuername"]); DataRow[] data = entity.dataSet.Tables[0].Select("issuername='" + coop + "'"); i = 1; foreach (DataRow row in data) { if (count >= 50) { //Add header again count = 8; sw.WriteLine("----------------------------------------------------------------------------------------------------------------------------------"); sw.WriteLine((char)12); AddHeader(sw, entity); } sw.Write(report.StringFormatWithoutPipe(row["GodownName"].ToString(), 25, 2)); sw.Write(report.StringFormatWithoutPipe(row["Dono"].ToString(), 10, 2)); sw.Write(report.StringFormatWithoutPipe(i == 1 ? row["issuername"].ToString() : " ", 30, 2)); sw.Write(report.StringFormatWithoutPipe(report.FormatDirectDate(row["DoDate"].ToString()), 10, 2)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(row["Due"].ToString()), 13, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(row["Paid"].ToString()), 12, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(row["AdvanceCollection"].ToString()), 13, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(row["Debit"].ToString()), 12, 1)); sw.WriteLine(""); Due += !string.IsNullOrEmpty(Convert.ToString(row["Due"])) ? Convert.ToDecimal(row["Due"].ToString()) : 0; Paid += !string.IsNullOrEmpty(Convert.ToString(row["Paid"])) ? Convert.ToDecimal(row["Paid"].ToString()) : 0; AdvanceCollection += !string.IsNullOrEmpty(Convert.ToString(row["AdvanceCollection"])) ? Convert.ToDecimal(row["AdvanceCollection"].ToString()) : 0; Debit += !string.IsNullOrEmpty(Convert.ToString(row["Debit"])) ? Convert.ToDecimal(row["Debit"].ToString()) : 0; i = 2; count++; } sw.WriteLine("----------------------------------------------------------------------------------------------------------------------------------"); sw.Write(report.StringFormatWithoutPipe(" ", 35, 2)); sw.Write(report.StringFormatWithoutPipe(" ", 30, 2)); sw.Write(report.StringFormatWithoutPipe("Total", 10, 2)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(Due.ToString()), 13, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(Paid.ToString()), 12, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(AdvanceCollection.ToString()), 13, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(Debit.ToString()), 12, 1)); sw.WriteLine(""); GrandTotal_Due += Due; GrandTotal_Paid += Paid; GrandTotal_ADV += AdvanceCollection; GrandTotal_Debit += Debit; sw.WriteLine("----------------------------------------------------------------------------------------------------------------------------------"); } sw.WriteLine("----------------------------------------------------------------------------------------------------------------------------------"); sw.Write(report.StringFormatWithoutPipe(" ", 35, 2)); sw.Write(report.StringFormatWithoutPipe(" ", 20, 2)); sw.Write(report.StringFormatWithoutPipe("Grand Total", 20, 2)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(GrandTotal_Due.ToString()), 13, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(GrandTotal_Paid.ToString()), 12, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(GrandTotal_ADV.ToString()), 13, 1)); sw.Write(report.StringFormatWithoutPipe(report.Decimalformat(GrandTotal_Debit.ToString()), 12, 1)); sw.WriteLine(""); sw.WriteLine("----------------------------------------------------------------------------------------------------------------------------------"); //Check Collections sw.WriteLine((char)12); if (!isDataAvailable) { sw.WriteLine("----------------------------------------------------------------------------------------------------------------------------------"); sw.WriteLine((char)12); } } catch (Exception ex) { AuditLog.WriteError(ex.Message); } }