public static StockCardReport CreateStockCard(int activityID, int itemID, int unitID, int warehouse, int manufactuererID, DateTime? startDate = null, DateTime? endDate = null)
        {
            BLL.Balance balance = new Balance();

            BLL.Item item = new Item();
            item.LoadByPrimaryKey(itemID);

            ItemUnit iunit = new ItemUnit();
            iunit.LoadByPrimaryKey(unitID);

            BLL.Warehouse physicalStore = new Warehouse();
            physicalStore.LoadByPrimaryKey(warehouse);
            var dataView = new DataView();

            if(startDate == null || endDate == null)
            {
                dataView = Balance.GetStockCardByWarehouse(activityID, itemID, unitID, EthiopianDate.EthiopianDate.Now.FiscalYear,
                                          warehouse, manufactuererID);
            }
            else
            {
                dataView = Balance.GetStockCardByDate(activityID, itemID, unitID, warehouse, manufactuererID,
                                                      startDate.Value, endDate.Value);

            }
            StockCardReport report = new StockCardReport();
            report.DataSource = dataView;

            // Bind the headers here.
            report.StockCode.Text = item.StockCode;
            report.Description.Text = item.FullItemName;
            report.Unit.Text = iunit.Text;

            Activity store = new Activity();
            store.LoadByPrimaryKey(activityID);
            report.Account.Text = store.AccountName;
            report.SubAccount.Text = store.SubAccountName;
            report.Activity.Text = store.Name;

            Manufacturer manufacturers = new Manufacturer();
            manufacturers.LoadByPrimaryKey(manufactuererID);
            report.Manufacturer.Text = manufacturers.Name;
            // TODO: add the Item Source Here (the suggested interpretation is that item source is supplier)
            report.PrintedBy.Text = string.Format("Generated By: {0} On {1}", CurrentContext.LoggedInUserName,
                                                  BLL.DateTimeHelper.ServerDateTime.ToString("dd-MM-yyyy hh:mm tt"));
            report.Store.Text = physicalStore.Name;

            report.AppVersion.Text = "HCMIS";
            return report;
        }
        private void btnRefreshStockCard_Click(object sender, EventArgs e)
        {
            if (dxStockCardValiation.Validate())
            {
                // Bind the stock card.
                 var dataRow = (DataRowView)lkStockArchivePeriod.GetSelectedDataRow();
                StockCardReport report;
                if (chkStockCardArchive.Checked && dataRow != null)
                {
                      report = ReportingReportFactory.CreateStockCard(Convert.ToInt32(lkStockCardActivity.EditValue), ItemID,
                                                                           Convert.ToInt32(lkStockCardUnit.EditValue),
                                                                           Convert.ToInt32(lkStockCardWarehouse.EditValue),
                                                                           Convert.ToInt32(lkStockCardManufacturer.EditValue),
                                                                           Convert.ToDateTime(dataRow["StartDate"]),
                                                                           Convert.ToDateTime(dataRow["EndDate"]));

                }
                else
                {
                    report = ReportingReportFactory.CreateStockCard(Convert.ToInt32(lkStockCardActivity.EditValue), ItemID,
                                                                           Convert.ToInt32(lkStockCardUnit.EditValue),
                                                                           Convert.ToInt32(lkStockCardWarehouse.EditValue), Convert.ToInt32(lkStockCardManufacturer.EditValue));

                }
                 stockCardReport = report;
                printStockCard.PrintingSystem = report.PrintingSystem;
                report.PrintingSystem.ExecCommand(DevExpress.XtraPrinting.PrintingSystemCommand.ZoomToPageWidth, null);
                // Generate the report's print document.
                report.CreateDocument();
            }
        }