コード例 #1
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            SqlConnection conn;

            conn = DB.getinstance();
            conn.Open();
            ClsPatient P = new ClsPatient();

            P.Patient_Name = txtName.Text;
            P.Patient_Age  = Convert.ToInt32(txtAge.Text);

            if (rdbMale.Checked == true)
            {
                P.Patient_Gender = rdbMale.Text;
            }
            else if (rdbFemale.Checked == true)
            {
                P.Patient_Gender = rdbFemale.Text;
            }

            P.Patient_BloodGroup = txtGroup.Text;
            P.Patient_Phone      = Convert.ToInt32(txtContact.Text);
            P.Patient_Address    = txtAddress.Text;
            P.Requested_Date     = Convert.ToDateTime(datetime.Text);
            P.Patient_Disease    = txtDisease.Text;
            try
            {
                P.insert();
                MessageBox.Show("Info inserted");

                dataGridView1.DataSource = new ClsPatient.PatientDAL().GetAllPAtients();
                dataGridView1.Enabled    = true;
            }
            catch (Exception)
            {
                MessageBox.Show("Kindly check your data..");
            }
            txtPatientId.Text = new ClsPatient.PatientDAL().GetPatientId();
            txtName.Text      = "";
            txtAge.Text       = "";
            txtGroup.Text     = "";
            rdbMale.Checked   = false;
            rdbFemale.Checked = false;
            txtContact.Text   = "";
            txtAddress.Text   = "";
            txtDisease.Text   = "";
        }
コード例 #2
0
        private void bttnUpdate_Click(object sender, EventArgs e)
        {
            SqlConnection conn;

            conn = DB.getinstance();
            conn.Open();
            ClsPatient Ptn = new ClsPatient();

            Ptn.Patient_Id   = Convert.ToInt32(txtId.Text);
            Ptn.Patient_Name = txtPName.Text;
            Ptn.Patient_Age  = Convert.ToInt32(txtPAge.Text);
            if (btnMale.Checked == true)
            {
                Ptn.Patient_Gender = btnMale.Text;
            }
            else if (btnFemale.Checked == true)
            {
                Ptn.Patient_Gender = btnFemale.Text;
            }
            Ptn.Patient_BloodGroup = txtBG.Text;
            Ptn.Patient_Phone      = Convert.ToInt32(txtPContact.Text);
            Ptn.Patient_Address    = txtPAddress.Text;
            Ptn.Requested_Date     = Convert.ToDateTime(date.Text);
            Ptn.Patient_Disease    = txtPDisease.Text;

            try
            {
                Ptn.update();
                MessageBox.Show("Patient Updated.");

                dataGridView1.DataSource = new ClsPatient.PatientDAL().GetAllPAtients();
                dataGridView1.Enabled    = true;
            }
            catch (Exception)
            {
                MessageBox.Show("Error");
            }
            txtId.Text        = "";
            txtPName.Text     = "";
            txtPAge.Text      = "";
            txtBG.Text        = "";
            btnMale.Checked   = false;
            btnFemale.Checked = false;
            txtPContact.Text  = "";
            txtPAddress.Text  = "";
            txtPDisease.Text  = "";
        }
コード例 #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            SqlConnection conn;

            conn = DB.getinstance();
            conn.Open();
            ClsPatient patient = new ClsPatient();

            patient.Patient_Id = Convert.ToInt32(txtDelete.Text);
            try
            {
                patient.delet();
                MessageBox.Show("Patient deleted succesffully.");
                dataGridView2.DataSource = null;

                dataGridView1.DataSource = new ClsPatient.PatientDAL().GetAllPAtients();
                dataGridView1.Enabled    = true;
            }
            catch (Exception)
            {
                MessageBox.Show("Patient Can't be deleted.");
            }
            txtDelete.Text = "";
        }