示例#1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int i = e.RowIndex;

            //MessageBox.Show(i.ToString());
            if (i >= 0)
            {
                dataGridView2.Rows.Clear();
                //string query = "SELECT opd.opd, opd.patient_id, patients.name, patients.dob, patients.gender, opd.doctor, patients.category, patients.family_head, opd.symptoms, opd.remarks, opd.medicine_id, opd.medicines, opd.dosage, opd.quantity, opd.storemedicine_id, opd.storequantity FROM opd INNER JOIN patients ON opd.patient_id=patients.patient_id WHERE opd.opd="+opd;
                dbconnect db  = new dbconnect();
                opd       opd = new opd();
                opd.loadOPDDetails(dataGridView1.Rows[i].Cells[0].Value.ToString(), db);
                if (opd.dr.Read())
                {
                    textBox8.Text  = opd.dr[0].ToString();
                    textBox10.Text = opd.dr[1].ToString();
                    textBox9.Text  = opd.dr[2].ToString();
                    int age = DateTime.Today.Year - Convert.ToInt32(opd.dr[3].ToString().Substring(0, 4));
                    if (Convert.ToInt32(opd.dr[3].ToString().Substring(5, 2)) > DateTime.Today.Month)
                    {
                        age--;
                    }
                    textBox1.Text  = age.ToString();
                    textBox2.Text  = opd.dr[4].ToString();
                    textBox5.Text  = opd.dr[5].ToString();
                    textBox3.Text  = opd.dr[6].ToString();
                    textBox4.Text  = opd.dr[7].ToString();
                    textBox6.Text  = opd.dr[8].ToString();
                    textBox13.Text = opd.dr[9].ToString();
                    medicinesID    = new string[0];
                    medicines      = new string[0];
                    dosage         = new string[0];
                    qty            = new string[0];
                    medicinesID    = opd.dr[10].ToString().Split(',');
                    medicines      = opd.dr[11].ToString().Split(',');
                    dosage         = opd.dr[12].ToString().Split(',');
                    qty            = opd.dr[13].ToString().Split(',');
                    if (opd.dr[14].ToString() != "")
                    {
                        medicinesIDStore = opd.dr[14].ToString().Split(',');
                        qtyStore         = opd.dr[15].ToString().Split(',');
                    }
                    for (int q = 0; q < medicinesID.Length; q++)
                    {
                        dataGridView2.Rows.Add(medicinesID[q], medicines[q], qty[q], dosage[q]);
                    }
                    dataGridView2.ClearSelection();
                    issuedLP = medicinesID.Contains("LP");
                }
                db.dbclose();
            }
        }