Exemplo n.º 1
0
        public ActionResult Unassigned(WordExeception wd)
        {
            if (User.Identity.Name.Equals("zeesh"))
            {
                myConn = new MySqlConnection(TaqtiController.connectionString);
                myConn.Open();
                MySqlCommand cmd = new MySqlCommand(TaqtiController.connectionString);
                cmd = myConn.CreateCommand();
                cmd.CommandText = "select max(id) as id from Exceptions;";
                dataReader = cmd.ExecuteReader();
                int id3 = 0;
                while (dataReader.Read())
                {
                    id3 = dataReader.GetInt32(0);
                }
                myConn.Close();
                MySqlConnection myConn2 = new MySqlConnection(TaqtiController.connectionString);
                MySqlCommand cmd2 = new MySqlCommand(TaqtiController.connectionString);
                myConn2.Open();
                cmd2 = myConn2.CreateCommand();

                if (!String.IsNullOrEmpty(wd.taqti2))
                {
                    if (wd.add)
                    {
                        cmd2.CommandText = "INSERT into Exceptions(ID,word,taqti,taqti2) VALUES (@id,@word,@taqti1,@taqti2)";
                        cmd2.Parameters.AddWithValue("@id", id3 + 1);
                        cmd2.Parameters.AddWithValue("@word", (string)wd.word);
                        cmd2.Parameters.AddWithValue("@taqti1", (string)wd.taqti);
                        cmd2.Parameters.AddWithValue("@taqti2", (string)wd.taqti2);
                        cmd2.ExecuteNonQuery();

                    }
                }
                else
                {
                    if (wd.add)
                    {
                        cmd2.CommandText = "INSERT into Exceptions(ID,word,taqti) VALUES (@id,@word,@taqti1)";
                        cmd2.Parameters.AddWithValue("@id", id3 + 1);
                        cmd2.Parameters.AddWithValue("@word", (string)wd.word);
                        cmd2.Parameters.AddWithValue("@taqti1", (string)wd.taqti);
                        cmd2.ExecuteNonQuery();

                    }
                }

                myConn2.Close();





                myConn = new MySqlConnection(TaqtiController.connectionString);
                myConn.Open();
                cmd = new MySqlCommand(TaqtiController.connectionString);
                cmd = myConn.CreateCommand();
                cmd.CommandText = "select max(id) as id from dataEntry;";
                dataReader = cmd.ExecuteReader();
                int id4 = 0;
                while (dataReader.Read())
                {
                    id4 = dataReader.GetInt32(0);
                }
                myConn.Close();
                myConn2 = new MySqlConnection(TaqtiController.connectionString);
                cmd2 = new MySqlCommand(TaqtiController.connectionString);
                myConn2.Open();

                cmd2 = myConn2.CreateCommand();
                cmd2.CommandText = "INSERT into dataEntry(ID,name,whichtable,whichid,time) VALUES (@id,@name,@table,@tableid,@time)";
                cmd2.Parameters.AddWithValue("@id", id4 + 1);
                cmd2.Parameters.AddWithValue("@name", (string)User.Identity.Name);
                cmd2.Parameters.AddWithValue("@table", (string)"Exceptions");
                cmd2.Parameters.AddWithValue("@tableid", id3);
                cmd2.Parameters.AddWithValue("@time", DateTime.Now);
                cmd2.ExecuteNonQuery();
                myConn2.Close();

                MySqlConnection myConn3 = new MySqlConnection(TaqtiController.connectionString);
                MySqlCommand cmd3 = new MySqlCommand(TaqtiController.connectionString);

                myConn3.Open();

                cmd3 = myConn3.CreateCommand();
                cmd3.CommandText = "UPDATE unassigned set assigned = @assigned where id = @id;";
                cmd3.Parameters.AddWithValue("@assigned", true);
                cmd3.Parameters.AddWithValue("@id", (int)wd.id);
                cmd3.ExecuteNonQuery();
                myConn3.Close();


                return RedirectToAction("Unassigned");
            }
            else
            {
                return RedirectToAction("Error");
            }
        }
Exemplo n.º 2
0
 public ActionResult Unassigned()
 {
     WordExeception wd = new WordExeception();
     myConn = new MySqlConnection(TaqtiController.connectionString);
     myConn.Open();
     MySqlCommand cmd = new MySqlCommand(TaqtiController.connectionString);
     cmd = myConn.CreateCommand();
     cmd.CommandText = "select * from unassigned where assigned = false order by id desc;";
     dataReader = cmd.ExecuteReader();
     while (dataReader.Read())
     {
         wd.id = dataReader.GetInt32(0);
        wd.word = dataReader.GetString(1);
     }
     myConn.Close();
     return View(wd);
 }