public bool AddLabInvestigation(LabInvestigation labinvestigation) { try { entities.LabInvestigations.Add(labinvestigation); entities.SaveChanges(); return true; } catch (Exception x) { throw x; } }
private void btnAddInvestigation_Click(object sender, EventArgs e) { string name = txtInvestigationName.Text.Trim(); string value = txtInvestigationValue.Text.Trim(); if (name == "" || value == "") { MessageBox.Show("Enter name and value"); return; } else { LabInvestigation labinvestigation = new LabInvestigation () { LabInvestigationName = name, NormalValue = value, CreatedOn = DateTime.Now }; bool result = new MasterData().AddLabInvestigation(labinvestigation); if (result) { txtInvestigationName.Text = ""; txtInvestigationValue.Text = ""; MessageBox.Show("Lab Investigation added successfully"); } else { MessageBox.Show("Cannot add Lab Investigation : contact Admin"); } } }