Beispiel #1
0
        private void btnAddHospital_Click(object sender, EventArgs e)
        {
            string name = txtHospitalName.Text.Trim();
            string location = txtLocation.Text.Trim();

            if (name == "" || location == "")
            {
                MessageBox.Show("Enter name and location");
                return;
            }
            else
            {
                Hospital hospital = new Hospital() { HospitalName = name, Location = location, CreatedOn = DateTime.Now };
                bool result = new MasterData().AddHospital(hospital);
                if (result)
                {
                    txtHospitalName.Text = "";
                    txtLocation.Text = "";
                    MessageBox.Show("Hospital added successfully");
                }
                else
                {
                    MessageBox.Show("Cannot add hospital : contact Admin");
                }
            }
        }
Beispiel #2
0
 public bool AddHospital(Hospital hospital)
 {
     try
     {
         entities.Hospitals.Add(hospital);
         entities.SaveChanges();
         return true;
     }
     catch (Exception x)
     {
         throw x;
     }
 }