private void btnNew_Click(object sender, EventArgs e)
        {
            var existFrm = GetForm(frmWarehouseOutName);

            if (existFrm != null)
            {
                existFrm.Close();
            }
            FrmWarehouseOut frm = new FrmWarehouseOut();

            frm.MdiParent = this.MdiParent;
            frm.Show();
        }
        private void gridWarehouse_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = Convert.ToInt32(gridWarehouse.Rows[e.RowIndex].Cells[0].Value);

            if (e.ColumnIndex == gridWarehouse.Columns.Count - 1)
            {
                if (MessageBox.Show("确定要删除此数据?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    try
                    {
                        var items      = entities.WarehouseOutItem.Where(item => item.WarehouseOut_Id == id).ToList();
                        var productIds = items.Select(p => p.Product_Id).ToList();
                        var products   = entities.Product.Where(p => productIds.Contains(p.Id)).ToList();
                        using (TransactionScope scope = new TransactionScope())
                        {
                            foreach (var item in items)
                            {
                                var product = products.First(p => p.Id == item.Product_Id);
                                product.StockQuantity = product.StockQuantity + item.Quantity;
                                entities.Save <Product>(product);
                            }
                            entities.Delete <WarehouseOut>(id);
                            scope.Complete();
                        }
                    }
                    catch (Exception exp)
                    {
                        MessageBox.Show("数据删除失败!", "提示");
                        LogHelper.WriteLog(LogType.Error, exp, this.GetType());
                    }
                    DataBind();
                }
            }
            if (e.ColumnIndex == gridWarehouse.Columns.Count - 2)
            {
                var existFrm = GetForm(frmWarehouseOutName);
                if (existFrm != null)
                {
                    existFrm.Close();
                }
                FrmWarehouseOut frm = new FrmWarehouseOut();
                frm.MdiParent      = this.MdiParent;
                frm.WarehouseOutId = id;
                frm.Show();
            }
        }