/// <summary> /// Function to fill gridview /// </summary> public void GridFill() { try { PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll(); if (txtVoucherNo.Text.Trim() == string.Empty) { strInvoiceNo = "-1"; } else { strInvoiceNo = txtVoucherNo.Text; } if (cmbCashOrParty.SelectedIndex == 0 || cmbCashOrParty.SelectedIndex == -1) { decLedgerId = -1; } else { decLedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); } if (cmbVoucherType.SelectedIndex == 0 || cmbVoucherType.SelectedIndex == -1) { decVoucherTypeId = -1; } else { decVoucherTypeId = Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString()); } if (cmbStatus.SelectedIndex == 0 || cmbStatus.SelectedIndex == -1) { strStatus = "All"; } else { strStatus = cmbStatus.SelectedItem.ToString(); } DateTime FromDate = this.dtpFromDate.Value; DateTime ToDate = this.dtpToDate.Value; ListObjPurchaseOrderRegister = BllPurchaseOrder.PurchaseOrdeReportViewAll(strInvoiceNo, decLedgerId, decVoucherTypeId, FromDate, ToDate, strStatus); if (ListObjPurchaseOrderRegister[0].Rows.Count > 0) { decimal decTotal = 0; for (int i = 0; i < ListObjPurchaseOrderRegister[0].Rows.Count; i++) { if (ListObjPurchaseOrderRegister[0].Rows[i]["totalAmount"].ToString() != null) { decTotal = decTotal + Convert.ToDecimal(ListObjPurchaseOrderRegister[0].Rows[i]["totalAmount"].ToString()); } } decTotal = Math.Round(decTotal, 2); txtTotalAmount.Text = decTotal.ToString(); } else { txtTotalAmount.Text = "0.00"; } dgvPurchaseOrderReport.DataSource = ListObjPurchaseOrderRegister[0]; if (dgvPurchaseOrderReport.Columns.Count > 0) { dgvPurchaseOrderReport.Columns["dgvtxtTotalAmount"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } } catch (Exception ex) { MessageBox.Show("PORP:4" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }