Beispiel #1
0
        void LoadListSubJenisBrgTree()
        {
            //  list jenisBrg
            var listJenisBrg = _jenisBrgBL.ListData();

            if (listJenisBrg == null)
            {
                return;
            }
            //
            SubJenisBrgTree.Nodes.Clear();
            foreach (var item in listJenisBrg)
            {
                SubJenisBrgTree.Nodes.Add(item.JenisBrgID, item.JenisBrgName);
                var listSubJenisBrg = _subJenisBrgBL.ListData(item.JenisBrgID);
                if (listSubJenisBrg != null)
                {
                    foreach (var item2 in listSubJenisBrg)
                    {
                        SubJenisBrgTree.Nodes[item.JenisBrgID]
                        .Nodes.Add(item2.SubJenisBrgID, item2.SubJenisBrgName);
                    }
                }
            }
        }
Beispiel #2
0
        public void ListData_CallDalListData()
        {
            //  arrange

            //  act
            var actual = _subJenisBrgBL.ListData("");

            //  assert
            _subJenisBrgDal.Verify(x => x.ListData(""), Times.Once);
        }
        private void SearchButton_Click(object sender, EventArgs e)
        {
            var searchKeyword = SearchTextBox.Text.ToLower();

            //  jika keyword kosong, tampilkan semua
            if (searchKeyword.Trim() == "")
            {
                ListDataJenisBrg();
                return;
            }

            //  clear grid
            JenisBrgGrid.Rows.Clear();
            SubJenisBrgGrid.Rows.Clear();

            var listSubJenisBrg = _subJenisBrgBL.ListData();

            if (listSubJenisBrg == null)
            {
                return;
            }

            var searchResult =
                (
                    from c in listSubJenisBrg
                    where c.SubJenisBrgName.ToLower().Contains(searchKeyword.ToLower())
                    select c
                ).ToList();

            if (!searchResult.Any())
            {
                return;
            }

            //  distinct jenisbrg
            var resultJenisBrg =
                (
                    from c in searchResult
                    group c by new
            {
                c.JenisBrgID,
                c.JenisBrgName
            }
                    into d
                    select d.FirstOrDefault()
                ).ToList();

            //  isi grid jenisbrg
            if (resultJenisBrg.Any())
            {
                foreach (var item in resultJenisBrg)
                {
                    object[] rowdata =
                    {
                        item.JenisBrgID,
                        item.JenisBrgName
                    };
                    JenisBrgGrid.Rows.Add(rowdata);
                }

                ListDataSubJenisBrg(resultJenisBrg.FirstOrDefault().JenisBrgID, searchKeyword);
            }
        }