Пример #1
0
        private void gvRecDocuments_ClickAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            if (currentRecItemCode != string.Empty)
            {
                PopulateRecBatchTables();
            }
            if (pVal.Row >= 0)
            {
                string itemCode  = dtRecDocuments.GetValue("ItemCode", pVal.Row).ToString();
                string whsCode   = dtRecDocuments.GetValue("WhsCode", pVal.Row).ToString();
                double avgPrice  = Convert.ToDouble(dtRecDocuments.GetValue("AvgPrice", pVal.Row));
                double addAmount = Convert.ToDouble(dtRecDocuments.GetValue("AddAmount", pVal.Row));
                double quantity  = Convert.ToDouble(dtRecDocuments.GetValue("Quantity", pVal.Row));

                currentRecDocumentIndex = pVal.Row;
                currentRecItemCode      = itemCode;
                currentRecWhsCode       = whsCode;

                //CHECK IF THE SELECTED BATCHES TABLE HAS BEEN POPULATED BEFORE
                var selectedBatches = receiptBatchDataSources.Where(x => x.ItemCode == currentRecItemCode && x.WhsCode == currentRecWhsCode && x.Index == currentRecDocumentIndex);
                if (selectedBatches.Count() > 0)
                {
                    dtRecBatches.Rows.Clear();
                    this.UIAPIRawForm.Freeze(true);
                    for (int x = 0; x < selectedBatches.First().SelectedBatches.Rows.Count; x++)
                    {
                        dtRecBatches.Rows.Add(1);
                        dtRecBatches.SetValue("Batch", x, selectedBatches.First().SelectedBatches.Rows[x]["Batch"]);
                        dtRecBatches.SetValue("Selected Qty", x, selectedBatches.First().SelectedBatches.Rows[x]["Selected Qty"]);
                    }
                    this.UIAPIRawForm.Freeze(false);
                }
                else
                {
                    dtRecBatches.Rows.Clear();
                    //System.Data.DataTable dt = CopyBatchesDataTable(dtRecBatches);
                    var bds = new SelectedBatchDataSources()
                    {
                        AddAmount       = addAmount,
                        AvgPrice        = Convert.ToDouble(avgPrice),
                        Quantity        = Convert.ToDouble(quantity),
                        Index           = currentRecDocumentIndex,
                        ItemCode        = currentRecItemCode,
                        WhsCode         = currentRecWhsCode,
                        SelectedBatches = CopySelectedBatchesDataTable(dtRecBatches)
                    };
                    receiptBatchDataSources.Add(bds);
                }
            }
            gvRecBatches.AddLine();
        }