Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            fill_textBox();
            string start       = comboBox1.Text;
            string destination = comboBox2.Text;
            string Class       = paseclass();
            string type        = pasetype();
            string passe       = textBox1.Text;
            string price       = textBox4.Text;

            // string tno = textBox5.Text;


            textBox6.Text = Class;
            textBox7.Text = type;
            textBox8.Text = passe;
            //textBox9.Text = tno;
            textBox12.Text = start;
            textBox13.Text = destination;
            textBox14.Text = price;



            string tcktno    = textBox9.Text;
            string pclass    = textBox6.Text;
            string tdate     = textBox10.Text;
            string ttime     = textBox11.Text;
            string ptype     = textBox7.Text;
            string froms     = textBox12.Text;
            string tos       = textBox13.Text;
            string noOfPasse = textBox8.Text;
            string Price     = textBox14.Text;
            string cno       = comboBox6.Text;
            string trainid   = comboBox5.Text;


            SqlConnection con = new DBConnector().getConnection();

            try
            {
                con.Open();
                SqlCommand cmd2 = con.CreateCommand();
                cmd2.CommandType = CommandType.Text;
                cmd2.CommandText = "insert into tdt values('" + tcktno + "','" + pclass + "','" + tdate + "','" + ttime + "','" + ptype + "','" + froms + "','" + tos + "','" + noOfPasse + "','" + Price + "','" + trainid + "','" + cno + "')";
                int b = cmd2.ExecuteNonQuery();


                if (b > 0)
                {
                    /*printDialog1.Document = printDocument1;
                     * if (printDialog1.ShowDialog() == DialogResult.OK)
                     * {
                     *
                     *  printDocument1.Print();
                     *
                     *
                     *
                     *
                     * }*/
                    MessageBox.Show("add successfully");
                }
                else
                {
                    MessageBox.Show("Printing Failed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }