Example #1
0
 private void saveButton_Click(object sender, EventArgs e)
 {
     Doctor doctor=new Doctor();
     doctor.Name = nameTextBox.Text;
     doctor.DepartmentId = int.Parse(departmentComboBox.SelectedValue.ToString());
     doctor.Id = idforSearch;
     DoctorManager doctorManager=new DoctorManager();
     if (saveButton.Text == "Update")
     {
         bool status = doctorManager.Update(doctor);
         if (status)
         {
             Close();
             MessageBox.Show("Updated Successfully");
         }
         else
         {
             MessageBox.Show("Not updated");
         }
     }
     else if (doctorManager.Save(doctor))
     {
         Close();
         MessageBox.Show("Doctor Successfully Added");
     }
 }
Example #2
0
 public bool Update(Doctor doctor)
 {
     if (doctor.Name == "")
     {
         MessageBox.Show("Name cannot be empty");
         return false;
     }
     else
     {
         return doctorGateway.Update(doctor);
     }
 }
Example #3
0
 public Doctor GetDoctorByPatientId(int patientId)
 {
     string connectionString = ConfigurationManager.ConnectionStrings["HospitalConnectionString"].ConnectionString;
     SqlConnection sqlConnection = new SqlConnection(connectionString);
     string query = "SELECT * FROM PatientDoctorView WHERE Id='" + patientId + "'";
     SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);
     sqlConnection.Open();
     SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
     Doctor doctor=new Doctor();
     while (sqlDataReader.Read())
     {
         doctor.Id = int.Parse(sqlDataReader["DoctorId"].ToString());
         doctor.Name = sqlDataReader["DoctorName"].ToString();
     }
     return doctor;
 }
Example #4
0
 public List<Doctor> GetDoctorList()
 {
     string connectionString = ConfigurationManager.ConnectionStrings["HospitalConnectionString"].ConnectionString;
     SqlConnection sqlConnection = new SqlConnection(connectionString);
     string query = "SELECT * FROM DoctorTable";
     SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);
     sqlConnection.Open();
     SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
     List<Doctor> doctorList = new List<Doctor>();
     while (sqlDataReader.Read())
     {
         Doctor doctor = new Doctor();
         doctor.Id = int.Parse(sqlDataReader["Id"].ToString());
         doctor.Name = sqlDataReader["Name"].ToString();
         doctorList.Add(doctor);
     }
     return doctorList;
 }
Example #5
0
        public Doctor GetDoctorById(int doctorId)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["HospitalConnectionString"].ConnectionString;
            SqlConnection sqlConnection = new SqlConnection(connectionString);
            string query = "SELECT * FROM DoctorTable WHERE Id='"+doctorId+"'";
            SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);
            sqlConnection.Open();
            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
            Model.Doctor aDoctor = new Doctor();

            while (sqlDataReader.Read())
            {
                aDoctor.Id = int.Parse(sqlDataReader["Id"].ToString());
                aDoctor.Name = sqlDataReader["Name"].ToString();
                aDoctor.DepartmentId = int.Parse(sqlDataReader["DepartmentId"].ToString());
            }
            sqlDataReader.Close();
            sqlConnection.Close();
            return aDoctor;
        }
Example #6
0
        public DoctorEntryForm(string mode,int doctorId)
        {
            InitializeComponent();
            if (mode == "Update")
            {
                //MessageBox.Show(doctorId.ToString());
                Doctor aDoctor=new Doctor();
                BLL.DoctorManager manager=new DoctorManager();
                aDoctor = manager.GetDoctorById(doctorId);

                idforSearch = aDoctor.Id;

                nameTextBox.Text = aDoctor.Name;
                GetDepartmentsInComboBox();
                departmentComboBox.SelectedValue=aDoctor.DepartmentId;
                saveButton.Text = "Update";

            }
            else
            {
                GetDepartmentsInComboBox();
            }
        }
Example #7
0
 public bool Save(Doctor doctor)
 {
     string connectionString = ConfigurationManager.ConnectionStrings["HospitalConnectionString"].ConnectionString;
     SqlConnection sqlConnection = new SqlConnection(connectionString);
     string query = "INSERT INTO DoctorTable (Name,DepartmentId) VALUES('" + doctor.Name + "','"+doctor.DepartmentId+"')";
     SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);
     sqlConnection.Open();
     int row = sqlCommand.ExecuteNonQuery();
     sqlConnection.Close();
     if (row == 1)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Example #8
0
 public bool Update(Doctor doctor)
 {
     string connectionString = ConfigurationManager.ConnectionStrings["HospitalConnectionString"].ConnectionString;
     SqlConnection sqlConnection = new SqlConnection(connectionString);
     string query = "UPDATE DoctorTable SET Name='" + doctor.Name + "',DepartmentId='" + doctor.DepartmentId + "' WHERE Id='"+doctor.Id+"' ";
     SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);
     sqlConnection.Open();
     int row = sqlCommand.ExecuteNonQuery();
     sqlConnection.Close();
     if (row == 1)
     {
         return true;
     }
     else
     {
         return false;
     }
 }