Пример #1
0
        private void pdataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string str       = ((System.Windows.Forms.DataGridView)(sender)).Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
            int    patientid = Convert.ToInt32(pdataGridView.Rows[e.RowIndex].Cells[7].Value);

            if (str == "checkout")
            {
                DialogResult dialogrslt = MessageBox.Show("Are you sure to checkout?", "Checkout", MessageBoxButtons.OKCancel);
                if (dialogrslt == DialogResult.OK)
                {
                    da.patient_checkout(patientid);
                    pdataGridView.DataSource = null;
                    pdataGridView.Rows.Clear();
                    List <Patient> plist = da.patientdatagrid();
                    foreach (var item in plist)
                    {
                        pdataGridView.Rows.Add(item.Name, item.Contactno, item.Status, item.RoomNo, "details", "edit", "checkout", item.id);
                    }
                }
                else if (dialogrslt == DialogResult.Cancel)
                {
                }
            }
            if (str == "details")
            {
                Patient patient = new Patient();
                int     roomno  = ada.getRoom(patientid);
                patient = ada.getPatientfromView(patientid);
                string rname = ada.getRec(patientid);
                detailpatientassistedlabel.Text        = rname;
                detailpatientidlabel.Text              = patientid.ToString();
                detailpatientnamelabel.Text            = patient.Name;
                detailpatientaddresslabel.Text         = patient.Address;
                detailpatientgenderlabel.Text          = patient.Gender;
                detailpatientdoblabel.Text             = patient.DOB.ToString();
                detailpatientcontactlabel.Text         = patient.Contactno.ToString();
                detailpatientstatuslabel.Text          = patient.Status;
                detailpatientroomlabel.Text            = roomno.ToString();
                detailpatientconditionlabel.Text       = patient.Condition;
                detailpatientadmitdatelabel.Text       = patient.Admitdate.ToString();
                detailpatientreleasedatedatelabel.Text = patient.Releasedate.ToString();
                rtabControl.SelectedTab = patientdetailtab;
            }
            if (str == "edit")
            {
                Patient patient = new Patient();
                patient = ada.getPatientbyId(patientid);
                editpatientnametextBox.Text = patient.Name;
                editpatientaddresscomboBox.Items.Clear();
                editpatientaddresscomboBox.Text = "";
                List <string> addresslist = new List <string>();
                addresslist = da.addresscombo();
                foreach (var address in addresslist)
                {
                    editpatientaddresscomboBox.Items.Add(address);
                }
                editpatientaddresscomboBox.SelectedItem = patient.Address;
                editpatientcontacttextBox.Text          = patient.Contactno.ToString();
                editpatientdobdateTimePicker.Text       = patient.DOB.ToString();
                editpatientidlabel.Text = patientid.ToString();
                if (patient.Gender == "Male")
                {
                    editpatientmaleradioButton.Checked = true;
                }
                else if (patient.Gender == "Female")
                {
                    editpatientfemaleradioButton.Checked = true;
                }
                rtabControl.SelectedTab = patientedittab;
            }
        }