Esempio n. 1
0
        private void GetComponents()
        {
            try
            {
                FormHelpers.CursorWait(true);
                var itemno    = BPSUtilitiesV1.NZ(mtxtItemNo.Text, "").ToString();
                var partscode = BPSUtilitiesV1.NZ(mtxtPartCode.Text, "").ToString();
                ListHelper.FillMetroCombo(mcboCatCode, catbal.GetAll().Select(i => new { i.CATCODE, i.CATDESC }).
                                          Where(w => w.CATCODE == "BULK").Distinct().ToList(), "CATCODE", "CATCODE");
                var catcode = BPSUtilitiesV1.NZ(mcboCatCode.SelectedValue, "").ToString();
                item = itembal.GetWithCat(UserSettings.LogInYear, itemno, catcode);

                GetRefCompDetails();
                if (item != null && item.itemCom.Count > 0)
                {
                    if (partscode != "")
                    {
                        itemcom = item.itemCom.Where(w => w.PartNo == partscode).OrderBy(o => o.ItemAddress).FirstOrDefault();
                        if (itemcom != null)
                        {
                            var sourceTable = item.itemCom.Where(w => w.ItemAddress.StartsWith(itemcom.ItemAddress) && w.ItemAddress != itemcom.ItemAddress).ToList();
                            using (var reader = ObjectReader.Create(sourceTable,
                                                                    "DocID",
                                                                    "MatCode",
                                                                    "MatDescription",
                                                                    "ItemUsage",
                                                                    "UnitPrice",
                                                                    "Amount",
                                                                    "Address"))
                            {
                                dt.Load(reader);
                                mgridMatList.DataSource = dt;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageHelpers.ShowError(ex.Message);
            }
            finally
            {
                FormHelpers.CursorWait(false);
            }
        }