Ejemplo n.º 1
0
 private void llAdd_Clicked(object sender, EventArgs e)
 {
     using (供应商编辑 mForm = new 供应商编辑())
     {
         if (mForm.ShowDialog() == DialogResult.OK)
         {
             InitDaGoodsSupplier();
         }
     }
 }
        private void dgvDaSupplier_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            if (e.ColumnIndex == dsc删除.Index)
            {
                //删除
                int        daSupplierId = ((DaSupplier)DaSupplierBindingSource[e.RowIndex]).IntID;
                DaSupplier mDaSupplier  = myEntity.DaSuppliers.SingleOrDefault(a => a.IntID == daSupplierId);
                if (mDaSupplier.DaPurchaseContracts.Count > 0)
                {
                    MessageBox.Show("该物品已有采购订单,不能删除");
                    return;
                }
                if (MessageBox.Show("是否确认删除" + mDaSupplier.VcName, "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
                {
                    return;
                }
                //myEntity.DaSuppliers.Attach(mDaSupplier);
                mDaSupplier.DaGoodsSuppliers.Clear();
                myEntity.DaSuppliers.Remove(mDaSupplier);

                int ret = myEntity.SaveChanges();

                if (ret > 0)
                {
                    InitDaGoodsSupplier();
                    MessageBox.Show("删除成功");
                }
                else
                {
                    MessageBox.Show("删除失败");
                }
            }
            if (e.ColumnIndex == dsc修改.Index)
            {
                //修改
                using (供应商编辑 mForm = new 供应商编辑())
                {
                    mForm.DaSupplierID = ((DaSupplier)DaSupplierBindingSource[e.RowIndex]).IntID;

                    if (mForm.ShowDialog() == DialogResult.OK)
                    {
                        InitDaGoodsSupplier();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void dgvDaSupplier_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            //if (e.ColumnIndex == dsc删除.Index)
            //{
            //    //删除
            //    DaSupplier mDaSupplier = (DaSupplier)DaSupplierBindingSource[e.RowIndex];
            //    if (mDaSupplier.DaPurchaseContracts.Count > 0)
            //    {
            //        MessageBox.Show("该物品已有采购订单,不能删除");
            //        return;
            //    }
            //    if (MessageBox.Show("是否确认删除" + mDaSupplier.VcName, "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            //        return;
            //    myEntity.DaSuppliers.Remove(mDaSupplier);

            //    int ret = myEntity.SaveChanges();

            //    if (ret > 0)
            //    {
            //        MessageBox.Show("删除成功");
            //        InitDaGoodsSupplier();
            //    }
            //    else
            //    {
            //        MessageBox.Show("删除失败");
            //    }
            //}
            if (e.ColumnIndex == ds修改.Index)
            {
                //修改
                using (供应商编辑 mForm = new 供应商编辑())
                {
                    mForm.DaSupplierID = ((DaSupplier)DaSupplierBindingSource[e.RowIndex]).IntID;

                    if (mForm.ShowDialog() == DialogResult.OK)
                    {
                        InitDaGoodsSupplier();
                    }
                }
            }
        }
 private void llAdd_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (dgvDaGoods.SelectedRows.Count < 1)
     {
         MessageBox.Show("请选择采购物品");
         return;
     }
     using (供应商编辑 mForm = new 供应商编辑())
     {
         mForm.DaGoodsID = ((DaGoods)DaGoodsBindingSource[dgvDaGoods.SelectedRows[0].Index]).IntID;
         //mForm.myEntity = myEntity;
         if (mForm.ShowDialog() == DialogResult.OK)
         {
             //增加成功,刷新列表
             //((System.Data.Entity.Infrastructure.IObjectContextAdapter)myEntity).ObjectContext.Refresh(System.Data.Objects.RefreshMode.StoreWins, myEntity.DaSuppliers);
             //((System.Data.Entity.Infrastructure.IObjectContextAdapter)myEntity).ObjectContext.AcceptAllChanges();
             InitDaGoodsSupplier();
             //dgvDaGoods_SelectionChanged(sender, e);
         }
     }
 }