protected void Button7_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); ds = objb.getdiagnosis_byopdcode(Session["opd_code"].ToString()); DataClassesDataContext rt = new DataClassesDataContext(); palm_opd_diagnosis_master pom = new palm_opd_diagnosis_master(); if (ds.Tables[0].Rows.Count == 0) { pom.pateint_code = Session["pateint_code"].ToString(); pom.opd_code = Session["opd_code"].ToString(); pom.inserted_by = Session["emp_code"].ToString(); pom.inserted_on = DateTime.Now; rt.palm_opd_diagnosis_masters.InsertOnSubmit(pom); rt.SubmitChanges(); palm_opd_provisional_diagnosi pod = new palm_opd_provisional_diagnosi(); pom = rt.palm_opd_diagnosis_masters.Single(palm_opd_diagnosis_master => palm_opd_diagnosis_master.opd_code == Session["opd_code"].ToString()); pod.master_id = pom.opd_diagnosis_master_id; pod.opd_code = pom.opd_code; pod.pro_diagnosis = TextBox4.Text; pod.pro_remark = TextBox5.Text; rt.palm_opd_provisional_diagnosis.InsertOnSubmit(pod); rt.SubmitChanges(); } else { palm_opd_provisional_diagnosi pod = new palm_opd_provisional_diagnosi(); pom = rt.palm_opd_diagnosis_masters.Single(palm_opd_diagnosis_master => palm_opd_diagnosis_master.opd_code == Session["opd_code"].ToString()); pod.master_id = pom.opd_diagnosis_master_id; pod.opd_code = pom.opd_code; pod.pro_diagnosis = TextBox4.Text; pod.pro_remark = TextBox5.Text; rt.palm_opd_provisional_diagnosis.InsertOnSubmit(pod); rt.SubmitChanges(); } BindData(); }