コード例 #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        int id = 0;

        try
        {
            string        strConn      = ConfigurationManager.ConnectionStrings["anmcs"].ToString();
            SqlConnection myConnection = new SqlConnection(strConn);
            SqlCommand    myCommand    = new SqlCommand();
            myCommand.Connection = myConnection;

            myCommand.CommandText = "SELECT TOP 1 * from anm_Templates ORDER BY Template DESC";
            myConnection.Open();

            SqlDataReader reader = myCommand.ExecuteReader();
            while (reader.Read())
            {
                id = Convert.ToInt32(reader["Template"].ToString());
            }
            myConnection.Close();
            string idt = (id + 1).ToString();
            FileUpload1.SaveAs(Server.MapPath("~\\css\\css") + idt + ".css");
            anm_Utility ut = new anm_Utility();
            ut.AddTemplate(TextBox1.Text.ToString(), TextBox2.Text.ToString(), TextBox3.Text.ToString());
        }
        catch (Exception ex)
        {
            lblerror.Text    = ex.Message;
            lblerror.Visible = true;
        }
        Response.Redirect(Page.Request.Url.AbsolutePath.ToString() + "?p=AdminTemplates");
    }