Ejemplo n.º 1
0
        private void NotExisted()
        {
            Products product = null;

            try
            {
                // 数据库中查找
                product = objProductManager.GetProductByProductId(this.textBoxProductId.Text.Trim());
            }
            catch (Exception ex)
            {
                MessageBoxEx.Show("查询商品时出错!",
                                  Program.MessageBoxTitle[Program.MessageBoxTitleType.Error],
                                  ex.Message,
                                  MessageBoxButtons.OK,
                                  MessageBoxIcon.Error);
            }
            if (product != null)
            {
                AddtoDetailList(product, Convert.ToInt32(this.textBoxCount.Text.Trim()));
            }
            // 数据库中也没有找到
            else
            {
                AddtoDetailList(GenerateNewProduct(), Convert.ToInt32(this.textBoxCount.Text.Trim()));
                return;
            }
        }