コード例 #1
0
        private void EditIssue_Load(object sender, EventArgs e)
        {
            Stores str = new Stores();
            str.LoadAll();
            cboStores.DataSource = str.DefaultView;

            ReceivingUnits rUnit = new ReceivingUnits();
            rUnit.GetActiveDispensaries();
            cboReceivingUnit.DataSource = rUnit.DefaultView;

            if (_tranId != 0)
            {
                IssueDoc iss = new IssueDoc();
                Items itm = new Items();

                iss.LoadByPrimaryKey(_tranId);

                DataTable dtItm = itm.GetItemById(iss.ItemID);
                string itemName = dtItm.Rows[0]["ItemName"].ToString() + " - " + dtItm.Rows[0]["DosageForm"].ToString() + " - " + dtItm.Rows[0]["Strength"].ToString();

                txtRefNo.Text = iss.RefNo;
                txtBatchNo.Text = iss.BatchNo;
                try
                {
                    txtPack.Text = iss.NoOfPack.ToString();
                    txtQtyPack.Text = iss.QtyPerPack.ToString();
                    txtPrice.Text = (iss.Cost * iss.QtyPerPack).ToString();
                }
                catch
                {
                    txtPack.Text = "0";
                    txtQtyPack.Text = "0";
                    txtPrice.Text = (iss.Cost * 1).ToString();
                }
                txtQuantity.Text = iss.Quantity.ToString();
                DateTime dtDate = Convert.ToDateTime(iss.Date.ToString("MM/dd/yyyy"));
                txtDate.Text = dtDate.ToShortDateString();
                //dtIssDate.Value = DateTime.Now;
                //dtIssDate.CustomFormat = "MM/dd/yyyy";
                //DateTime dtCurrent = Convert.ToDateTime(dtIssDate.Text);

                //long tic = (DateTime.Now.Ticks - dtCurrent.Ticks);
                //DateTime dtIssG = dtDate.AddTicks(tic);

                //dtIssDate.Value = dtIssG;
                cboStores.SelectedValue = iss.StoreId;
                cboReceivingUnit.SelectedValue = iss.ReceivingUnitID;
                txtItemName.Text = itemName;
                txtReceivedBy.Text = iss.IssuedBy;
                txtRemark.Text = iss.Remark;

            }
        }
コード例 #2
0
        private void PopulateListToGrid()
        {
            _dtRecGrid = new DataTable();
            var itm = new Items();
            var rec = new ReceiveDoc();
            _tabPage = 1;
            tabControl1.SelectedTabPageIndex = 1;
            if (_dtRecGrid.Columns.Count == 0)
            {
                string[] str = { "ID", "Stock Code", "Item Name", "Batch No", "Unit", "BU Qty", "Price", "Qty To Transfer", "RecID", "UnitID"};
                foreach (string col in str)
                {
                    _dtRecGrid.Columns.Add(col);
                }
            }
            int count = 1;
            foreach (DataRow dr in _dtSelectedTable.Rows)
            {
                rec.LoadByPrimaryKey(Convert.ToInt32(dr["ReceiveID"]));

                int id = Convert.ToInt32(dr["ItemID"]);
                double price = 0;
                if (!rec.IsColumnNull("Cost"))
                {
                    price = (rec.RowCount > 0) ? Convert.ToDouble(rec.Cost) * rec.QuantityLeft : 0;
                }
                DataTable dtItm = itm.GetItemById(id);
                string itemName = dtItm.Rows[0]["FullItemName"].ToString();
                object[] obj;
                switch (VisibilitySetting.HandleUnits)
                {
                    case 1:
                        obj = new object[]
                                 {
                                     id, dtItm.Rows[0]["StockCode"].ToString(),itemName, rec.BatchNo, dtItm.Rows[0]["Unit"].ToString(),rec.QuantityLeft, price, "",Convert.ToInt32(dr["ReceiveID"]),0};
                        break;
                    case 2:
                        obj = new object[]
                                 {
                                     id, dtItm.Rows[0]["StockCode"].ToString(),itemName, rec.BatchNo, dtItm.Rows[0]["Unit"].ToString(),rec.QuantityLeft, price, "",Convert.ToInt32(dr["ReceiveID"]),rec.UnitID
                                 };
                        break;
                    default:
                        obj = new object[]
                                 {
                                     id, dtItm.Rows[0]["StockCode"].ToString(),itemName, rec.BatchNo, dtItm.Rows[0]["Unit"].ToString(),rec.QuantityLeft, price, "",Convert.ToInt32(dr["ReceiveID"]),rec.UnitID
                                 };
                        break;
                }
                _dtRecGrid.Rows.Add(obj);
                count++;
            }
            receivingGrid.DataSource =_dtRecGrid;
            txtTranferFrom.Text = lkFromStore.Text;
        }
コード例 #3
0
        /// <summary>
        /// Populates the fields based on the supplied itemID or categoryID
        /// </summary>
        private void PopulateFields()
        {
            if (_itemId == 0)
                return;

            Items itm = new Items();

            DataTable dtItem = itm.GetItemById(_itemId);
            txtItemName.Text = dtItem.Rows[0]["ItemName"].ToString() + " - " + dtItem.Rows[0]["DosageForm"].ToString() + " - " + dtItem.Rows[0]["Strength"].ToString();
            ckExculed.Checked =itm.IsInHospitalList;
            chkNeedExpiryBatch.Checked = itm.NeedExpiryBatch;
            txtText.Text = itm.StockCodeDACA ?? string.Empty;
            txtQuantityPerPack.Text = itm.Cost ?? string.Empty;

            try
            {
                if (dtItem.Rows[0]["ABC"].ToString() == "A")
                    rdA.Checked = true;
                else if (dtItem.Rows[0]["ABC"].ToString() == "B")
                    rdB.Checked = true;
                else if (dtItem.Rows[0]["ABC"].ToString() == "C")
                    rdC.Checked = true;
            }
            catch { }

            try
            {
                if (dtItem.Rows[0]["VEN"].ToString() == "V")
                    rdV.Checked = true;
                else if (dtItem.Rows[0]["VEN"].ToString() == "E")
                    rdE.Checked = true;
                else if (dtItem.Rows[0]["VEN"].ToString() == "N")
                    rdN.Checked = true;
            }
            catch { }

            //ItemShelf itmShelf = new ItemShelf();
            //DataTable dtSlf = itmShelf.GetLocationByItem(itm.ID);
            //lstBinLocation.DataSource = dtSlf;

            var unit = new ItemUnit();
            var itemunits= unit.LoadFromSQl(_itemId);
            itemunitbindingSource.DataSource = itemunits;

            if (VisibilitySetting.HandleUnits == 2)
            {
                listBox1.Visible = true;
            }
            else if(VisibilitySetting.HandleUnits == 3)
            {
                 listBox1.Visible = true;
            }
            else if(VisibilitySetting.HandleUnits == 1)
            {
                listBox1.Hide();
            }
            Supplier sup = new Supplier();
            sup.GetActiveSuppliers();

            ItemSupplier itmSup = new ItemSupplier();
            itm.GetItemsBySupplier(_itemId);
            foreach (DataRowView dv in sup.DefaultView)
            {
                bool check = false;
                check = itmSup.CheckIfExist(_itemId, Convert.ToInt32(dv["ID"]));
                object obj = dv["CompanyName"];
                lstSuppliers.Items.Add(obj, check);
            }

            Programs prog = new Programs();
            prog.GetSubPrograms();
            ProgramProduct progItem = new ProgramProduct();
            lstPrograms.Items.Clear();
            foreach (DataRowView dv in prog.DefaultView)
            {
                bool check = false;
                check = progItem.CheckIfExists(_itemId, Convert.ToInt32(dv["ID"]));
                lstPrograms.Items.Add(dv["Name"], check);
            }

            ReceivingUnits dus = new ReceivingUnits();
            dus.GetActiveDispensaries();
            lstDUs.Items.Clear();

            DUsItemList duItem = new DUsItemList();

            foreach (DataRowView drDus in dus.DefaultView)
            {
                bool check = false;
                check = duItem.CheckIfExsits(_itemId, Convert.ToInt32(drDus["ID"]));
                lstDUs.Items.Add(drDus["Name"], check);
            }
        }
コード例 #4
0
        /// <summary>
        /// Populates the grid based on the selection.
        /// </summary>
        private void PopulateGridList()
        {
            if (issueGrid.DataSource != null)
            {
                var dt = new DataTable();
                issueGrid.DataSource = dt;
                _dtRecGrid.Rows.Clear();
                _dtRecGrid.Columns.Clear();
            }

            var itm = new Items();
            var itmB = new Items();
            var bal = new Balance();
            _tabPage = 1;
            tabControl1.SelectedTabPageIndex = 1;

            if (_dtRecGrid.Columns.Count == 0)
            {
                string[] str = { "ID", "Stock Code", "Item Name", "Unit", "Store SOH", "Dispatchable", "MR Issue Qty",
                                   "DU Remaining SOH", "DU AMC", "Recommended Qty", "Pack Qty", "Qty Per Pack",
                                   "Requested Qty", "MR DU SOH","UnitID"};
                foreach (string col in str)
                {
                    _dtRecGrid.Columns.Add(col);
                }
            }

            int count = 1;
            Int64 quantity = 0;
            dtIssueDate.Value = DateTime.Now;
            dtIssueDate.CustomFormat = "MM/dd/yyyy";
            var dtCurrent = ConvertDate.DateConverter(dtIssueDate.Text);
            if (_dtSelectedTable != null)
                foreach (DataRow lst in _dtSelectedTable.Rows)//(ListViewItem lst in lstItem.Items)
                {
                    var itmID = Convert.ToInt32(lst["ID"]);
                    var dtExp = itm.GetExpiredItemsByID(Convert.ToInt32(cboStores.EditValue), itmID);
                    var dtItm = itm.GetItemById(itmID);
                    Int64 expAmount = 0;
                    foreach (DataRow dr in dtExp.Rows)
                    {
                        expAmount = itmB.GetExpiredQtyItemsByID(Convert.ToInt32(dr["ID"]), Convert.ToInt32(cboStores.EditValue));
                        quantity = Convert.ToInt64(dr["Quantity"]) - expAmount;//+ adjQuant - issuedQuant - lostQuant
                    }
                    Int64 soh = 0;
                    Int64 dispatchable = Convert.ToInt64(lst["Dispatchable"]);

                    object[] obj;
                    string itemName = lst["FullItemName"].ToString();
                    switch (VisibilitySetting.HandleUnits)
                    {
                        case 1:
                            soh = bal.GetSOH(itmID, Convert.ToInt32(cboStores.EditValue), dtCurrent.Month, dtCurrent.Year);
                            obj = new object[] {itmID.ToString(), dtItm.Rows[0]["StockCode"].ToString(), itemName, dtItm.Rows[0]["Unit"].ToString(),
                                                soh, dispatchable, 0, 0, 0, 0, 0, 0, 0, 0, 0};
                            break;
                        case 2:
                            soh = bal.GetSOHByUnit(itmID, Convert.ToInt32(cboStores.EditValue), dtCurrent.Month, dtCurrent.Year, Convert.ToInt32(lst["UnitID"]));
                            obj = new object[]{ itmID.ToString(), dtItm.Rows[0]["StockCode"].ToString(),
                                                itemName, dtItm.Rows[0]["Unit"].ToString(),
                                                soh, dispatchable, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(lst["UnitID"])};
                            break;
                        default:
                            soh = bal.GetSOHByUnit(itmID, Convert.ToInt32(cboStores.EditValue), dtCurrent.Month, dtCurrent.Year, Convert.ToInt32(lst["UnitID"]));
                            obj = new object[]{ itmID.ToString(), dtItm.Rows[0]["StockCode"].ToString(),
                                                itemName, dtItm.Rows[0]["Unit"].ToString(),
                                                soh, dispatchable, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(lst["UnitID"])};
                            break;
                    }

                    //if (expAmount < soh && quantity < soh || dispatchable > 0)
                    //{
                    //    _dtRecGrid.Rows.Add(obj);
                    //    count++;
                    //}

                    if (expAmount < soh && dispatchable > 0)
                    {
                        _dtRecGrid.Rows.Add(obj);
                        count++;
                    }
                    else if(soh >0 && dispatchable==0)
                    {
                        XtraMessageBox.Show(String.Format("{0} Is Expired!", itemName), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        ResetValues();
                        tabControl1.TabIndex = 0;
                        break;
                    }
                    else if (soh == 0)
                    {
                      XtraMessageBox.Show(String.Format("{0} is stocked out!", itemName), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        break;
                    }
                    else if (expAmount == soh && expAmount != 0)
                    {
                        XtraMessageBox.Show(String.Format("{0} Is Expired!",itemName), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        ResetValues();
                        tabControl1.TabIndex = 0;
                        break;
                    }
                    else if( dispatchable>0 )
                    {
                        _dtRecGrid.Rows.Add(obj);
                        count++;
                    }
                    else
                    {
                        ResetValues();
                        XtraMessageBox.Show("You are trying to issue an Expired item!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        tabControl1.TabIndex = 0;
                        break;
                    }
                }

            issueGrid.DataSource = _dtRecGrid;
            cboStoreConf.EditValue = cboStores.EditValue;
            dtIssueDate.CustomFormat = "MMM dd,yyyy";

            var recUnit = new ReceivingUnits();
            recUnit.GetActiveDispensaries();
            cboReceivingUnits.Properties.DataSource = recUnit.DefaultView;
            cboReceivingUnits.Properties.DisplayMember = "Name";
            cboReceivingUnits.Properties.ValueMember = "ID";
        }
        private void ItemStockStatus()
        {
            GeneralInfo info = new GeneralInfo();
            info.LoadAll();
            Balance bal = new Balance();
            Items itm = new Items();
            //dtDate.Value = DateTime.Now;
            //DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text);

            // int yr = ()?dtCurrent.Year : dtCurrent.Year -1;
            DataTable dtItm = itm.GetItemById(_itemId);
            string dosage = lblBUnit.Text;
            double amc = Builder.CalculateAverageConsumption(_itemId, _storeId, _dtCurrent.Subtract(TimeSpan.FromDays(180)), _dtCurrent, CalculationOptions.Monthly);//bal.CalculateAMC(_itemId, _storeId, _dtCurrent.Month, _dtCurrent.Year);
            Int64 soh = bal.GetSOH(_itemId, _storeId, _dtCurrent.Month, _dtCurrent.Year);
            double sohPrice = bal.GetSOHAmount(_itemId, _storeId, _dtCurrent.Month, _dtCurrent.Year);
            string sohPriStr = ((sohPrice != 0) ? sohPrice.ToString("C") + " ETB" : "0 ETB");
            // this can not be done cuz it works only for current year
            // Int64 soh = itm.GetSOHQtyAmount(itemId, storeId);

            double min = (amc * info.Min); //Int64 min = (amc * info.Min);
            double max = (amc * info.Max);  //Int64 max = (amc * info.Max);
            double eop = amc * (info.EOP + 0.25);
            double beloweop = amc * (info.EOP - 0.25);
            double reorder = max - soh;
            double mos = (amc > 0) ? (Convert.ToDouble(soh) / Convert.ToDouble(amc)) : 0;
            object[] obj = itm.GetExpiredQtyAmountItemsByID(_itemId, _storeId);
            Int64 expAmount = Convert.ToInt64(obj[0]);
            Double expCost = Convert.ToDouble(obj[1]);
            string expBirr = ((expCost != 0) ? " in ETB " + expCost.ToString("C") : " Price NA");
            object[] nearObj = itm.GetNearlyExpiredQtyAmountItemsByID(_itemId, _storeId);
            Int64 nearExpAmount = Convert.ToInt64(nearObj[0]);
            double nearExpCost = Convert.ToDouble(nearObj[1]);
            string nearExpBirr = ((nearExpCost != 0) ? " in ETB " + nearExpCost.ToString("C") : " Price NA");
            txtSOH.Text = (soh != 0) ? soh.ToString("#,###") + " - " + dosage + ", " + sohPriStr : "0 - " + dosage;
            txtAMC.Text = (amc != 0) ? amc.ToString("#,###") + " - " + dosage : "0" + " - " + dosage;
            txtMin.Text = (min != 0) ? min.ToString("#,###") + " - " + dosage : "0" + " - " + dosage;
            txtMax.Text = (max != 0) ? max.ToString("#,###") + " - " + dosage : "0" + " - " + dosage;
            txtMOS.Text = mos.ToString("#,###.0#");
            txtReorderAmount.Text = (reorder <= 0) ? "0 - " + dosage : reorder.ToString("#,###") + " - " + dosage;
            txtExpiredAmount.Text = (expAmount != 0) ? "Qty: " + expAmount.ToString("#,###") + " - " + dosage + expBirr : "0";
            txtNearExp.Text = (nearExpAmount != 0) ? nearExpAmount.ToString("#,###") + " - " + dosage + nearExpBirr : "0";

            DateTime dtTran = new DateTime();
            //dtDate.Value = DateTime.Now;
            //dtDate.CustomFormat = "MM/dd/yyyy";

            TimeSpan tt = new TimeSpan();
            if (soh == 0)
            {
                lblstat.Text = "Stocked Out";
                lblStatus.Text = "Stocked Out";
                lblCurStatus.Text = "Stocked Out";
                dtTran = itm.GetLastIssuedDate(_itemId, _storeId);
                tt = new TimeSpan(_dtCurrent.Ticks - dtTran.Ticks);
                lblTime.Text = " For the past " + tt.TotalDays.ToString() + " Days";
            }
            else if (soh > max && max != 0)
            {
                lblstat.Text = "Over Stock";
                lblStatus.Text = "Over Stock";
                lblCurStatus.Text = "Over Stock";
                dtTran = itm.GetLastReceiveDate(_itemId, _storeId);
                tt = new TimeSpan(_dtCurrent.Ticks - dtTran.Ticks);
                lblTime.Text = " For the past " + tt.TotalDays.ToString() + " Days";
            }
            else if (soh > beloweop && soh <= eop)
            {
                lblstat.Text = "Near EOP";
                lblStatus.Text = "Near EOP";
                lblCurStatus.Text = "Near EOP";
                dtTran = itm.GetLastIssuedDate(_itemId, _storeId);
                tt = new TimeSpan(_dtCurrent.Ticks - dtTran.Ticks);
                lblTime.Text = " For the past " + tt.TotalDays.ToString() + " Days";
            }
            else if (soh > 0 && soh <= beloweop)
            {
                lblstat.Text = "Below EOP";
                lblStatus.Text = "Below EOP";
                lblCurStatus.Text = "Below EOP";
                dtTran = itm.GetLastIssuedDate(_itemId, _storeId);
                tt = new TimeSpan(_dtCurrent.Ticks - dtTran.Ticks);
                lblTime.Text = " For the past " + tt.TotalDays.ToString() + " Days";
            }
            else if (soh > eop && soh <= min)
            {
                lblstat.Text = "Below Min";
                lblStatus.Text = "Below Min";
                lblCurStatus.Text = "Below Min";
                dtTran = itm.GetLastIssuedDate(_itemId, _storeId);
                tt = new TimeSpan(_dtCurrent.Ticks - dtTran.Ticks);
                lblTime.Text = " For the past " + tt.TotalDays.ToString() + " Days";
            }
            else //if (soh> min && soh <= max)
            {
                lblstat.Text = "Normal";
                lblStatus.Text = "Normal";
                lblCurStatus.Text = "Normal";

            }
            //}
            //else
            //{
            //    lblCurStatus.Text = "Stocked Out";

            //    lblTime.Text = " Never been received!";
            //}
        }
        private void BinCardTransaction_Load(object sender, EventArgs e)
        {
            DataTable dtyears = Items.AllYears();

            dtDate.Value = DateTime.Now;
            dtDate.CustomFormat = "MM/dd/yyyy";
            _dtCurrent = ConvertDate.DateConverter(dtDate.Text);
            //CALENDAR:
            foreach (DataRow drYears in dtyears.Rows)
            {
                if (drYears["year"] != DBNull.Value)
                {
                    int yr = Convert.ToInt32(drYears["year"]);
                    cboYear.Items.Add(yr);
                }
            }
            bool added = true;
            for (int x = 0; x < cboYear.Items.Count; x++)//to check if the current year is included or not
            {
                if (Convert.ToInt64(cboYear.Items[x]) == _year)
                {
                    added = false;
                    break;
                }
            }
            if (added)
            {
                cboYear.Items.Add(_year);
            }
            cboYear.SelectedItem = _year;

            var itemunit = new ItemUnit();
            var allunits = itemunit.GetAllUnits();
            unitBindingSource.DataSource = allunits.DefaultView;

            var unitcolumn = ((GridView)gridItemsList.MainView).Columns[11];
            switch (VisibilitySetting.HandleUnits)
            {
                case 1:
                    unitcolumn.Visible = false;
                    break;
                case 2:
                    unitcolumn.Visible = true;
                    break;
                default:
                    unitcolumn.Visible = true;
                    break;
            }

            PopulateBinCardYearCombo();
            cboFiscalYear.SelectedItem = _year;
            BLL.Items itm = new Items();
            DataTable dtItm = itm.GetItemById(_itemId);
            string itemName = dtItm.Rows[0]["ItemName"].ToString() + " - " + dtItm.Rows[0]["DosageForm"].ToString() + " - " + dtItm.Rows[0]["Strength"].ToString();
            txtItemName.Text = itemName;
            txtitmName.Text = itemName;
            toolTip1.SetToolTip(txtitmName, itemName);
            lblBUnit.Text = dtItm.Rows[0]["Unit"].ToString();
            this.Text = itemName + " Detail Report";

            ReceivingUnits dus = new ReceivingUnits();
            DataTable dtDU = dus.GetApplicableDUs(_itemId, _storeId);
            Stores stor = new Stores();
            stor.LoadByPrimaryKey(_storeId);
            object[] objS = { 0, stor.StoreName, "", "" };
            dtDU.Rows.Add(objS);
            cboDU.DataSource = dtDU;
            cboDU.SelectedIndex = (cboDU.Items.Count - 1);
            cboDU.Text = "Select DU";

            try
            {
                txtFreeItem.Text = (itm.IsFree) ? "Yes" : "No";
                txtRefrigerated.Text = (itm.Refrigeratored) ? "Yes" : "No";
                txtPediatric.Text = (itm.Pediatric) ? "Yes" : "No";

            }
            catch
            {
            }

            int du = ((cboDU.SelectedValue != null) ? Convert.ToInt32(cboDU.SelectedValue) : 0);
            GenerateCharts(0);
            ItemStockStatus();

            //GenerateBinCard();
            GenerateBinCardNew();
            PopulateTransaction();

            tabControl1.SelectedTabPageIndex = _tabInd;
            _first = 1;
            lblItemID.Text = _itemId.ToString();

            PopulateLogisticSummary();
        }
コード例 #7
0
        /// <summary>
        /// Load the lookups and Prepare the form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditReceive_Load(object sender, EventArgs e)
        {
            lkItemUnit.Enabled = VisibilitySetting.HandleUnits != 1;
            var str = new Stores();
            str.LoadAll();
            cboStores.DataSource = str.DefaultView;

            var sup = new Supplier();
            sup.GetActiveSuppliers();
            cboSupplier.DataSource = sup.DefaultView;

            if(_tranId != 0)
            {
                var rec = new ReceiveDoc();
                var itm = new Items();

                rec.LoadByPrimaryKey(_tranId);

                var dtItm = itm.GetItemById(rec.ItemID);

                var units = new ItemUnit();
                var unit = units.LoadFromSQl(rec.ItemID);
                lkItemUnit.Properties.DataSource = unit;
                lkItemUnit.Properties.DisplayMember = "Text";
                lkItemUnit.Properties.ValueMember = "ID";

                var programs = new Programs();
                var allprograms = programs.GetSubPrograms();
                lkPrograms.Properties.DataSource = allprograms;
                lkPrograms.Properties.ValueMember = "ID";
                lkPrograms.Properties.DisplayMember = "Name";

                string itemName = dtItm.Rows[0]["ItemName"].ToString() + " - " + dtItm.Rows[0]["DosageForm"].ToString() + " - " + dtItm.Rows[0]["Strength"].ToString();

                txtRefNo.Text = rec.RefNo;
                txtBatchNo.Text = rec.BatchNo;
                try
                {
                    txtPack.Text = rec.NoOfPack.ToString();
                    txtQtyPack.Text =rec.QtyPerPack.ToString();
                    txtPrice.Text = (rec.Cost * rec.QtyPerPack).ToString();
                    //txtQuantityLeft.Text = rec.QuantityLeft.ToString();
                }
                catch
                {
                    txtPack.Text = "0";
                    txtQtyPack.Text = "0";
                    txtPrice.Text = (rec.Cost * 1).ToString();
                }
                txtQuantity.Text = rec.Quantity.ToString();
                lkPrograms.EditValue = rec.SubProgramID;
                DateTime dtDate = Convert.ToDateTime(rec.Date.ToString("MM/dd/yyyy"));
                txtDate.Text = dtDate.ToShortDateString();
                dtRecDate.Value = DateTime.Now;
                dtRecDate.CustomFormat = "MM/dd/yyyy";
                if (!rec.IsColumnNull("ExpDate"))
                    dtExpiryDate.Value = rec.ExpDate;
                cboStores.SelectedValue = rec.StoreID;
                cboSupplier.SelectedValue = rec.SupplierID;

                if (!rec.IsColumnNull("UnitID"))
                    lkItemUnit.EditValue = rec.UnitID;
                txtItemName.Text = itemName;
                txtReceivedBy.Text = rec.ReceivedBy;
                txtRemark.Text = rec.Remark;

            }
        }
        /// <summary>
        /// Populate the grid with the selected items.
        /// </summary>
        private void PopulateGridList()
        {
            dtRecGrid = new DataTable();
            Items itm = new Items();
            ReceiveDoc rec = new ReceiveDoc();
            tabPage = 1;
            tabControl1.SelectedTabPageIndex = 1;
            if (dtRecGrid.Columns.Count == 0)
            {
                string[] str = { "ID", "Stock Code", "Item Name", "Batch No", "Unit", "BU Qty", "Price", "Losses", "Adjustment", "RecID", "Reason",
                               "UnitID"};
                foreach (string col in str)
                {
                    dtRecGrid.Columns.Add(col);
                }
            }
            int count = 1;
            foreach (DataRow dr in dtSelectedTable.Rows)
            {
                rec.LoadByPrimaryKey(Convert.ToInt32(dr["ReceiveID"]));

                int id = Convert.ToInt32(dr["ItemID"]);
                double price = 0;
                if (!rec.IsColumnNull("Cost"))
                {
                    price = (rec.RowCount > 0) ? Convert.ToDouble(rec.Cost) * rec.QuantityLeft : 0;
                }
                DataTable dtItm = itm.GetItemById(id);
                string itemName = dtItm.Rows[0]["FullItemName"].ToString();
                var obj = new object[] { };
                switch (VisibilitySetting.HandleUnits)
                {
                    case 1:
                        obj = new object[]
                                 {
                                     id, dtItm.Rows[0]["StockCode"].ToString(),
                                     itemName, rec.BatchNo, dtItm.Rows[0]["Unit"].ToString(),
                                     rec.QuantityLeft, price, "", "",
                                     Convert.ToInt32(dr["ReceiveID"]),
                                     0, 0
                                 };
                        break;
                    case 2:
                        obj = new object[]
                                 {
                                     id, dtItm.Rows[0]["StockCode"].ToString(),
                                     itemName, rec.BatchNo, dtItm.Rows[0]["Unit"].ToString(),
                                     rec.QuantityLeft, price, "", "",
                                     Convert.ToInt32(dr["ReceiveID"]),
                                     0, rec.UnitID
                                 };
                        break;
                    default:
                        obj = new object[]
                                 {
                                     id, dtItm.Rows[0]["StockCode"].ToString(),
                                     itemName, rec.BatchNo, dtItm.Rows[0]["Unit"].ToString(),
                                     rec.QuantityLeft, price, "", "",
                                     Convert.ToInt32(dr["ReceiveID"]),
                                     0, rec.UnitID
                                 };
                        break;
                }
                dtRecGrid.Rows.Add(obj);
                count++;

            }

            //var disRes = new DisposalReasons();
            //var allreasons = disRes.GetAllReasons();
            //reasonBindingSource.DataSource = allreasons.DefaultView;

            AdjustmentGrid.DataSource = dtRecGrid;
            cboStoreConfi.Text = cboStores.Text;
        }