public string insert() { try { HospitalManagementEntity context = new HospitalManagementEntity(); Medicine_details m = new Medicine_details(); m.Name = name; m.price = price; m.Quantity = quantity; m.Mfg_date = date1; m.Expiry_date = date2; context.Medicine_details.Add(m); context.SaveChanges(); return m.Medicine_Id.ToString(); } catch (Exception e) { return "All Values are required"; } }
public string update(string Patient_id, string name, string price, string e_date, string m_date, string quantity) { try { HospitalManagementEntity context = new HospitalManagementEntity(); Medicine_details u = context.Medicine_details.Find(Convert.ToInt32(Patient_id)); u.Mfg_date = Convert.ToDateTime( m_date); u.Medicine_Id = Convert.ToInt32(Patient_id); u.Name = name; u.Expiry_date = Convert.ToDateTime(e_date); u.price = Convert.ToInt32(price); u.Quantity = Convert.ToInt32(quantity); context.Entry(u).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return "Updation Successfull"; } catch (Exception e) { return "Can't Update Record Id's"; } }