private void ddlPO_SelectedIndexChanged(object sender, EventArgs e) { if (ddlPO.SelectedItem != null) { tbPaymentDue.Text = BLPO_Product.GetTotalPO_ProductByPOId(APCContext, ((PO)ddlPO.SelectedItem).Id).ToString("N"); } }
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(); } } }
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); }
private void insertPO_Product(PO PO) { DataTable dt = (DataTable)dgPOProduct.DataSource; for (int i = 0; i < dt.Rows.Count; i++) { int quantity = 0; decimal price = 0; decimal totalPrice = 0; decimal serviceCharge = 0; bool subCon = false; string description = dt.Rows[i]["Description"].ToString(); string categoryName = dt.Rows[i]["Name"].ToString(); //Category selectedCategory = BLCategory.GetCategoryById(APCContext, categoryId); Category selectedCategory = BLCategory.GetCategoryByExactName(APCContext, categoryName); int.TryParse(dt.Rows[i]["Quantity"].ToString(), out quantity); decimal.TryParse(dt.Rows[i]["Price"].ToString(), out price); decimal.TryParse(dt.Rows[i]["Total"].ToString(), out totalPrice); decimal.TryParse(dt.Rows[i]["ServiceCharge"].ToString(), out serviceCharge); bool.TryParse(dt.Rows[i]["SubCon"].ToString(), out subCon); BLPO_Product.insertPO_Product(APCContext, PO, selectedCategory, description, quantity, price, serviceCharge, totalPrice, subCon); } }