Ejemplo n.º 1
0
 public static void Delete(int id)
 {
     try
     {
         String query = "DELETE FROM Materialy WHERE ID = " + id + ";";
         SQLConnector.ProcessQuery(query);
     }
     catch (Exception ex)
     {
         throw new HttpResponseException(HttpStatusCode.InternalServerError);
     }
 }
Ejemplo n.º 2
0
 public static void Update(int id, Material material)
 {
     try
     {
         String query = "UPDATE Materialy SET CourseID=" + material.getCourseID() + ", Title='" + material.getTitle() + "', FilePath='" + material.getFilePath() + "', Type=" + material.getType() + " WHERE ID=" + id + ";";
         SQLConnector.ProcessQuery(query);
     }
     catch (Exception ex)
     {
         throw new HttpResponseException(HttpStatusCode.InternalServerError);
     }
 }
 internal String ProcessQuery(String query, String SuccessMessage)
 {
     try
     {
         SQLConnector.ProcessQuery(query);
         return(SuccessMessage);
     }
     catch (System.Data.SqlClient.SqlException ex)
     {
         throw;
     }
 }
Ejemplo n.º 4
0
    public static void Create(Material material)
    {
        String query = "INSERT INTO Materialy (CourseID, Title, FilePath, Type) VALUES (" + material.getCourseID() + ", '" + material.getTitle() + "', '" + material.getFilePath() + "', " + material.getType() + ");";

        try
        {
            SQLConnector.ProcessQuery(query);
        }
        catch (System.Data.SqlClient.SqlException ex)
        {
            throw new HttpResponseException(HttpStatusCode.InternalServerError);
        }
    }
Ejemplo n.º 5
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        UserItemToRecover ValidationItem = LoginAndMailValidation(TextBox1.Text, TextBox2.Text);

        if (ValidationItem != null)
        {
            String newPassword      = StringGen.GenString();
            PasswordSaltAndHash sah = new PasswordSaltAndHash(newPassword);
            String query            = SendPasswordToDatabase(sah.getPasswordSalt(), sah.getPasswordHash(), ValidationItem);
            try
            {
                SQLConnector.ProcessQuery(query);
                Panel1.Visible = false;
                Panel2.Visible = true;
                Label1.Text    = "<p class=\"center\">Hasło zostało zmienione pomyślnie. Nowe hasło brzmi: " + newPassword + "</p>";
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                Panel1.Visible = false;
                Panel2.Visible = true;
                Label1.Text    = "<p class=\"center\">Baza wygenerowała następującego errora: " + ex.Message + "</p>";
            }
        }
    }