/// <summary>
        /// 初始化数据
        /// </summary>
        private void InitCommodityData()
        {
            ClearPage();
            SetSizeAndColorItems();
            string errText = "";

            if (_commodityInfoService == null)
            {
                _commodityInfoService = new CommodityInfoService();
            }
            List <CommodityInfo> list;

            if (_currentTypeId == Guid.Empty)
            {
                this.dataGridView1.DataSource = CreateDtTemplate();
                return;
            }
            list = _commodityInfoService.GetEntityList(out errText, _currentTypeId);
            if (list == null || list.Count == 0)
            {
                this.dataGridView1.DataSource = CreateDtTemplate();
                return;
            }
            this.dataGridView1.DataSource = list;
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string errText;

            if (_commodityInfoService == null)
            {
                _commodityInfoService = new CommodityInfoService();
            }
            var i = _commodityInfoService.DeleteEntity(out errText, _currentId);

            if (i == 0)
            {
                MessageBox.Show(errText);
                return;
            }
            MessageBox.Show("删除成功!");
            ClearPage();
            InitCommodityData();
        }
示例#3
0
        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitCommodityData()
        {
            string errText = "";

            if (_commodityInfoService == null)
            {
                _commodityInfoService = new CommodityInfoService();
            }
            List <CommodityInfo> list;

            list = _commodityInfoService.GetEntityList(out errText);
            if (list == null || list.Count == 0)
            {
                this.dataGridView1.DataSource = CreateDtTemplate();
                return;
            }
            var data = GetDistinctData(_currentDt, list);

            this.dataGridView1.DataSource = EntityHelper.CreateInstanceCollection(data);
        }
        /// <summary>
        /// 查找商品
        /// </summary>
        /// <param name="commodityNo"></param>
        private void QueryData(string commodityNo)
        {
            if (string.IsNullOrEmpty(commodityNo))
            {
                MessageBox.Show("请输入查询的商品编号!");
                return;
            }
            if (_commodityInfoService == null)
            {
                _commodityInfoService = new CommodityInfoService();
            }
            string errText;
            var    result = _commodityInfoService.QueryCommodityInfo(out errText, commodityNo);

            if (result == null || result.Count == 0)
            {
                MessageBox.Show("没有找到匹配的商品!");
                return;
            }
            this.dataGridView1.DataSource = result;
        }