protected void btnAddDetail_Click(object sender, EventArgs e) { try { tPurchaseDetail detail = new tPurchaseDetail { PurchaseDetailAmount = GetDecimal(txtAmount.Text), PurchaseDetailDate = DateTime.Now, PurchaseDetailCostElementCode = ddlCostElement.SelectedValue, PurchaseDetailDescription = txtDescription.Text.Trim(), PurchaseDetailPurchaseId = m_nPurchaseId }; if (detail != null) { m_db.tPurchaseDetails.InsertOnSubmit(detail); m_db.SubmitChanges(); gridPurchaseOrderDetails.DataBind(); // Clear the form txtAmount.Text = ""; txtDescription.Text = ""; ddlCostElement.SelectedIndex = 0; lblError.Text = ""; } } catch (Exception ex) { lblError.Text = ex.Message; } }
protected void btnAddDetail_Click(object sender, EventArgs e) { try { Int32 nPurchaseId = 0; if (gridPurchases.SelectedDataKey != null) { nPurchaseId = Convert.ToInt32(gridPurchases.SelectedDataKey.Value.ToString()); } if (nPurchaseId > 0) { tPurchaseDetail detail = new tPurchaseDetail { PurchaseDetailAmount = 0.0m, PurchaseDetailCostElementCode = "201.0", PurchaseDetailDescription = "Enter Description", PurchaseDetailPurchaseId = nPurchaseId }; m_db.tPurchaseDetails.InsertOnSubmit(detail); m_db.SubmitChanges(); gridPurchases.DataBind(); // Now, modify the purchase order email flag SetPurchaseOrderEmailFlag(nPurchaseId, false); } } catch (Exception ex) { lblError.Text = ex.Message; } }