private void btnPreview_Click(object sender, EventArgs e)
 {
     if (!GlobalFunctions.checkRights("tsmSalesReport", "Preview"))
     {
         return;
     }
     try
     {
         loStockCardRpt.SetDataSource(GlobalVariables.DTCompanyLogo);
         loStockCardRpt.Database.Tables[1].SetDataSource(ldtReports);
         loStockCardRpt.SetParameterValue("CompanyName", GlobalVariables.CompanyName);
         loStockCardRpt.SetParameterValue("CompanyAddress", GlobalVariables.CompanyAddress);
         loStockCardRpt.SetParameterValue("CompanyContactNumber", GlobalVariables.ContactNumber);
         loStockCardRpt.SetParameterValue("Username", GlobalVariables.Userfullname);
         loStockCardRpt.SetParameterValue("Title", "Stock Card");
         loStockCardRpt.SetParameterValue("SubTitle", "Stock Card");
         loStockCardRpt.SetParameterValue("ItemDescription", dgvStockList.CurrentRow.Cells[1].Value.ToString());
         loStockCardRpt.SetParameterValue("Unit", dgvStockList.CurrentRow.Cells[4].Value.ToString());
         loStockCardRpt.SetParameterValue("QtyOnHand",string.Format("{0:n}", decimal.Parse(dgvStockList.CurrentRow.Cells[5].Value.ToString())));
         loReportViewer.crystalReportViewer.ReportSource = loStockCardRpt;
         loReportViewer.ShowDialog();
     }
     catch { }
 }
Esempio n. 2
0
        private void btnPreview_Click(object sender, EventArgs e)
        {
            try
            {
                if (!GlobalFunctions.checkRights("tsmStockCard", "Preview"))
                {
                    return;
                }

                decimal _qtyTotalIn  = 0;
                decimal _qtyTotalOut = 0;
                decimal _qtyBegBal   = 0;

                foreach (DataRow _dr in loStock.getStockCardBegBal(dtpFromDate.Value, dgvStockList.CurrentRow.Cells[0].Value.ToString(), cboLocation.SelectedValue.ToString()).Rows)
                {
                    _qtyTotalIn  += decimal.Parse(_dr[0].ToString());
                    _qtyTotalOut += decimal.Parse(_dr[1].ToString());
                    _qtyBegBal   += decimal.Parse(_dr[2].ToString());
                }

                loStockCardRpt.SetDataSource(GlobalVariables.DTCompanyLogo);
                loStockCardRpt.Database.Tables[1].SetDataSource(ldtList);
                loStockCardRpt.SetParameterValue("CompanyName", GlobalVariables.CompanyName);
                loStockCardRpt.SetParameterValue("CompanyAddress", GlobalVariables.CompanyAddress);
                loStockCardRpt.SetParameterValue("CompanyContactNumber", GlobalVariables.ContactNumber);
                loStockCardRpt.SetParameterValue("Username", GlobalVariables.Userfullname);
                loStockCardRpt.SetParameterValue("Title", "Stock Card");
                loStockCardRpt.SetParameterValue("SubTitle", "Stock Card");
                loStockCardRpt.SetParameterValue("DateFrom", string.Format("{0:MM-dd-yyyy}", dtpFromDate.Value));
                loStockCardRpt.SetParameterValue("DateTo", string.Format("{0:MM-dd-yyyy}", dtpToDate.Value));
                loStockCardRpt.SetParameterValue("Stock", dgvStockList.CurrentRow.Cells[1].Value.ToString());
                loStockCardRpt.SetParameterValue("Location", cboLocation.Text);
                loStockCardRpt.SetParameterValue("QtyTotalIn", string.Format("{0:n}", _qtyTotalIn));
                loStockCardRpt.SetParameterValue("QtyTotalOut", string.Format("{0:n}", _qtyTotalOut));
                loStockCardRpt.SetParameterValue("QtyBegBal", string.Format("{0:n}", _qtyBegBal));
                loReportViewer.crystalReportViewer.ReportSource = loStockCardRpt;
                loReportViewer.ShowDialog();
            }
            catch (Exception ex)
            {
                ErrorMessageUI em = new ErrorMessageUI(ex.Message, this.Name, "btnPreview_Click");
                em.ShowDialog();
                return;
            }
        }