private void update_btn_Click(object sender, RoutedEventArgs e) { if (billselected == null) { return; } billselected = (Bill)dataGrid_Patients_Bill.SelectedItem; String pname = patname_bill.Text; String ptype = patient_type.Text; double totalbil; double medchrg; double docchrg; if (ptype.Equals("outdoor")) { billselected.no_of_days = null; billselected.room_charge = null; medchrg = double.Parse(medchrge_bill.Text); docchrg = double.Parse(pat_docchrg.Text); totalbil = medchrg + docchrg; this.totalbill_bill.Text = totalbil.ToString(); } else { int nod = int.Parse(noofday_bill.Text); int roomchrg = int.Parse(roomchrg_bill.Text); billselected.no_of_days = nod; billselected.room_charge = roomchrg; medchrg = double.Parse(medchrge_bill.Text); docchrg = double.Parse(pat_docchrg.Text); totalbil = medchrg + docchrg + (nod * roomchrg); this.totalbill_bill.Text = totalbil.ToString(); } billselected.pat_name = pname; billselected.pat_type = ptype; billselected.med_charge = medchrg; billselected.doctor_charge = docchrg; billselected.total_bill = totalbil; hmsfac.updateBill(billselected); dataGrid_Patients_Bill.Items.Refresh(); }