コード例 #1
0
        void fill_combo()
        {
            SqlConnection con = new DBConnector().getConnection();

            con.Open();
            SqlCommand cmd2 = con.CreateCommand();

            cmd2.CommandType = CommandType.Text;
            cmd2.CommandText = "select * from train";


            try
            {
                SqlDataReader myReader = cmd2.ExecuteReader();

                while (myReader.Read())
                {
                    string trainid = myReader.GetString(0);
                    comboBox1.Items.Add(trainid);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
ファイル: anysale.cs プロジェクト: SriDarshana/GroupProject
        void fill_grid()
        {
            SqlConnection con = new DBConnector().getConnection();

            try
            {
                string theDate  = dateTimePicker1.Value.ToString("dd/MM/yyyy");
                string theDate1 = dateTimePicker2.Value.ToString("dd/MM/yyyy");

                con.Open();
                SqlCommand cmd = con.CreateCommand();

                // string fr = comboBox1.Text;
                //string to = comboBox2.Text;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "select * from tdt where date between '" + theDate + "' and '" + theDate1 + "' ";
                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = cmd;
                DataTable dbdataset = new DataTable();
                sda.Fill(dbdataset);
                BindingSource bsource = new BindingSource();
                bsource.DataSource       = dbdataset;
                dataGridView1.DataSource = bsource;
                sda.Update(dbdataset);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #3
0
ファイル: dsalrpt.cs プロジェクト: SriDarshana/GroupProject
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string date = dateTimePicker1.Text;

                cry.Load(@"G:\3rd year 2nd semester\Group project\train\train\CrystalReport4.rpt");
                SqlConnection con = new DBConnector().getConnection();
                SqlCommand    cmd = con.CreateCommand();

                con.Open();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "select date,trainid,tcktno,start,des,price,passe from tdt where  date='" + date + "'";
                SqlDataAdapter sda = new SqlDataAdapter();
                // sda.SelectCommand.CommandType = CommandType.StoredProcedure;
                sda.SelectCommand = cmd;
                DataSet st = new System.Data.DataSet();
                sda.Fill(st, "Tickets");

                cry.SetDataSource(st);
                cry.SetParameterValue("date", date);
                crystalReportViewer1.ReportSource = cry;
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
ファイル: addtrain.cs プロジェクト: SriDarshana/GroupProject
        void fill_textBox()
        {
            SqlConnection con = new DBConnector().getConnection();

            con.Open();
            SqlCommand cmd2 = con.CreateCommand();

            cmd2.CommandType = CommandType.Text;
            cmd2.CommandText = "select * from train";


            try
            {
                SqlDataReader myReader = cmd2.ExecuteReader();

                while (myReader.Read())
                {
                    string tctno = myReader.GetString(0);
                    textBox1.Text = tctno;

                    double t = Double.Parse(textBox1.Text) + 1;

                    textBox1.Text = "00" + t.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #5
0
ファイル: Morning.cs プロジェクト: SriDarshana/GroupProject
        private void comboBox5_SelectedIndexChanged(object sender, EventArgs e)
        {
            SqlConnection con = new DBConnector().getConnection();



            try
            {
                con.Open();

                SqlCommand cmd2 = con.CreateCommand();

                string empi = comboBox5.Text;



                cmd2.CommandType = CommandType.Text;
                cmd2.CommandText = "select * from emp where empid='" + empi + "'";

                SqlDataReader my = cmd2.ExecuteReader();

                while (my.Read())
                {
                    string empil = my.GetString(1);
                    string empij = my.GetString(2);

                    textBox5.Text = empil + " " + empij;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: SriDarshana/GroupProject
        private void button1_Click(object sender, EventArgs e)
        {
            string username = textBox1.Text;
            string password = textBox2.Text;


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

            con.Open();
            SqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "SELECT * FROM login WHERE username='******' AND password='******'";
            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.HasRows)
            {
                this.Hide();
                Home Hm = new Home(label4.Text, textBox1.Text);
                Hm.ShowDialog();
            }
            else
            {
                MessageBox.Show("Invalid login ,Try again", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #7
0
ファイル: empmgt.cs プロジェクト: SriDarshana/GroupProject
        private void button3_Click(object sender, EventArgs e)
        {
            SqlConnection con = new DBConnector().getConnection();

            try
            {
                con.Open();
                SqlCommand cmd2 = con.CreateCommand();
                string     y    = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
                cmd2.CommandType = CommandType.Text;
                cmd2.CommandText = "delete from emp where empid='" + y + "' ;";
                int b = cmd2.ExecuteNonQuery();

                if (b > 0)
                {
                    MessageBox.Show("Successfully Deleted!!!", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    fill_grid();
                }
                else
                {
                    MessageBox.Show("Delete Failed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #8
0
        void fill_grid()
        {
            SqlConnection con = new DBConnector().getConnection();

            try
            {
                con.Open();
                SqlCommand cmd = con.CreateCommand();

                // string fr = comboBox1.Text;
                //string to = comboBox2.Text;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "select * from tshedule where Start='" + comboBox1.Text + "' and en='" + comboBox2.Text + "'";
                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = cmd;
                DataTable dbdataset = new DataTable();
                sda.Fill(dbdataset);
                BindingSource bsource = new BindingSource();
                bsource.DataSource       = dbdataset;
                dataGridView1.DataSource = bsource;
                sda.Update(dbdataset);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string date1 = dateTimePicker1.Text;
                string date2 = dateTimePicker2.Text;

                string theDate  = dateTimePicker1.Value.ToString("dd/MM/yyyy");
                string theDate1 = dateTimePicker2.Value.ToString("dd/MM/yyyy");


                cry.Load(@"G:\3rd year 2nd semester\Group project\train\train\CrystalReport5.rpt");
                SqlConnection con = new DBConnector().getConnection();
                SqlCommand    cmd = con.CreateCommand();

                con.Open();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "select * from tdt where date between '" + theDate + "' and '" + theDate1 + "' ";
                SqlDataAdapter sda = new SqlDataAdapter();
                // sda.SelectCommand.CommandType = CommandType.StoredProcedure;
                sda.SelectCommand = cmd;
                DataSet st = new System.Data.DataSet();
                sda.Fill(st, "Tickets");

                cry.SetDataSource(st);
                cry.SetParameterValue("date1", date1);
                cry.SetParameterValue("date2", date2);
                crystalReportViewer1.ReportSource = cry;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #10
0
ファイル: other.cs プロジェクト: SriDarshana/GroupProject
        void fill_textBox()
        {
            SqlConnection con = new DBConnector().getConnection();

            con.Open();
            SqlCommand cmd2 = con.CreateCommand();

            cmd2.CommandType = CommandType.Text;
            cmd2.CommandText = "select workid from works";


            try
            {
                SqlDataReader myReader = cmd2.ExecuteReader();


                while (myReader.Read())
                {
                    int tctno = myReader.GetInt32(0);
                    label7.Text = tctno.ToString();

                    double t = Double.Parse(label7.Text) + 1;

                    label7.Text = "W" + t.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #11
0
ファイル: Annualy.cs プロジェクト: SriDarshana/GroupProject
        void fill_grid10()
        {
            SqlConnection con = new DBConnector().getConnection();

            try
            {
                con.Open();
                SqlCommand cmd = con.CreateCommand();

                //string month = comboBox1.Text;
                string year = comboBox2.Text;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "select * from stockout where year='" + year + "'";
                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = cmd;
                DataTable dbdataset = new DataTable();
                sda.Fill(dbdataset);
                BindingSource bsource = new BindingSource();
                bsource.DataSource       = dbdataset;
                dataGridView2.DataSource = bsource;
                sda.Update(dbdataset);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #12
0
ファイル: Morning.cs プロジェクト: SriDarshana/GroupProject
        void fill_textBox()
        {
            SqlConnection con = new DBConnector().getConnection();

            con.Open();
            SqlCommand cmd2 = con.CreateCommand();

            cmd2.CommandType = CommandType.Text;
            cmd2.CommandText = "select workid from works";


            try
            {
                SqlDataReader myReader = cmd2.ExecuteReader();


                while (myReader.Read())
                {
                    int tctno = myReader.GetInt32(0);
                    label6.Text = tctno.ToString();

                    double t = Double.Parse(label6.Text) + 1;

                    label6.Text = t.ToString();

                    int tctno1 = myReader.GetInt32(0);
                    label12.Text = tctno1.ToString();

                    double t1 = Double.Parse(label12.Text) + 2;

                    label12.Text = t1.ToString();

                    int tctno2 = myReader.GetInt32(0);
                    label18.Text = tctno2.ToString();

                    double t2 = Double.Parse(label18.Text) + 3;

                    label18.Text = t2.ToString();

                    int tctno3 = myReader.GetInt32(0);
                    label24.Text = tctno3.ToString();

                    double t3 = Double.Parse(label24.Text) + 4;

                    label24.Text = t3.ToString();

                    int tctno4 = myReader.GetInt32(0);
                    label30.Text = tctno4.ToString();

                    double t4 = Double.Parse(label30.Text) + 5;

                    label30.Text = t4.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #13
0
ファイル: empmgt.cs プロジェクト: SriDarshana/GroupProject
        private void button4_Click(object sender, EventArgs e)
        {
            SqlConnection con = new DBConnector().getConnection();

            try
            {
                con.Open();
                SqlCommand cmd = con.CreateCommand();
                cmd.CommandType = CommandType.Text;

                //dataGridView1.Rows.Add();
                string empid     = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
                string firstname = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
                string lastname  = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
                string address   = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
                string dob       = dataGridView1.SelectedRows[0].Cells[4].Value.ToString();
                string gender    = dataGridView1.SelectedRows[0].Cells[5].Value.ToString();
                string status    = dataGridView1.SelectedRows[0].Cells[6].Value.ToString();
                string position  = dataGridView1.SelectedRows[0].Cells[7].Value.ToString();
                string etfno     = dataGridView1.SelectedRows[0].Cells[8].Value.ToString();
                string tp        = dataGridView1.SelectedRows[0].Cells[9].Value.ToString();



                cmd.CommandText = "update emp set empid='" + empid + "',firstname='" + firstname + "',lastname='" + lastname + "', address='" + address + "',dob='" + dob + "',gender='" + gender + "',status='" + status + "',position='" + position + "',etfno='" + etfno + "',tp='" + tp + "' where empid='" + empid + "';";
                int a = cmd.ExecuteNonQuery();
                if (a > 0)
                {
                    MessageBox.Show("Successfully Updated!!!", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Update Failed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #14
0
ファイル: addemp.cs プロジェクト: SriDarshana/GroupProject
        private void button3_Click(object sender, EventArgs e)
        {
            string empid     = textBox1.Text;
            string firstname = textBox2.Text;
            string lastname  = textBox3.Text;
            string address   = textBox4.Text;
            string dob       = dateTimePicker1.Text;
            string gender    = getgender();
            string status    = comboBox1.Text;
            string position  = textBox5.Text;
            string etfno     = textBox6.Text;
            string tp        = textBox8.Text;

            //string susername = textBox4.Text;

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

            try
            {
                con.Open();
                SqlCommand cmd2 = con.CreateCommand();
                cmd2.CommandType = CommandType.Text;
                cmd2.CommandText = "insert into emp (empid,firstname,lastname,address,dob,gender,status,position,etfno,tp) values('" + empid + "','" + firstname + "','" + lastname + "','" + address + "','" + dob + "','" + gender + "','" + status + "','" + position + "','" + etfno + "','" + tp + "')";
                int b = cmd2.ExecuteNonQuery();


                if (b > 0)
                {
                    MessageBox.Show("Successfully Registered!!!", "Registration", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Registration Failed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #15
0
        private void button1_Click(object sender, EventArgs e)
        {
            string year = comboBox1.Text;

            cry.Load(@"G:\3rd year 2nd semester\Group project\train\train\CrystalReport7.rpt");
            SqlConnection con = new DBConnector().getConnection();
            SqlCommand    cmd = con.CreateCommand();

            con.Open();
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from stockout where  year='" + year + "' ";
            SqlDataAdapter sda = new SqlDataAdapter();

            // sda.SelectCommand.CommandType = CommandType.StoredProcedure;
            sda.SelectCommand = cmd;
            DataSet st = new System.Data.DataSet();

            sda.Fill(st, "STOCKOUT");
            cry.SetDataSource(st);
            cry.SetParameterValue("year", year);
            crystalReportViewer1.ReportSource = cry;
        }
コード例 #16
0
ファイル: Morning.cs プロジェクト: SriDarshana/GroupProject
        void fill_combo()
        {
            SqlConnection con = new DBConnector().getConnection();

            con.Open();
            SqlCommand cmd2 = con.CreateCommand();

            cmd2.CommandType = CommandType.Text;
            cmd2.CommandText = "select * from emp";


            try
            {
                SqlDataReader myReader = cmd2.ExecuteReader();


                while (myReader.Read())
                {
                    String empi = myReader.GetString(0);
                    comboBox1.Items.Add(empi);

                    String empi1 = myReader.GetString(0);
                    comboBox2.Items.Add(empi1);

                    String empi2 = myReader.GetString(0);
                    comboBox3.Items.Add(empi2);

                    String empi3 = myReader.GetString(0);
                    comboBox4.Items.Add(empi3);

                    String empi4 = myReader.GetString(0);
                    comboBox5.Items.Add(empi4);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #17
0
ファイル: issuetkt.cs プロジェクト: SriDarshana/GroupProject
        private void radioButton5_CheckedChanged(object sender, EventArgs e)
        {
            SqlConnection con = new DBConnector().getConnection();



            try
            {
                con.Open();

                SqlCommand cmd2 = con.CreateCommand();

                string start       = comboBox1.Text;
                string destination = comboBox2.Text;
                string Class       = paseclass();
                string type        = pasetype();



                cmd2.CommandType = CommandType.Text;
                cmd2.CommandText = "select * from Tckt where start='" + start + "' and destination='" + destination + "' and class='" + Class + "' and type='" + type + "'";

                SqlDataReader my = cmd2.ExecuteReader();

                while (my.Read())
                {
                    string sprice = my.GetString(4);
                    string stax   = my.GetString(5);

                    textBox2.Text = sprice;
                    textBox3.Text = stax;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #18
0
ファイル: addtrain.cs プロジェクト: SriDarshana/GroupProject
        private void button3_Click(object sender, EventArgs e)
        {
            string trainid        = textBox1.Text;
            string tname          = textBox2.Text;
            string enginecapasity = textBox3.Text;
            string noOfBox        = textBox4.Text;
            string route          = textBox5.Text;
            string type           = textBox6.Text;


            //string susername = textBox4.Text;

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

            try
            {
                con.Open();
                SqlCommand cmd2 = con.CreateCommand();
                cmd2.CommandType = CommandType.Text;
                cmd2.CommandText = "insert into train (trainid,tname,enginecapasity,noOfBox,route,type) values('" + trainid + "','" + tname + "','" + enginecapasity + "','" + noOfBox + "','" + route + "','" + type + "')";
                int b = cmd2.ExecuteNonQuery();


                if (b > 0)
                {
                    MessageBox.Show("Successfully Saved!!!", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Saving Failed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #19
0
ファイル: Morning.cs プロジェクト: SriDarshana/GroupProject
        private void button10_Click(object sender, EventArgs e)
        {
            string workid    = label30.Text;
            string workplace = groupBox5.Text;
            string date      = dateTimePicker1.Text;
            string session   = label5.Text;
            string empno     = comboBox5.Text;
            string empname   = textBox5.Text;



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

            try
            {
                con.Open();
                SqlCommand cmd2 = con.CreateCommand();
                cmd2.CommandType = CommandType.Text;
                cmd2.CommandText = "insert into works (workid,workingplace,date,session,empno,empname) values('" + workid + "','" + workplace + "','" + date + "','" + session + "','" + empno + "','" + empname + "')";
                int b = cmd2.ExecuteNonQuery();


                if (b > 0)
                {
                    MessageBox.Show("Successfully Saved!!!", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Saving Failed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #20
0
ファイル: empmgt.cs プロジェクト: SriDarshana/GroupProject
        void fill_grid()
        {
            SqlConnection con = new DBConnector().getConnection();

            try
            {
                con.Open();
                SqlCommand cmd = con.CreateCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "select * from emp";
                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = cmd;
                DataTable dbdataset = new DataTable();
                sda.Fill(dbdataset);
                BindingSource bsource = new BindingSource();
                bsource.DataSource       = dbdataset;
                dataGridView1.DataSource = bsource;
                sda.Update(dbdataset);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #21
0
ファイル: issuetkt.cs プロジェクト: SriDarshana/GroupProject
        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);
            }
        }