private void BarbtnOpen_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            CTechCore.Tools.frmSearch frm = new CTechCore.Tools.frmSearch();
            DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(typeof(CTechCore.WaitForms.frmWaitBasic));
            DataTable dt = new DataTable();

            MyApp.CTech.ExecSQL($"select AutoIndex, OrderNum, Account, Name, OrderDate,  ulIDPOrdConfirmed State from vw_XR_PurchaseOrdersForGRV ", ref dt);
            frm.cntrlSearch1.DataSource = dt;
            DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();

            frm.cntrlSearch1.gridView1.Columns.ToList().ForEach(c => c.MinWidth = 150);
            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (frm.cntrlSearch1.EditValue is DataRow)
                {
                    purchaseOrderToGRVBindingSource.DataSource = new PurchaseOrderToGRV(((DataRow)frm.cntrlSearch1.EditValue).Field <Int64>("AutoIndex"));
                }
                else if (frm.cntrlSearch1.EditValue is PurchaseOrderToGRV)
                {
                    purchaseOrderToGRVBindingSource.DataSource = (PurchaseOrderToGRV)frm.cntrlSearch1.EditValue;
                }

                PurchaseOrderToGRV grv = (PurchaseOrderToGRV)purchaseOrderToGRVBindingSource.DataSource;
                gcPOHeader.DataSource  = grv.HeaderInfo;
                gcPODetails.DataSource = grv.DetailInfo;
                //lkpStokGroup.Enabled = false;
            }
        }
        private void BarbtnPrintBarcodes_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            PurchaseOrderToGRV grv   = (PurchaseOrderToGRV)purchaseOrderToGRVBindingSource.DataSource;
            List <int>         rolls = new List <int>();
            DataTable          dt    = new DataTable();

            MyApp.CTech.ExecSQL($"SELECT StockRollID FROM StockRollHdr (NOLOCK) WHERE PONumber = '{grv.HeaderInfo.Table.AsEnumerable().FirstOrDefault().Field<string>("Ordernum")}' ", ref dt);

            Stock.StockRollItems.PrintBarcodes(dt.AsEnumerable().Select(r => (int)r["StockRollID"]).ToList());
        }
 private void gvPODetails_DoubleClick(object sender, EventArgs e)
 {
     DevExpress.Utils.DXMouseEventArgs                   ea   = e as DevExpress.Utils.DXMouseEventArgs;
     DevExpress.XtraGrid.Views.Grid.GridView             view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
     DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo info = view.CalcHitInfo(ea.Location);
     if (info.InRow || info.InRowCell)
     {
         frmReceiveStock frm = new frmReceiveStock((DataRow)view.GetDataRow(info.RowHandle));
         frm.StartPosition = FormStartPosition.CenterParent;
         if (frm.ShowDialog() == DialogResult.OK)
         {
             PurchaseOrderToGRV grv = (PurchaseOrderToGRV)purchaseOrderToGRVBindingSource.DataSource;
             grv.Reload();
             gcPOHeader.DataSource  = grv.HeaderInfo;
             gcPODetails.DataSource = grv.DetailInfo;
         }
     }
 }
        private void BarbtnProcess_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (lkpBinLocation.EditValue == null)
            {
                MessageBox.Show("Please select a bin location for all these items", "Invalid Bin Location ", MessageBoxButtons.OK);
                lkpBinLocation.Focus();
                return;
            }

            if (lkpBinLocation.Text.ToLower() == "photo")
            {
                //if(not user in ("vanessa", "richard", "cheslyn") )
                //if not((vStaffID = 'vanessa') or(vStaffID = 'cheslyn') or(vStaffID = 'richard')) then
                //begin
                //      messagedlg('You are not permitted to use this bin location', mtError, [mbOK], 0);
                //      exit;
                //end;
            }
            PurchaseOrderToGRV grv       = (PurchaseOrderToGRV)purchaseOrderToGRVBindingSource.DataSource;
            string             OrdNumber = grv.HeaderInfo.Table.AsEnumerable().FirstOrDefault().Field <string>("OrderNum");

            if (MessageBox.Show($"Are you sure that you want to create a GRV for Purchase Order number '{OrdNumber}'?'", "Please confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                UseWaitCursor = true;
                grv.Location  = lkpBinLocation.Text;

                DataSet    results = (DataSet)CTechCore.WaitForms.cWaitWindow.Show(grv.Process, "", new object[] { });
                List <int> rolls   = results.Tables.OfType <DataTable>().ToList().SelectMany(t => t.AsEnumerable().Select(r => (int)r["StockRollID"])).ToList();
                Stock.StockRollItems.PrintBarcodes(rolls);

                grv.Reload(grv.DocumentNumber);
                purchaseOrderToGRVBindingSource.DataSource = grv;

                gcPOHeader.DataSource  = grv.HeaderInfo;
                gcPODetails.DataSource = grv.DetailInfo;
                UseWaitCursor          = false;
            }
        }