Ejemplo n.º 1
0
 private void BtnUpdate_Click(object sender, EventArgs e)
 {
     if (DgvCategory.SelectedRows.Count == 1)
     {
         int index = DgvCategory.SelectedRows[0].Index;
         category = categories[index];
         FrmCategoryUpdate fmu = new FrmCategoryUpdate {
             StartPosition = FormStartPosition.CenterParent
         };
         fmu.ShowDialog();
         if (category != null)
         {
             DgvCategory.Rows[index].Cells["Column1"].Value  = category.CategoryID;
             DgvCategory.Rows[index].Cells["Column2"].Value  = category.CategoryName;
             DgvCategory.Rows[index].Cells["Column3"].Value  = category.ParentCategoryName;
             DgvCategory.Rows[index].Cells["Column7"].Value  = category.Firm;
             DgvCategory.Rows[index].Cells["Column5"].Value  = category.Unit;
             DgvCategory.Rows[index].Cells["Column6"].Value  = category.Color;
             DgvCategory.Rows[index].Cells["Column10"].Value = category.ExpirationDate;
             DgvCategory.Rows[index].Cells["Column8"].Value  = category.MinStock;
             DgvCategory.Rows[index].Cells["Column9"].Value  = category.MaxStock;
             DgvCategory.Rows[index].Cells["Column11"].Value = category.IsValid;
             categories[index] = category;
             category          = null;
         }
         hasUpdated = true;
     }
     else
     {
         MsgBoxUtil.ErrMsgBox("请选择要修改的商品信息!");
     }
 }
Ejemplo n.º 2
0
 private void BtnMsDelete_Click(object sender, EventArgs e)
 {
     if (DgvMembership.SelectedRows.Count == 1)
     {
         int index = DgvMembership.SelectedRows[0].Index;
         Ms = mses[index];
         if (EValid.效 == Ms.IsValid)
         {
             StringBuilder sb = new StringBuilder();
             sb.Append("确定删除当前会员?\n");
             sb.Append("会员编号" + Ms.MsID.ToString() + "\n");
             sb.Append("会员姓名" + Ms.MsName + "\n");
             sb.Append("联系方式" + Ms.MsPhone + "\n");
             sb.Append("会员积分" + Ms.MsPoint);
             if (DialogResult.OK == MsgBoxUtil.QuestionMsgBox(sb.ToString()))
             {
                 MembershipDao.DeleteByMsID(Ms.MsID);
                 mses[index].IsValid = EValid.已删除;
                 DgvMembership.Rows[index].Cells["ClnMsIsValid"].Value = EValid.已删除;
                 Ms = null;
             }
         }
     }
     else
     {
         MsgBoxUtil.ErrMsgBox("请选择要删除的会员!");
     }
 }
Ejemplo n.º 3
0
 private void BtnInsert_Click(object sender, EventArgs e)
 {
     try {
         string    CategoryName       = TxtCategoryName.Text;
         ECategory ParentCategoryEnum = (ECategory)CmbParentCategoryName.SelectedIndex;
         string    ParentCategoryName = ParentCategoryEnum.ToString();
         Console.WriteLine(ParentCategoryName);
         string Firm           = TxtFirm.Text;
         string Unit           = TxtUnit.Text;
         string Color          = TxtColor.Text;
         int    ExpirationDate = int.Parse(TxtExpirationDate.Text);
         int    MinStock       = int.Parse(TxtMinStock.Text);
         int    MaxStock       = int.Parse(TxtMaxStock.Text);
         FrmCategory.category = new EtCategory {
             CategoryName       = CategoryName,
             ParentCategoryID   = ParentCategoryEnum,
             ParentCategoryName = ParentCategoryName,
             Unit           = Unit,
             Color          = Color,
             Firm           = Firm,
             MinStock       = MinStock,
             MaxStock       = MaxStock,
             ExpirationDate = ExpirationDate,
             IsValid        = EValid.效
         };
         Close();
     }
     catch (Exception) {
         MsgBoxUtil.ErrMsgBox("商品信息输入错误!");
     }
 }
 private void BtnCommit_Click(object sender, EventArgs e)
 {
     try {
         if (TxtCategoryName.Text == "")
         {
             MsgBoxUtil.ErrMsgBox("商品名称不得为空!");
         }
         else
         {
             FrmCategory.category = new EtCategory
             {
                 CategoryID         = FrmCategory.category.CategoryID,
                 CategoryName       = TxtCategoryName.Text,
                 ParentCategoryID   = (ECategory)CmbParentCategoryName.SelectedIndex,
                 ParentCategoryName = ((ECategory)CmbParentCategoryName.SelectedIndex).ToString(),
                 Unit           = TxtUnit.Text,
                 Color          = TxtColor.Text,
                 Firm           = TxtFirm.Text,
                 MinStock       = int.Parse(TxtMinStock.Text),
                 MaxStock       = int.Parse(TxtMaxStock.Text),
                 ExpirationDate = int.Parse(TxtExpirationDate.Text),
                 IsValid        = (EValid)CmbIsValid.SelectedIndex
             };
             Close();
         }
     }
     catch (Exception) {
         MsgBoxUtil.ErrMsgBox("商品信息输入错误!");
     }
 }
Ejemplo n.º 5
0
 private void BtnStaffDelete_Click(object sender, EventArgs e)
 {
     if (DgvStaffData.SelectedRows.Count == 1)
     {
         int index = DgvStaffData.SelectedRows[0].Index;
         Staff = staffs[index];
         StringBuilder sb = new StringBuilder();
         sb.Append("确定删除当前员工?\n");
         sb.Append("员工编号:" + Staff.StaffID.ToString() + "\n");
         sb.Append("员工姓名:" + Staff.StaffName + "\n");
         sb.Append("联系方式:" + Staff.StaffPhone + "\n");
         sb.Append("员工职称:" + Staff.Role);
         if (DialogResult.OK == MsgBoxUtil.QuestionMsgBox(sb.ToString()))
         {
             StaffDao.DeleteByStaffID(Staff.StaffID);
             staffs.RemoveAt(index);
             DgvStaffData.Rows.RemoveAt(index);
             Staff = null;
         }
     }
     else
     {
         MsgBoxUtil.ErrMsgBox("请选择要删除的员工!");
     }
 }
Ejemplo n.º 6
0
 private void BtnMsUpdate_Click(object sender, EventArgs e)
 {
     if (DgvMembership.SelectedRows.Count == 1)
     {
         int index = DgvMembership.SelectedRows[0].Index;
         Ms = mses[index];
         FrmMsUpdate fmu = new FrmMsUpdate {
             StartPosition = FormStartPosition.CenterParent
         };
         fmu.ShowDialog();
         if (Ms != null)
         {
             DgvMembership.Rows[index].Cells["ClnMsName"].Value    = Ms.MsName;
             DgvMembership.Rows[index].Cells["ClnMsPhone"].Value   = Ms.MsPhone;
             DgvMembership.Rows[index].Cells["ClnMsPoint"].Value   = Ms.MsPoint;
             DgvMembership.Rows[index].Cells["ClnMsIsValid"].Value = Ms.IsValid;
             mses[index] = Ms;
             Ms          = null;
         }
         hasUpdated = true;
     }
     else
     {
         MsgBoxUtil.ErrMsgBox("请选择要修改的会员信息!");
     }
 }
 private void BtnComfirm_Click(object sender, EventArgs e)
 {
     if (0 == Goods.Count)
     {
         MsgBoxUtil.ErrMsgBox("没有待插入的表单!");
     }
     else if (DialogResult.OK == MsgBoxUtil.QuestionMsgBox("确认提交?"))
     {
         if (Save())
         {
             Close();
         }
     }
 }
Ejemplo n.º 8
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                int            account  = int.Parse(TxtAccount.Text);
                string         password = TxtPassword.Text;
                string         pwd      = Encrypt.GetMD5(password);
                List <EtStaff> staffs   = StaffDao.QueryByStaffID(account);
                if (staffs.Count == 0)
                {
                    MsgBoxUtil.ErrMsgBox("用户名或密码错误");
                }
                else if (!pwd.Equals(staffs[0].Pwd))
                {
                    MsgBoxUtil.ErrMsgBox("用户名或密码错误");
                }
                else
                {
                    Form f = null;
                    switch (staffs[0].Role)
                    {
                    case Enums.ERole.未定义:
                        break;

                    case Enums.ERole.管理员:
                        f = new FrmMainAdmin();
                        break;

                    case Enums.ERole.采购员:
                        f = new FrmMainPurchase();
                        break;

                    case Enums.ERole.销售员:
                        f = new FrmMainSale();
                        break;
                    }
                    Hide();
                    if (f != null)
                    {
                        f.ShowDialog();
                    }
                    Close();
                }
            }
            catch
            {
                MsgBoxUtil.ErrMsgBox("用户名或密码错误");
            }
        }
 private void BtnSubmit_Click(object sender, EventArgs e)
 {
     if (DialogResult.OK == MsgBoxUtil.QuestionMsgBox("确定提交?"))
     {
         if (!hasErr)
         {
             FrmGoodIncome.Goods.AddRange(excelGoods);
             Close();
         }
         else
         {
             MsgBoxUtil.ErrMsgBox("导入失败!");
         }
     }
 }
Ejemplo n.º 10
0
 private void BtnInsert_Click(object sender, EventArgs e)
 {
     try {
         EtSale sale = new EtSale {
             SaleID = 0,
             Good   = GoodDao.QueryByGoodID(int.Parse(CmbGoodID.SelectedItem.ToString().Split(' ')[0]))[0]
         };
         sale.Profit     = int.Parse(TxtPrice.Text) - sale.Good.Cost;
         sale.Good.Price = int.Parse(TxtPrice.Text);
         sale.Good.State = Enums.EState.已出售;
         FrmSale.Sales.Add(sale);
         Close();
     }
     catch (Exception) {
         MsgBoxUtil.ErrMsgBox("输入不得为空!");
     }
 }
Ejemplo n.º 11
0
 private void BtnMultiSaleInsert_Click(object sender, EventArgs e)
 {
     if (CmbOperator.SelectedIndex != -1)
     {
         salesPreSize = Sales.Count;
         FrmSaleFromExcel frmSaleFromExcel = new FrmSaleFromExcel {
             StartPosition = FormStartPosition.CenterParent
         };
         frmSaleFromExcel.ShowDialog();
         salesCurSize = Sales.Count;
         DgvAdd();
     }
     else
     {
         MsgBoxUtil.ErrMsgBox("请先选择经办人!");
     }
 }
Ejemplo n.º 12
0
        private bool Save()
        {
            EtPurchase purchase;

            if (-1 == CmbOperator.SelectedIndex)
            {
                MsgBoxUtil.ErrMsgBox("经办人不能为空!");
                return(false);
            }
            int staffId = StaffDao.QueryByStaffName(CmbOperator.SelectedItem.ToString())[0].StaffID;
            int res     = 0;

            foreach (ClsGood good in Goods)
            {
                purchase = new EtPurchase {
                    PurchaseID   = int.Parse(LblPurchaseID.Text),
                    Category     = good.Good.Category,
                    PurchaseDate = DtpPurchaseDate.Value.ToString("yyyyMMdd"),
                    Quantity     = good.Count,
                    Cost         = good.Good.Cost,
                    StaffID      = staffId
                };
                res += PurchaseDao.InsertPurchase(purchase);
                EtGood g = new EtGood {
                    Category       = good.Good.Category,
                    ProductionDate = good.Good.ProductionDate,
                    PurchaseDate   = purchase.PurchaseDate,
                    Cost           = good.Good.Cost,
                    Price          = good.Good.Price,
                    State          = good.Good.State
                };
                for (int i = 0; i < good.Count; i++)
                {
                    GoodDao.InsertGood(g);
                }
            }
            if (res == Goods.Count)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 13
0
 private void BtnStaffSubmit_Click(object sender, EventArgs e)
 {
     if (hasUpdated)
     {
         if (DialogResult.OK == MsgBoxUtil.QuestionMsgBox("确认提交?"))
         {
             foreach (EtStaff staff in staffs)
             {
                 StaffDao.InsertStaff(staff);
             }
             hasUpdated = false;
         }
     }
     else
     {
         MsgBoxUtil.ErrMsgBox("没有待添加的员工!");
     }
 }
Ejemplo n.º 14
0
 private void BtnSaleSubmit_Click(object sender, EventArgs e)
 {
     if (hasUpdated)
     {
         if (DialogResult.OK == MsgBoxUtil.QuestionMsgBox("确认提交?"))
         {
             if (Save())
             {
                 Close();
                 hasUpdated = false;
             }
         }
     }
     else
     {
         MsgBoxUtil.ErrMsgBox("没有待插入的表单!");
     }
 }
Ejemplo n.º 15
0
 private void BtnMsUpdate_Click(object sender, EventArgs e)
 {
     if (TxtMsName.Text == "")
     {
         MsgBoxUtil.ErrMsgBox("会员姓名不得为空!");
     }
     else
     {
         FrmMembership.Ms = new EtMembership {
             MsID    = FrmMembership.Ms.MsID,
             MsName  = TxtMsName.Text,
             MsPhone = TxtMsPhone.Text,
             MsPoint = int.Parse(TxtMsPoint.Text),
             IsValid = (EValid)CmbIsValid.SelectedIndex
         };
         Close();
     }
 }
Ejemplo n.º 16
0
 private void BtnInsert_Click(object sender, EventArgs e)
 {
     try {
         string MsName  = TxtMsName.Text;
         string MsPhone = TxtMsPhone.Text;
         int    MsPoint = "" == TxtMsPoint.Text ? 0 : int.Parse(TxtMsPoint.Text);
         EValid IsValid = (EValid)CmbIsValid.SelectedIndex;
         FrmMembership.Ms = new EtMembership {
             MsName  = MsName,
             MsPhone = MsPhone,
             MsPoint = MsPoint,
             IsValid = IsValid
         };
         Close();
     }
     catch (Exception) {
         MsgBoxUtil.ErrMsgBox("员工信息输入错误!");
     }
 }
Ejemplo n.º 17
0
 private void BtnSubmit_Click(object sender, EventArgs e)
 {
     try {
         if (TxtStaffName.Text != "")
         {
             FrmStaff.Staff.StaffName  = TxtStaffName.Text;
             FrmStaff.Staff.StaffPhone = TxtStaffPhone.Text;
             FrmStaff.Staff.Role       = (ERole)CmbStaffRole.SelectedIndex;
             Dispose();
         }
         else
         {
             MsgBoxUtil.ErrMsgBox("员工姓名不得为空!");
         }
     }
     catch (Exception) {
         MsgBoxUtil.ErrMsgBox("员工信息输入错误!");
     }
 }
Ejemplo n.º 18
0
        private ClsGood GetGoodFromInput()
        {
            ClsGood good = null;

            try {
                int               categoryID     = int.Parse(CmbCategoryID.SelectedItem.ToString().Split(' ')[0]);
                string            productionDate = DtpProductionID.Value.ToString("yyyyMMdd");
                double            cost           = double.Parse(TxtCost.Text);
                double            price          = TxtPrice.Text != "" ? double.Parse(TxtPrice.Text) : 0;
                int               count          = TxtCount.Text != "" ? int.Parse(TxtCount.Text) : 0;
                EState            state          = (EState)CmbIsValid.SelectedIndex;
                List <EtCategory> categories     = CategoryDao.QueryByCategoryID(categoryID);
                if (0 == count)
                {
                    MsgBoxUtil.ErrMsgBox("商品数量不能为0!");
                }
                else
                {
                    if (0 == categories.Count)
                    {
                        MsgBoxUtil.ErrMsgBox("不存在该商品!");
                    }
                    else
                    {
                        good = new ClsGood {
                            Good = new EtGood {
                                Category       = categories[0],
                                ProductionDate = productionDate,
                                Cost           = cost,
                                Price          = price,
                                State          = state
                            },
                            Count = count
                        }
                    };
                }
            }
            catch (Exception) {
                MsgBoxUtil.ErrMsgBox("非法输入!");
            }
            return(good);
        }
Ejemplo n.º 19
0
        private void ShowPurchaseDetail()
        {
            string beginDate = DtpBegin.Value.ToString("yyyyMMdd");
            string endDate   = DtpEnd.Value.ToString("yyyyMMdd");

            if (CmbCategory.SelectedIndex == 0)
            {
                purchases = PurchaseDao.QueryByPurchaseDate(beginDate, endDate);
            }
            else
            {
                ECategory parentCategoryID = (ECategory)(CmbCategory.SelectedIndex - 1);
                purchases = PurchaseDao.QueryByPurchaseDate(beginDate, endDate, parentCategoryID);
            }
            if (purchases.Count == 0)
            {
                MsgBoxUtil.ErrMsgBox("没有符合条件的记录");
            }
            DgvPurchaseDetailShow();
        }
Ejemplo n.º 20
0
        private void BtnInsert_Click(object sender, EventArgs e)
        {
            if ("".Equals(TxtStaffName.Text))
            {
                MsgBoxUtil.ErrMsgBox("员工姓名不得为空!");
                return;
            }
            string StaffName  = TxtStaffName.Text;
            string Pwd        = Encrypt.GetMD5(TxtStaffPwd.Text);
            string StaffPhone = TxtStaffPhone.Text;
            ERole  Role       = (ERole)CmbStaffRole.SelectedIndex;

            FrmStaff.Staff = new EtStaff
            {
                StaffName  = StaffName,
                Pwd        = Pwd,
                StaffPhone = StaffPhone,
                Role       = Role
            };
            Close();
        }
Ejemplo n.º 21
0
        private List <EtSale> QuerySalesFromDB()
        {
            List <EtSale> sales     = new List <EtSale>();
            string        beginDate = DtpBegin.Value.ToString("yyyyMMdd");
            string        endDate   = DtpEnd.Value.ToString("yyyyMMdd");

            if (CmbCategory.SelectedIndex != 0)
            {
                ECategory parentCategoryID = (ECategory)(CmbCategory.SelectedIndex - 1);
                sales = SaleDao.QueryBySaleDate(beginDate, endDate, parentCategoryID);
            }
            else
            {
                sales = SaleDao.QueryBySaleDate(beginDate, endDate);
            }
            if (sales.Count == 0)
            {
                MsgBoxUtil.ErrMsgBox("没有符合条件的记录");
            }
            return(sales);
        }
 private void BtnSubmit_Click(object sender, EventArgs e)
 {
     if (!hasErr)
     {
         foreach (EtSale sale in excelSales)
         {
             FrmSale.Sales.Add(sale);
         }
         Close();
     }
     else
     {
         if (hasUpdated)
         {
             MsgBoxUtil.ErrMsgBox("导入失败!");
         }
         else
         {
             MsgBoxUtil.ErrMsgBox("未导入数据!");
         }
     }
 }
Ejemplo n.º 23
0
 private void BtnDelete_Click(object sender, EventArgs e)
 {
     if (DgvCategory.SelectedRows.Count == 1)
     {
         int index = DgvCategory.SelectedRows[0].Index;
         category = categories[index];
         if (EValid.效 == category.IsValid)
         {
             if (DialogResult.OK == MsgBoxUtil.QuestionMsgBox("是否删除当前商品?"))
             {
                 CategoryDao.DeleteByCategoryID(category.CategoryID);
                 categories[index].IsValid = EValid.已删除;
                 DgvCategory.Rows[index].Cells["Column11"].Value = EValid.已删除;
                 category = null;
             }
         }
     }
     else
     {
         MsgBoxUtil.ErrMsgBox("请选择要删除的商品!");
     }
 }
Ejemplo n.º 24
0
        private void SetCategoryList()
        {
            categories.Clear();
            string beginDate = DtpBegin.Value.ToString("yyyyMMdd");
            string endDate   = DtpEnd.Value.ToString("yyyyMMdd");

            if (CmbCategory.SelectedIndex != 0)
            {
                AddCategories(beginDate, endDate, CmbCategory.SelectedIndex - 1);
            }
            else
            {
                for (int i = 0; i < 8; i++)
                {
                    AddCategories(beginDate, endDate, i);
                }
            }
            if (categories.Count == 0)
            {
                MsgBoxUtil.ErrMsgBox("没有符合条件的记录");
            }
        }
Ejemplo n.º 25
0
        private bool Save()
        {
            if (CmbOperator.SelectedIndex == -1)
            {
                MsgBoxUtil.ErrMsgBox("经办人不能为空!");
                return(false);
            }
            int res = 0;

            foreach (EtSale sale in Sales)
            {
                res += SaleDao.InsertSale(sale);
                GoodDao.UpdateGood(sale.Good);
            }
            if (res == Sales.Count)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 26
0
 private void BtnStaffUpdate_Click(object sender, EventArgs e)
 {
     if (DgvStaffData.SelectedRows.Count == 1)
     {
         int index = DgvStaffData.SelectedRows[0].Index;
         Staff = staffs[index];
         FrmStaffUpdate fsu = new FrmStaffUpdate {
             StartPosition = FormStartPosition.CenterParent
         };
         fsu.ShowDialog();
         if (Staff != null)
         {
             DgvStaffData.Rows[index].Cells["ClnStaffName"].Value  = Staff.StaffName;
             DgvStaffData.Rows[index].Cells["ClnStaffPhone"].Value = Staff.StaffPhone;
             DgvStaffData.Rows[index].Cells["ClnStaffRole"].Value  = Staff.Role;
             Staff = null;
         }
         hasUpdated = true;
     }
     else
     {
         MsgBoxUtil.ErrMsgBox("请选择要修改的员工信息!");
     }
 }
        private void BtnBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog {
                InitialDirectory = Path.GetFullPath("../../Excel模板"),
                Title            = "选择Excel文件",
                Filter           = "excel文件(*.xls,*.xlsx)|*.xls;*.xlsx|excel03文件(*.xls)|*.xls|excel07文件(*.xlsx)|*.xlsx",
                RestoreDirectory = true
            };
            string excelPath = null;

            if (DialogResult.OK == openFileDialog.ShowDialog())
            {
                excelPath         = openFileDialog.FileName;
                TxtExcelPath.Text = excelPath;
            }
            if (excelPath == null || excelPath == "")
            {
                MsgBoxUtil.ErrMsgBox("路径不能为空");
                return;
            }
            using (FileStream fs = File.OpenRead(excelPath)) {
                IWorkbook workbook = null;
                //判断Excel的格式,区分xls与xlsx
                if (Path.GetExtension(fs.Name) == ".xls")
                {
                    workbook = new HSSFWorkbook(fs);
                }
                else if (Path.GetExtension(fs.Name) == ".xlsx")
                {
                    workbook = new XSSFWorkbook(fs);
                }
                //获取工作表
                ISheet sheet = workbook.GetSheetAt(0);
                //遍历行
                for (int i = 1; i <= sheet.LastRowNum; i++)
                {
                    IRow row = sheet.GetRow(i);
                    if (row != null)
                    {
                        EtSale sale = ParseSale(row);
                        if (sale != null)
                        {
                            excelSales.Add(sale);
                            DgvSaleFromExcel.Rows.Add(new object[] {
                                "√  " + i,
                                sale.Good.GoodID,
                                sale.Good.Category.CategoryName,
                                sale.Good.Category.Unit,
                                sale.Good.Price,
                                ""
                            });
                        }
                        else
                        {
                            DgvSaleFromExcel.Rows.Add(new object[] { "×  " + i, "", "", "", "", errInfo });
                            DgvSaleFromExcel.Rows[i - 1].DefaultCellStyle.ForeColor = Color.Red;
                        }
                        hasUpdated = true;
                    }
                }
                DgvSaleFromExcel.RowsDefaultCellStyle.BackColor            = Color.LightCyan;
                DgvSaleFromExcel.AlternatingRowsDefaultCellStyle.BackColor = Color.White;
            }
        }
Ejemplo n.º 28
0
 private void BtnQuery_Click(object sender, EventArgs e)
 {
     if (TxtQuery.Text != "")
     {
         List <EtSale> subSales = new List <EtSale>();
         List <EtGood> subGoods = new List <EtGood>();
         string        query    = TxtQuery.Text;
         string        RegexStr = "^[0-9]+$";
         if (RdoSale.Checked)
         {
             if (Regex.IsMatch(query, RegexStr))
             {
                 subSales = SaleDao.QueryBySaleID(int.Parse(query));
                 if (subSales.Count == 0)
                 {
                     subSales = SaleDao.QueryByStaffID(int.Parse(query));
                 }
             }
             if (subSales.Count == 0)
             {
                 MsgBoxUtil.ErrMsgBox("未找到销售单!");
             }
             else
             {
                 subGoods = GoodDao.QueryByGoodID(subSales[0].Good.GoodID);
             }
         }
         else
         {
             if (Regex.IsMatch(query, RegexStr))
             {
                 subGoods = GoodDao.QueryByGoodID(int.Parse(query));
             }
             else
             {
                 subGoods = GoodDao.QueryByCategoryID(CategoryDao.QueryByCategoryName(query)[0].CategoryID);
             }
             if (subGoods.Count == 0)
             {
                 MsgBoxUtil.ErrMsgBox("未找到商品!");
             }
             else
             {
                 for (int i = 0; i < subGoods.Count; i++)
                 {
                     if (subGoods[i].State == Enums.EState.已出售)
                     {
                         subSales.Add(SaleDao.QueryByGoodID(subGoods[i].GoodID)[0]);
                     }
                     else
                     {
                         subGoods.RemoveAt(i);
                         i--;
                     }
                 }
             }
         }
         DgvAdd(subSales, subGoods);
     }
     else
     {
         MsgBoxUtil.ErrMsgBox("请输入查询条件!");
     }
 }