Exemple #1
0
        private void button22_Click(object sender, EventArgs e)
        {
            token token = new token(richTextBox1.Text);

            token.Show();
        }
Exemple #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                int      count = 0;
                string   date  = dateTimePicker1.Text;
                DateTime d     = DateTime.ParseExact(date, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                string   dd    = d.ToString("yyyy/MM/dd");
                db.sql.Close();
                db.sql.Open();
                SqlCommand    comand = new SqlCommand("select * from appointment where reg_no='" + richTextBox1.Text + "' and date='" + dd + "'", db.sql);
                SqlDataReader reader = comand.ExecuteReader();
                while (reader.Read())
                {
                    count++;
                }
                if (count > 0)
                {
                    MessageBox.Show("Appointment already Taken");
                }
                else
                {
                    try
                    {
                        if (richTextBox1.Text == "" || richTextBox2.Text == "" || richTextBox3.Text == "" || richTextBox4.Text == "" || comboBoxEx3.Text == "" || dateTimePicker1.Text == "" || comboBoxEx1.Text == "" || richTextBox6.Text == "")
                        {
                            MessageBox.Show("Provide all the information");
                        }
                        else
                        {
                            DialogResult r = MessageBox.Show("Do you want to save it ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            if (r == DialogResult.Yes)
                            {
                                int fees = Convert.ToInt32(richTextBox6.Text);
                                db.sql.Close();
                                db.sql.Open();
                                int           c     = 0;
                                SqlCommand    check = new SqlCommand("select reg_no from symptoms where reg_no='" + richTextBox1.Text + "'", db.sql);
                                SqlDataReader read  = check.ExecuteReader();
                                while (read.Read())
                                {
                                    c++;
                                }

                                db.sql.Close();
                                db.sql.Open();
                                SqlCommand cmd  = new SqlCommand("insert into appointment(reg_no,name,address,age,sex,referance,date,doctor,fees,weight)values(N'" + richTextBox1.Text + "',N'" + richTextBox2.Text + "',N'" + richTextBox3.Text + "',N'" + richTextBox4.Text + "',N'" + comboBoxEx3.Text + "',N'" + richTextBox5.Text + "',N'" + dd + "',N'" + comboBoxEx1.Text + "',N'" + fees + "',N'" + richTextBox47.Text + "')", db.sql);
                                SqlCommand cmd2 = new SqlCommand("insert into symptoms(reg_no)values('" + richTextBox1.Text + "')", db.sql);
                                SqlCommand cmd3 = new SqlCommand("insert into patient_test(reg_no)values('" + richTextBox1.Text + "')", db.sql);
                                SqlCommand cmd4 = new SqlCommand("insert into advice(reg_no)values('" + richTextBox1.Text + "')", db.sql);
                                SqlCommand cmd5 = new SqlCommand("insert into diagnosis(reg_no)values('" + richTextBox1.Text + "')", db.sql);
                                int        x    = cmd.ExecuteNonQuery();



                                if (c > 0)
                                {
                                }
                                else
                                {
                                    cmd2.ExecuteNonQuery();
                                    cmd3.ExecuteNonQuery();
                                    cmd4.ExecuteNonQuery();
                                    cmd5.ExecuteNonQuery();
                                }


                                if (x > 0)
                                {
                                    MessageBox.Show("Data Inserted Successfully");
                                    token token = new token(richTextBox1.Text);
                                    token.Show();
                                }
                                else
                                {
                                    MessageBox.Show("Data not Inserted");
                                }
                                db.sql.Close();
                                show_appointment();
                            }
                            else
                            {
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
            }
            catch
            {
            }
        }