/// <summary>
        /// Load All Neccessary Data and Bind To DataSource
        /// </summary>
        void LoadAndBind()
        {
            //Bind

            //Load Detail Table To Grid
            Item item = new Item();

            gridReceiveDoc.DataSource = item.GetReceiveDocDetailForDiagnostics(ItemId, ManufacturerId, UnitId,
                                                                               MovingAverageId);

            gridJournalEntries.DataSource = item.GetJournalEntriesForDiagnostics(AffectedLedgerID);

            MovingAverageHistory history     = new MovingAverageHistory();
            CostElement          costElement = new CostElement(ItemId, MovingAverageId, ManufacturerId, UnitId, ManufacturerId);

            gridAllSimilarItems.DataSource = history.GetHistory(costElement);

            //Load Header Information From first row to be displayed

            txtItemName.EditValue         = Item;
            txtItemUnit.EditValue         = Unit;
            txtManufacturerName.EditValue = Manufacturer;
            txtActivityName.EditValue     = MovingAverage;
            txtUnitCost.EditValue         = UnitCost;
            txtMargin.EditValue           = Margin;
            txtSellingPrice.EditValue     = SellingPrice;
        }
        private int SaveRRF()
        {
            RRF rrf = new RRF();

            if (rrf.RRFExists(_storeID, _fromYear, _fromMonth, _toYear, _toMonth))
            {
                if (XtraMessageBox.Show("RRF Exists on disk, are you sure you want to replace it?", "RRF Save",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return(-1);
                }
            }
            int rrfID = rrf.AddNewRRF(_storeID, _fromYear, _fromMonth, _toYear, _toMonth, true);

            BLL.Item  itm   = new BLL.Item();
            DataTable dtbl1 = new DataTable();

            if (gridItemChoiceView.DataSource != null)
            {
                dtbl1 = ((DataView)gridItemChoiceView.DataSource).Table;
            }
            foreach (DataRow dr in dtbl1.Rows)
            {
                int       itemID       = Convert.ToInt32(dr["ID"]);
                int       requestedqty = Convert.ToInt32(dr["Quantity"]);
                int       storeID      = int.Parse(cboStores.EditValue.ToString());
                RRFDetail rrfDetail    = new RRFDetail();
                rrfDetail.AddNewRRFDetail(rrfID, storeID, itemID, requestedqty);
            }
            return(rrf.ID);
        }
        private void btnGo_Click(object sender, EventArgs e)
        {
            try
            {
                int itemID;
                if (!string.IsNullOrEmpty(txtItemID.Text))
                {
                    _itemID = int.Parse(txtItemID.Text);
                }
                itemID = _itemID;
                BLL.Item itm = new BLL.Item();
                itm.LoadByPrimaryKey(itemID);
                lblFullItemName.Text = itm.FullItemName;

                rd.LoadByItemID(itemID);
                grdReceiveDoc.DataSource = rd.DefaultView;

                recPallet.LoadByItemID(itemID);
                grdReceivePallet.DataSource = recPallet.DefaultView;

                id.LoadByItemID(itemID);
                grdIssueDoc.DataSource = id.DefaultView;

                ordDetail.LoadByItemID(itemID);
                grdOrderDetail.DataSource = ordDetail.DefaultView;

                pld.LoadByItemID(itemID);
                grdPickListDetail.DataSource = pld.DefaultView;

                _lossAndAdjustment.LoadByItemID(itemID);
                grdDisposal.DataSource = _lossAndAdjustment.DefaultView;

                yearEnd.LoadByItemID(itemID);
                grdYearEnd.DataSource = yearEnd.DefaultView;

                BLL.ItemUnit iu = new BLL.ItemUnit();
                iu.LoadAllForItem(int.Parse(txtItemID.Text));

                grdItemManufacturerItemUnit.DataSource = iu.DefaultView;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private int SaveRRF()
        {
            RRF rrf = new RRF();
            if (rrf.RRFExists(_storeID, _fromYear, _fromMonth, _toYear, _toMonth))
            {
                if (XtraMessageBox.Show("RRF Exists on disk, are you sure you want to replace it?", "RRF Save",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    return -1;
            }
            int rrfID = rrf.AddNewRRF(_storeID, _fromYear, _fromMonth, _toYear, _toMonth, true);
            BLL.Item itm = new BLL.Item();
            DataTable dtbl1 = new DataTable();
            if (gridItemChoiceView.DataSource != null) dtbl1 = ((DataView)gridItemChoiceView.DataSource).Table;
            foreach (DataRow dr in dtbl1.Rows)
            {
                int itemID = Convert.ToInt32(dr["ID"]);
                int requestedqty = Convert.ToInt32(dr["Quantity"]);
                int storeID = int.Parse(cboStores.EditValue.ToString());
                RRFDetail rrfDetail = new RRFDetail();
                rrfDetail.AddNewRRFDetail(rrfID, storeID, itemID, requestedqty);

            }
            return rrf.ID;
        }
        private void btnGo_Click(object sender, EventArgs e)
        {
            try
            {
                int itemID;
                if (!string.IsNullOrEmpty(txtItemID.Text))
                    _itemID = int.Parse(txtItemID.Text);
                itemID = _itemID;
                BLL.Item itm = new BLL.Item();
                itm.LoadByPrimaryKey(itemID);
                lblFullItemName.Text = itm.FullItemName;

                rd.LoadByItemID(itemID);
                grdReceiveDoc.DataSource = rd.DefaultView;

                recPallet.LoadByItemID(itemID);
                grdReceivePallet.DataSource = recPallet.DefaultView;

                id.LoadByItemID(itemID);
                grdIssueDoc.DataSource = id.DefaultView;

                ordDetail.LoadByItemID(itemID);
                grdOrderDetail.DataSource = ordDetail.DefaultView;

                pld.LoadByItemID(itemID);
                grdPickListDetail.DataSource = pld.DefaultView;

                _lossAndAdjustment.LoadByItemID(itemID);
                grdDisposal.DataSource = _lossAndAdjustment.DefaultView;

                yearEnd.LoadByItemID(itemID);
                grdYearEnd.DataSource = yearEnd.DefaultView;

                BLL.ItemUnit iu = new BLL.ItemUnit();
                iu.LoadAllForItem(int.Parse(txtItemID.Text));

                grdItemManufacturerItemUnit.DataSource = iu.DefaultView;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// Load All Neccessary Data and Bind To DataSource
        /// </summary>
        void LoadAndBind()
        {
            //Bind

            //Load Detail Table To Grid
            Item item = new Item();
            gridReceiveDoc.DataSource = item.GetReceiveDocDetailForDiagnostics(ItemId, ManufacturerId, UnitId,
                                                                               MovingAverageId);

            gridJournalEntries.DataSource = item.GetJournalEntriesForDiagnostics(AffectedLedgerID);

            MovingAverageHistory history = new MovingAverageHistory();
            CostElement costElement = new CostElement(ItemId, MovingAverageId, ManufacturerId, UnitId, ManufacturerId);
            gridAllSimilarItems.DataSource = history.GetHistory(costElement);

            //Load Header Information From first row to be displayed

                txtItemName.EditValue = Item;
                txtItemUnit.EditValue = Unit;
                txtManufacturerName.EditValue = Manufacturer;
                txtActivityName.EditValue = MovingAverage;
                txtUnitCost.EditValue = UnitCost;
                txtMargin.EditValue = Margin;
                txtSellingPrice.EditValue = SellingPrice;
        }