示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(Program.connString);
            conn.Open();
            String selectSQL = "select count(id) from users where id='" + textBox1.Text.ToString() + "';";

            MySql.Data.MySqlClient.MySqlDataReader userexists = new MySql.Data.MySqlClient.MySqlCommand(selectSQL, conn).ExecuteReader();
            userexists.Read();
            if (userexists[0].ToString().Equals("1"))
            {
                userexists.Close();



                selectSQL = "select password from users where id='" + textBox1.Text.ToString() + "';";
                MySql.Data.MySqlClient.MySqlDataReader comp = new MySql.Data.MySqlClient.MySqlCommand(selectSQL, conn).ExecuteReader();
                comp.Read();


                if (textBox2.Text.ToString().Equals(comp[0].ToString()))
                {
                    comp.Close();
                    selectSQL = "select name from users where id='" + textBox1.Text.ToString() + "';";
                    MySql.Data.MySqlClient.MySqlDataReader name = new MySql.Data.MySqlClient.MySqlCommand(selectSQL, conn).ExecuteReader();
                    name.Read();
                    String s = name[0].ToString();


                    Form1 f1 = new Form1(this, s, textBox1.Text.ToString());
                    textBox1.Text = "";
                    textBox2.Text = "";
                    this.Hide();
                    f1.Show();
                    conn.Close();
                }
                else
                {
                    label3.Text = "Wrong Password";
                    conn.Close();
                }
            }
            else
            {
                userexists.Close();
                conn.Close();
                label3.Text = "Wrong UserID";
            }
        }
        private void comboBox1_Click(object sender, EventArgs e)
        {
            comboBox1.Items.Clear();
            comboBox1.Items.Add("None");
            comboBox1.SelectedItem = "None";
            MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(Program.connString);
            conn.Open();
            String selectSQL = "select plotno from plotmaster where counter=0";

            MySql.Data.MySqlClient.MySqlDataReader vehiclecount = new MySql.Data.MySqlClient.MySqlCommand(selectSQL, conn).ExecuteReader();
            while (vehiclecount.Read())
            {
                comboBox1.Items.Add(vehiclecount[0].ToString());
            }
            vehiclecount.Close();

            conn.Close();
        }
示例#3
0
        public static int dataentry(String user, String platenumber, String vip, Form2 f2, String manually)
        {
            try
            {
                //   MessageBox.Show(platenumber);
                MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(Program.connString);
                conn.Open();
                String selectSQL = "select count(vehicleno) from vehiclemaster where vehicleno='" + platenumber + "'";
                MySql.Data.MySqlClient.MySqlDataReader vehiclecount = new MySql.Data.MySqlClient.MySqlCommand(selectSQL, conn).ExecuteReader();
                vehiclecount.Read();
                selectSQL = vehiclecount[0].ToString();
                vehiclecount.Close();
                //    MessageBox.Show(selectSQL);
                if (!selectSQL.Equals("0"))
                {
                    conn.Close();
                    return(2);
                }
                String nearestPlotValue;
                if (manually.Equals("None"))
                {
                    selectSQL = "select count(plotno) from plotmaster where counter=0";
                    MySql.Data.MySqlClient.MySqlDataReader plotcount = new MySql.Data.MySqlClient.MySqlCommand(selectSQL, conn).ExecuteReader();
                    plotcount.Read();

                    selectSQL = plotcount[0].ToString();
                    plotcount.Close();

                    //     MessageBox.Show(selectSQL);
                    if (selectSQL.Equals("0"))
                    {
                        conn.Close();
                        return(-1);
                    }

                    selectSQL = "select plotno from plotmaster where value=(select min(value) from plotmaster where counter=0) and counter=0";
                    MySql.Data.MySqlClient.MySqlDataReader minPlotValue = new MySql.Data.MySqlClient.MySqlCommand(selectSQL, conn).ExecuteReader();
                    minPlotValue.Read();
                    nearestPlotValue = minPlotValue[0].ToString();
                    minPlotValue.Close();
                }
                else
                {
                    nearestPlotValue = manually;
                }
                //  MessageBox.Show(nearestPlotValue);
                String vipInt;

                if (vip.Equals("True"))
                {
                    vipInt = "true";
                }
                else
                {
                    vipInt = "false";
                }

                String updSQL = "insert into vehiclemaster ( id,vehicleno,plotno, vip) values ( '" + user + "','" + platenumber + "' , '" + nearestPlotValue + "'," + vipInt + ")";
                //   MessageBox.Show(updSQL);
                new MySql.Data.MySqlClient.MySqlCommand(updSQL, conn).ExecuteNonQuery();
                updSQL = "UPDATE plotmaster SET counter='1' WHERE plotno= '" + nearestPlotValue + "'";
                new MySql.Data.MySqlClient.MySqlCommand(updSQL, conn).ExecuteNonQuery();
                //     MySql.Data.MySqlClient.MySqlCommand myCommand = new MySql.Data.MySqlClient.MySqlCommand("insert into plotmaster ( plotno, counter) values ( 'p6' , 1)", conn);
                //      myCommand.BeginExecuteNonQuery();
                //    Thread t1 = new Thread(new ThreadStart(f2.changelabel));
                f2.changelabel(nearestPlotValue);
                conn.Close();
                return(0);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(0);
            }
            finally
            {
            }
        }
        public static int dataexit(String platenumber, Form2 f2)
        {
            try
            {
                //    MessageBox.Show(platenumber);
                MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(Program.connString);
                conn.Open();
                String selectSQL = "select count(vehicleno) from vehiclemaster where vehicleno='" + platenumber + "'";
                MySql.Data.MySqlClient.MySqlDataReader vehiclecount = new MySql.Data.MySqlClient.MySqlCommand(selectSQL, conn).ExecuteReader();
                vehiclecount.Read();
                selectSQL = vehiclecount[0].ToString();
                vehiclecount.Close();
                //    MessageBox.Show(selectSQL);
                if (selectSQL.Equals("0"))
                {
                    conn.Close();
                    return(-1);
                }
                int hours, price, minutes, seconds;


                selectSQL = "SELECT TIMEDIFF(CURRENT_TIMESTAMP,(select vehiclein from vehiclemaster where vehicleno='" + platenumber + "'));";
                MySql.Data.MySqlClient.MySqlDataReader timedef = new MySql.Data.MySqlClient.MySqlCommand(selectSQL, conn).ExecuteReader();
                timedef.Read();
                string totalTime = timedef[0].ToString();
                timedef.Close();



                selectSQL = "select vip from vehiclemaster where vehicleno='" + platenumber + "';";
                MySql.Data.MySqlClient.MySqlDataReader vip = new MySql.Data.MySqlClient.MySqlCommand(selectSQL, conn).ExecuteReader();
                vip.Read();
                string vipstat = vip[0].ToString();
                vip.Close();
                //    MessageBox.Show("vip =" + vipstat);

                Int32.TryParse(totalTime.Substring(0, 2), out hours);
                Int32.TryParse(totalTime.Substring(3, 2), out minutes);
                Int32.TryParse(totalTime.Substring(6, 2), out seconds);
                //  MessageBox.Show(hours + " " + minutes + " " + seconds);
                if (seconds > 0)
                {
                    minutes = minutes + 1;
                }
                if (minutes > 0)
                {
                    hours = hours + 1;
                }


                if (hours <= Program.first_hours)
                {
                    price = Program.first_price;
                }
                else
                {
                    price = Program.first_price + (((hours - Program.first_hours) / Program.second_hours) * Program.second_price);
                }



                String updSQL = "insert into oldrecord (id,vehicleno,plotno,vehiclein,vip,price) select id,vehicleno,plotno,vehiclein,vip," + price + " from vehiclemaster where vehicleno='" + platenumber + "';";
                new MySql.Data.MySqlClient.MySqlCommand(updSQL, conn).ExecuteNonQuery();
                updSQL = "update plotmaster p, vehiclemaster v set p.counter=0 where p.plotno = v.plotno and v.vehicleno = '" + platenumber + "';";
                new MySql.Data.MySqlClient.MySqlCommand(updSQL, conn).ExecuteNonQuery();
                updSQL = "delete from vehiclemaster where vehicleno='" + platenumber + "';";
                new MySql.Data.MySqlClient.MySqlCommand(updSQL, conn).ExecuteNonQuery();
                if (vipstat.Equals("True"))
                {
                    conn.Close();
                    f2.changelabel("₹ 0");
                    return(0);
                }
                else
                {
                    conn.Close();

                    f2.changelabel("₹ " + price);
                    return(price);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            finally
            {
            }



            return(-2);
        }