public static Reports.BinCardReport CreateBinCard(int activityID, int itemID, int unitID, int warehouse,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);

            Activity activity = new Activity();
            activity.LoadByPrimaryKey(activityID);
            var dataView = new DataView();
            if (startDate == null || endDate == null)
            {
                dataView = Balance.GetBinCardByWarehouse(activityID, itemID, unitID, EthiopianDate.EthiopianDate.Now.FiscalYear,
                                          warehouse);
            }
            else
            {
                dataView = Balance.GetBinCardByDate(activityID, itemID, unitID, warehouse,startDate.Value,endDate.Value);
            }
            BinCardReport report = new BinCardReport();
            report.DataSource = dataView;

            report.StockCode.Text = item.StockCode;
            report.Description.Text = item.FullItemName;
            report.Unit.Text = iunit.Text;

            report.ItemSource.Text = activity.FullActivityName;

            // 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.AppVersion.Text = "HCMIS";
            return report;
        }
        private void lkBinCardWarehouse_EditValueChanged(object sender, EventArgs e)
        {
            if(_UnitID.HasValue && lkBinCardWarehouse.EditValue != null)
            {
                BinCardReport report = ReportingReportFactory.CreateBinCard(_StoreID, _ItemID, _UnitID.Value,
                                                                            Convert.ToInt32(lkBinCardWarehouse.EditValue));
                printBinCard.PrintingSystem = report.PrintingSystem;

                report.PrintingSystem.ExecCommand(DevExpress.XtraPrinting.PrintingSystemCommand.ZoomToPageWidth, null);
                binCardReport = report;
                // Generate the report's print document.
                report.CreateDocument();
            }
        }
        private void btnRefreshBinCard_Click(object sender, EventArgs e)
        {
            if (dxBinCardValidation.Validate())
            {
                // Do bind the bin card
                //int WarehouseID = lkBinCardWarehouse.
                 var dataRow = (DataRowView)lkBinArchivePeriod.GetSelectedDataRow();
                BinCardReport report;
                if (ckBinCardArchive.Checked && dataRow != null)
                 {

                     // Do bind the bin card
                     //int WarehouseID = lkBinCardWarehouse.
                      report =
                         ReportingReportFactory.CreateBinCard(Convert.ToInt32(lkBinCardActivity.EditValue), ItemID,
                                                              Convert.ToInt32(lkBinCardUnit.EditValue),
                                                              Convert.ToInt32(lkBinCardWarehouse.EditValue),
                                                              Convert.ToDateTime(dataRow["StartDate"]),
                                                              Convert.ToDateTime(dataRow["EndDate"]));

                 }
                 else
                 {
                     report = ReportingReportFactory.CreateBinCard(Convert.ToInt32(lkBinCardActivity.EditValue), ItemID,
                                                                                                Convert.ToInt32(lkBinCardUnit.EditValue),
                                                                                                Convert.ToInt32(lkBinCardWarehouse.EditValue));

                 }
                    printBinCard.PrintingSystem = report.PrintingSystem;

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