Exemplo n.º 1
0
        /// <summary>
        /// Function to fill datagridview
        /// </summary>
        public void PurchaseReturnReportGridFill()
        {
            string strProductCode = string.Empty;

            try
            {
                if (cmbCashOrParty.SelectedValue != null && cmbInvoiceNo.SelectedValue != null && cmbVoucherType.SelectedValue != null)
                {
                    if (cmbCashOrParty.SelectedValue.ToString() != "System.Data.DataRowView" && cmbInvoiceNo.SelectedValue.ToString() != "System.Data.DataRowView" && cmbVoucherType.SelectedValue.ToString() != "System.Data.DataRowView")
                    {
                        if (txtFromDate.Text != string.Empty)
                        {
                            strFrmDate = txtFromDate.Text;
                        }
                        else
                        {
                            strFrmDate = string.Empty;
                        }
                        if (txtToDate.Text != string.Empty)
                        {
                            strToDate = txtToDate.Text;
                        }
                        else
                        {
                            strToDate = string.Empty;
                        }
                        if (cmbCashOrParty.SelectedIndex > -1)
                        {
                            decLedgerID = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
                        }
                        else
                        {
                            decLedgerID = -1;
                        }
                        if (cmbVoucherType.SelectedValue.ToString() != string.Empty || cmbVoucherType.SelectedIndex > -1)
                        {
                            decVoucherTypeId = Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString());
                        }
                        else
                        {
                            decVoucherTypeId = -1;
                        }

                        if (cmbInvoiceNo.SelectedValue.ToString() != string.Empty || cmbInvoiceNo.SelectedIndex > -1)
                        {
                            decInvoice = Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString());
                        }
                        else
                        {
                            decInvoice = -1;
                        }
                        if (txtVoucherNo.Text != string.Empty)
                        {
                            strVoucherNo = txtVoucherNo.Text;
                        }
                        else
                        {
                            strVoucherNo = string.Empty;
                        }
                        if (txtProductCode.Text != string.Empty)
                        {
                            strProductCode = txtProductCode.Text;
                        }
                        else
                        {
                            strProductCode = string.Empty;
                        }
                        dtblReg = spPurchaseReturnMaster.PurchaseReturnReportGridFill(Convert.ToDateTime(strFrmDate), Convert.ToDateTime(strToDate), decLedgerID, decVoucherTypeId, decInvoice, strProductCode, strVoucherNo);
                        dgvPurchaseReturnReport.DataSource = dtblReg;
                        if (dtblReg.Rows.Count > 0)
                        {
                            decimal decTotal = 0;
                            for (int i = 0; i < dtblReg.Rows.Count; i++)
                            {
                                if (dtblReg.Rows[i]["totalAmount"].ToString() != null)
                                {
                                    decTotal = decTotal + Convert.ToDecimal(dtblReg.Rows[i]["totalAmount"].ToString());
                                }
                            }
                            decTotal            = Math.Round(decTotal, 2);
                            txtTotalAmount.Text = decTotal.ToString();
                        }
                        else
                        {
                            txtTotalAmount.Text = "0.00";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PRRT:05" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }