Пример #1
0
        private void deletePO_Product(PO po)
        {
            List <PO_Product> poProductList = BLPO_Product.GetPO_ProductByPOId(APCContext, po.Id);

            for (int i = 0; i < poProductList.Count(); i++)
            {
                int poProductId = 0;
                int.TryParse(poProductList[i].Id.ToString(), out poProductId);
                PO_Product currentPO_Product = BLPO_Product.GetPO_ProductById(APCContext, poProductId);
                if (currentPO_Product != null)
                {
                    APCContext.DeleteObject(currentPO_Product);
                    APCContext.SaveChanges();
                }
            }
        }
Пример #2
0
        public List <PO> searchById(int id)
        {
            if (id != 0)
            {
                List <PO> poList = BLPO.GetPOListById(APCContext, id);

                if (poList != null)
                {
                    tbId.Text = poList[0].Id.ToString();
                    cbSupplier.SelectedValue = poList[0].Supplier.Id;
                    cbProject.SelectedValue  = poList[0].Project.Id;
                    List <PO_Product> poProductList = BLPO_Product.GetPO_ProductByPOId(APCContext, id);
                    dgPOProduct.DataSource = createPO_ProductTableFromList(poProductList);

                    dgPOProduct.Columns.Remove("Name");
                    dgPOProduct.Columns.Remove("SubCon");

                    DataGridViewComboBoxColumn colName = BLHelper.ReturnDataGridComboBoxColumn("Name", "Name", "Name", "Name");
                    colName.DataSource = APCContext.Category;

                    DataGridViewCheckBoxColumn colSubCon = BLHelper.ReturnDataGridCBColumn("SubCon");

                    dgPOProduct.Columns.Insert(0, colName);
                    dgPOProduct.Columns.Add(colSubCon);

                    return(poList);
                }
                else
                {
                    MessageBox.Show("PO Id not found");
                }
            }
            else
            {
                MessageBox.Show("PO Id not found");
            }
            return(null);
        }