Beispiel #1
0
        private void comboBox_misCultivos_SelectedIndexChanged(object sender, EventArgs e)
        {
            Random random = new Random();
            int    num    = random.Next(100);

            textBox1.Text = num.ToString() + " %";

            DateTime today      = DateTime.Today;
            double   diff       = 0;
            double   porcentaje = 0;

            MySqlConnection conexion  = Conectar();
            String          sentencia = "SELECT fecha_siembra FROM mis_cultivos WHERE nombre = '" + comboBox_misCultivos.Text + "'";
            MySqlCommand    comando   = new MySqlCommand(sentencia, conexion);

            conexion.Open();
            comando.ExecuteNonQuery();

            MySqlDataReader MyReader;

            MyReader = comando.ExecuteReader();
            while (MyReader.Read())
            {
                var      dateString = MyReader.GetDateTime(MyReader.GetOrdinal("fecha_siembra")).ToString("yyyy/MM/dd");
                DateTime myDate     = DateTime.Parse(dateString);
                diff = (today - myDate).TotalDays;
            }
            MyReader.Close();

            String       sentencia2 = "UPDATE mis_cultivos SET dias_transcurridos = " + diff + " WHERE nombre = '" + comboBox_misCultivos.Text + "'";
            MySqlCommand comando2   = new MySqlCommand(sentencia2, conexion);

            comando2.ExecuteNonQuery();

            String       sentencia3 = "SELECT dias_desarrollo FROM mis_cultivos WHERE nombre = '" + comboBox_misCultivos.Text + "'";
            MySqlCommand comando3   = new MySqlCommand(sentencia3, conexion);

            comando3.ExecuteNonQuery();

            MyReader = comando3.ExecuteReader();
            while (MyReader.Read())
            {
                double dias = MyReader.GetDouble("dias_desarrollo");
                porcentaje = (diff * 100) / dias;
            }
            porcentaje = Math.Round(porcentaje, 2);

            MyReader.Close();

            conexion.Close();


            descripcion.Text = "Su cultivo tiene " + diff.ToString() + " días de haberse sembrado, lo que corresponde a " + porcentaje + "% de su estación de crecimiento. Recuerda que en esta etapa es importante...(recomendación) " + "y debería parecerse a la siguiente imagen: ";
        }
Beispiel #2
0
        //public void getMonthComboValues()
        //{
        //    String[] m = {"January","February","March","April","May","June","July","August","September","October","November","December"};

        //        MySqlConnection MyConn = ConnectionOld.getConnection();
        //        MySqlCommand SelectCommand = new MySqlCommand("select distinct Month from ot;", MyConn);
        //        MySqlDataReader MyReader;
        //        MyConn.Open();
        //        MyReader = SelectCommand.ExecuteReader();

        //        while (MyReader.Read())
        //        {
        //            String mon = MyReader.GetString("Month");
        //            for (int i = 0; i < m.Length; i++)
        //            {
        //                if (mon != m[0])
        //                {
        //                    combo_Month.Items.Add(mon);
        //                }


        //            }

        //        }
        //}
        public void getDetails()
        {
            MySqlConnection MyConn        = ConnectionOld.getConnection();
            MySqlCommand    SelectCommand = new MySqlCommand("select * from itp.employee where EmpId = '" + Connection.getUserIdFromConnectionString() + "' ;", MyConn);
            MySqlDataReader MyReader;

            MyConn.Open();
            MyReader = SelectCommand.ExecuteReader();

            while (MyReader.Read())
            {
                Emp_txt.Text         = MyReader.GetInt32("EmpId").ToString();
                First_txt.Text       = MyReader.GetString("FirstName");
                Last_txt.Text        = MyReader.GetString("LastName");
                dateTimePicker1.Text = MyReader.GetString("DOB");

                if ((MyReader.GetString("Nationality") == "SriLankan"))
                {
                    combo_Nat.Text = "SriLankan";
                }
                else
                {
                    combo_Nat.Text = "Foreigner";
                    Nat_txt.Text   = MyReader.GetString("Nationality");
                }

                NIC_txt.Text    = MyReader.GetString("NIC");
                Add_txt.Text    = MyReader.GetString("Address");
                Email_txt.Text  = MyReader.GetString("Email");
                Mob_txt.Text    = MyReader.GetString("MobileNo");
                Posi_combo.Text = MyReader.GetString("Position");
                Dep_txt.Text    = MyReader.GetString("DepId");
                textBox5.Text   = MyReader.GetDouble("BasicSalary").ToString();
                String gender = MyReader.GetChar("Gender").ToString();

                if (gender == "M")
                {
                    radioButton1.Checked = true;
                }
                else
                {
                    radioButton2.Checked = true;
                }
            }
        }
Beispiel #3
0
        double mostrarPrecio(string boxproducto) // Método para mostrar el precio de un producto seleccionado desde la base de datos.
        {
            double          precio    = 0;
            MySqlConnection conexion  = Conectar();
            String          sentencia = "SELECT precio FROM producto WHERE nombre = '" + boxproducto + "'";
            MySqlCommand    comando   = new MySqlCommand(sentencia, conexion);

            conexion.Open();
            comando.ExecuteNonQuery();
            MySqlDataReader MyReader;

            MyReader = comando.ExecuteReader();
            while (MyReader.Read())
            {
                precio = MyReader.GetDouble("precio");
            }
            MyReader.Close();
            conexion.Close();
            return(precio);
        }
Beispiel #4
0
        private void comboBox_productoEncontrado_SelectedIndexChanged(object sender, EventArgs e)
        {
            double          precio    = 0;
            MySqlConnection conexion  = Conectar();
            String          sentencia = "SELECT precio FROM producto WHERE nombre = '" + comboBox_productoEncontrado.Text + "'";
            MySqlCommand    comando   = new MySqlCommand(sentencia, conexion);

            conexion.Open();
            comando.ExecuteNonQuery();
            MySqlDataReader MyReader;

            MyReader = comando.ExecuteReader();
            while (MyReader.Read())
            {
                precio = MyReader.GetDouble("precio");
            }
            MyReader.Close();
            conexion.Close();
            textBox_precioEncontrado.Text = "$ " + precio.ToString("0.00");
            calcular_totalModificado();
        }
Beispiel #5
0
        private void comboBox_misCultivos_SelectedIndexChanged(object sender, EventArgs e)
        {
            Random random = new Random();
            int    num    = random.Next(100);

            textBox1.Text = num.ToString() + " %";

            DateTime today      = DateTime.Today;
            double   diff       = 0;
            double   porcentaje = 0;
            String   rec        = "";

            MySqlConnection conexion  = Conectar();
            String          sentencia = "SELECT fecha_siembra FROM mis_cultivos WHERE nombre = '" + comboBox_misCultivos.Text + "'";
            MySqlCommand    comando   = new MySqlCommand(sentencia, conexion);

            conexion.Open();
            comando.ExecuteNonQuery();

            MySqlDataReader MyReader;

            MyReader = comando.ExecuteReader();
            while (MyReader.Read())
            {
                var      dateString = MyReader.GetDateTime(MyReader.GetOrdinal("fecha_siembra")).ToString("yyyy/MM/dd");
                DateTime myDate     = DateTime.Parse(dateString);
                diff = (today - myDate).TotalDays;
            }
            MyReader.Close();

            String       sentencia2 = "UPDATE mis_cultivos SET dias_transcurridos = " + diff + " WHERE nombre = '" + comboBox_misCultivos.Text + "'";
            MySqlCommand comando2   = new MySqlCommand(sentencia2, conexion);

            comando2.ExecuteNonQuery();

            String       sentencia3 = "SELECT dias_desarrollo FROM mis_cultivos WHERE nombre = '" + comboBox_misCultivos.Text + "'";
            MySqlCommand comando3   = new MySqlCommand(sentencia3, conexion);

            comando3.ExecuteNonQuery();

            MyReader = comando3.ExecuteReader();
            while (MyReader.Read())
            {
                double dias = MyReader.GetDouble("dias_desarrollo");
                porcentaje = (diff * 100) / dias;
            }
            porcentaje = Math.Round(porcentaje, 2);
            int porcentaje_round = ((int)Math.Round(porcentaje / 10.0)) * 10;

            MyReader.Close();

            String       sentencia4 = "SELECT recomendacion FROM " + comboBox_misCultivos.Text + " WHERE crecimiento = " + porcentaje_round + "";
            MySqlCommand comando4   = new MySqlCommand(sentencia4, conexion);

            comando4.ExecuteNonQuery();
            MyReader = comando4.ExecuteReader();
            while (MyReader.Read())
            {
                rec = MyReader.GetString(0);
            }

            MyReader.Close();

            String       sentencia5 = "SELECT imagen FROM " + comboBox_misCultivos.Text + " WHERE crecimiento = " + porcentaje_round + "";
            MySqlCommand comando5   = new MySqlCommand(sentencia5, conexion);

            comando5.ExecuteNonQuery();

            MyReader = comando5.ExecuteReader();
            while (MyReader.Read())
            {
                var bytes = (byte[])MyReader[0];
                using (MemoryStream ms = new MemoryStream(bytes))
                {
                    pictureBox_imagenCrecimiento.Image = Image.FromStream(ms);
                }
            }

            MyReader.Close();

            conexion.Close();

            descripcion.Text = "Su cultivo tiene " + diff.ToString() + " días de haberse sembrado, lo que corresponde a " + porcentaje + "% de su estación de crecimiento. " + rec + " Su cultivo debería parecerse a la siguiente imagen: ";
            // pictureBox_imagenCrecimiento.Show();
        }