Exemplo n.º 1
0
        public void deleteDoctor(doctorDTO d)
        {
            s.sqlConnection.Open();
            string query = "delete from doctors where doctorId = '" + d.DoctorId + "'";

            s.sqlCommand = new SqlCommand(query, s.sqlConnection);
            s.sqlCommand.ExecuteNonQuery();
            s.sqlConnection.Close();
        }
        private void doctorDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            bool blank = false;

            if (doctorDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString() == "")
            {
                blank = true;
            }
            if (doctorDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString() == "")
            {
                blank = true;
            }
            if (doctorDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString() == "")
            {
                blank = true;
            }
            if (doctorDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString() == "")
            {
                blank = true;
            }
            if (doctorDataGridView.Rows[e.RowIndex].Cells[4].Value.ToString() == "")
            {
                blank = true;
            }
            if (doctorDataGridView.Rows[e.RowIndex].Cells[5].Value.ToString() == "")
            {
                blank = true;
            }
            if (doctorDataGridView.Rows[e.RowIndex].Cells[6].Value.ToString() == "")
            {
                blank = true;
            }
            if (doctorDataGridView.Rows[e.RowIndex].Cells[7].Value.ToString() == "")
            {
                blank = true;
            }

            if (blank)
            {
                loadDoctorsInfo();
                return;
            }


            int    doctorId     = Convert.ToInt32(doctorDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString());
            string name         = doctorDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString();
            string age          = doctorDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString();
            string gender       = doctorDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString();
            string degree       = doctorDataGridView.Rows[e.RowIndex].Cells[4].Value.ToString();
            string specialistIn = doctorDataGridView.Rows[e.RowIndex].Cells[5].Value.ToString();
            string phone        = doctorDataGridView.Rows[e.RowIndex].Cells[6].Value.ToString();
            string salary       = doctorDataGridView.Rows[e.RowIndex].Cells[7].Value.ToString();

            d = new doctorDTO(doctorId, name, age, gender, degree, specialistIn, phone, salary);
            dD.updateDoctor(d);
            loadDoctorsInfo();
        }
        private void doctorDataGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            int    doctorId     = Convert.ToInt32(doctorDataGridView.Rows[e.Row.Index].Cells[0].Value.ToString());
            string name         = doctorDataGridView.Rows[e.Row.Index].Cells[1].Value.ToString();
            string age          = doctorDataGridView.Rows[e.Row.Index].Cells[3].Value.ToString();
            string gender       = doctorDataGridView.Rows[e.Row.Index].Cells[2].Value.ToString();
            string degree       = doctorDataGridView.Rows[e.Row.Index].Cells[4].Value.ToString();
            string specialistIn = doctorDataGridView.Rows[e.Row.Index].Cells[5].Value.ToString();
            string phone        = doctorDataGridView.Rows[e.Row.Index].Cells[6].Value.ToString();
            string salary       = doctorDataGridView.Rows[e.Row.Index].Cells[7].Value.ToString();

            d = new doctorDTO(doctorId, name, age, gender, degree, specialistIn, phone, salary);
        }
Exemplo n.º 4
0
        private void addButton_Click(object sender, EventArgs e)
        {
            string    name         = nameBox.Text;
            string    age          = ageBox.Text;
            string    gender       = genderBox.Text;
            string    degree       = DegreeBox.Text;
            string    specialistIn = specialistBox.Text;
            string    phone        = phoneBox.Text;
            string    salary       = salaryBox.Text;
            doctorDTO d            = new doctorDTO(name, age, gender, degree, specialistIn, phone, salary);
            doctorDAO dD           = new doctorDAO();

            dD.createDoctor(d);
            clearFields();
        }
Exemplo n.º 5
0
        public void createDoctor(doctorDTO d)
        {
            s.sqlConnection.Open();
            string query = "insert into doctors(name,gender,age,phone,degree,specialistIn,salary) values('" + d.Name + "','"
                           + d.Gender + "','"
                           + d.Age + "','"
                           + d.Phone + "','"
                           + d.Degree + "','"
                           + d.SpecialistIn + "','"
                           + d.Salary + "')";

            s.sqlCommand = new SqlCommand(query, s.sqlConnection);
            s.sqlCommand.ExecuteNonQuery();
            s.sqlConnection.Close();
        }
Exemplo n.º 6
0
        public void updateDoctor(doctorDTO d)
        {
            s.sqlConnection.Open();
            string query = "update doctors set name = '"
                           + d.Name + "', gender = '"
                           + d.Gender + "', age = '"
                           + d.Age + "', phone = '"
                           + d.Phone + "', degree = '"
                           + d.Degree + "', specialistIn = '"
                           + d.SpecialistIn + "', salary = '"
                           + d.Salary + "' where doctorId = '"
                           + d.DoctorId + "' ";

            s.sqlCommand = new SqlCommand(query, s.sqlConnection);
            s.sqlCommand.ExecuteNonQuery();
            s.sqlConnection.Close();
        }
        private void deleteButton_Click(object sender, EventArgs e)
        {
            if (doctorDataGridView.SelectedRows.Count == 0)
            {
                MessageBox.Show("Select a row from table");
                return;
            }
            int idx = doctorDataGridView.SelectedRows[0].Index;

            int    doctorId     = Convert.ToInt32(doctorDataGridView.Rows[idx].Cells[0].Value.ToString());
            string name         = doctorDataGridView.Rows[idx].Cells[1].Value.ToString();
            string age          = doctorDataGridView.Rows[idx].Cells[3].Value.ToString();
            string gender       = doctorDataGridView.Rows[idx].Cells[2].Value.ToString();
            string degree       = doctorDataGridView.Rows[idx].Cells[4].Value.ToString();
            string specialistIn = doctorDataGridView.Rows[idx].Cells[5].Value.ToString();
            string phone        = doctorDataGridView.Rows[idx].Cells[6].Value.ToString();
            string salary       = doctorDataGridView.Rows[idx].Cells[7].Value.ToString();

            d = new doctorDTO(doctorId, name, age, gender, degree, specialistIn, phone, salary);
            dD.deleteDoctor(d);
            loadDoctorsInfo();
        }