コード例 #1
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();
                db.sql.Close();
                db.sql.Open();
                SqlCommand    comand = new SqlCommand("select * from appointment where reg_no='" + richTextBox1.Text + "' and date='" + date + "'", db.sql);
                SqlDataReader reader = comand.ExecuteReader();
                while (reader.Read())
                {
                    count++;
                }
                if (count > 0)
                {
                    MessageBox.Show("Appointment already Taken");
                }
                else
                {
                    try
                    {
                        int x = 0;
                        if (string.IsNullOrEmpty(comboBoxEx1.Text))
                        {
                            MessageBox.Show("Please Select Doctor!!!");
                        }
                        else if (string.IsNullOrEmpty(richTextBox6.Text))
                        {
                            MessageBox.Show("Valid Doctor Fees is Required!!!");
                        }
                        else if (string.IsNullOrEmpty(richTextBox1.Text))
                        {
                            MessageBox.Show("Valid Appointment No is Required.");
                        }
                        else if (string.IsNullOrEmpty(richTextBox2.Text))
                        {
                            MessageBox.Show("Patient Name is Required!!!");
                        }
                        else if (string.IsNullOrEmpty(richTextBox3.Text))
                        {
                            MessageBox.Show("Address is Required!!!");
                        }
                        else if (string.IsNullOrEmpty(richTextBox4.Text))
                        {
                            MessageBox.Show("Valid Age is Required!!!");
                        }
                        else if (string.IsNullOrEmpty(comboBoxEx3.Text))
                        {
                            MessageBox.Show("Gender is Required!!!");
                        }
                        else if (string.IsNullOrEmpty(dateTimePicker1.Text))
                        {
                            MessageBox.Show("Appointment Date is Required!!!");
                        }
                        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++;
                                }
                                File.Copy(txtImageTitle.Text, Path.Combine(@"E:\Upload", Path.GetFileName(txtImageTitle.Text)), true);
                                pathString = @"E:\Upload\" + Path.GetFileName(txtImageTitle.Text);
                                db.sql.Close();
                                db.sql.Open();
                                if (label101.Visible == true)
                                {
                                    SqlCommand cmd1 = new SqlCommand("insert into appointment(reg_no,name,address,age,sex,referance,date,doctor,fees,weight,card_id,card_type,hospital_id,image)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 + "','" + richTextBox27.Text + "','F',N'" + richTextBox8.Text + "',N'" + pathString + "')", db.sql);
                                    x = cmd1.ExecuteNonQuery();
                                }
                                else
                                {
                                    SqlCommand cmd = new SqlCommand("insert into appointment(reg_no,name,address,age,sex,referance,date,doctor,fees,weight,card_id,card_type,hospital_id,image)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 + "','" + richTextBox27.Text + "','P',N'" + richTextBox8.Text + "',N'" + pathString + "')", db.sql);
                                    x = cmd.ExecuteNonQuery();
                                }
                                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);
                                SqlCommand cmd6 = new SqlCommand("insert into user_cash_collection_doctor(user_name,password,reg_no,name,paid,date,date2)values('" + user_name + "','" + password + "','" + richTextBox1.Text + "','" + richTextBox2.Text + "','" + richTextBox6.Text + "','" + date + "','" + dd + "')", db.sql);

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


                                if (x > 0)
                                {
                                    MessageBox.Show("Data Inserted Successfully");
                                    token token = new token(richTextBox1.Text);
                                    token.Show();
                                    CLearAllField();
                                }
                                else
                                {
                                    MessageBox.Show("Data not Inserted");
                                }
                                db.sql.Close();
                                show_appointment();
                            }
                            else
                            {
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
            }
            catch
            {
            }
        }
コード例 #2
0
        private void button22_Click(object sender, EventArgs e)
        {
            token token = new token(richTextBox1.Text);

            token.Show();
        }
コード例 #3
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
            {
            }
        }