Click here to Skip to main content
15,893,622 members
Articles / Web Development / ASP.NET

Save image with printed text on it

Rate me:
Please Sign up or sign in to vote.
3.00/5 (2 votes)
25 Sep 2012CPOL2 min read 11.8K   121   2  
Create an ASP.NET page where the user can edit/modify text for an image and then save that image with printed text on it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Data.SqlClient;
using System.Data;
/// <summary>
/// Summary description for ImageCls
/// </summary>
public class ImageCls
{
    SqlConnection mycon;
    public ImageCls()
    {
        string contring = WebConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
        mycon = new SqlConnection(contring);
    }
    public DataTable GetImage()
    {
        SqlCommand cmd = new SqlCommand("spGetImage", mycon);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt);
        return dt;
    }
    public void SaveImage(Dictionary<string, string> parameters)
    {
        string cmdtxt = string.Empty;
        string cmdval = string.Empty;
        SqlCommand cmd = new SqlCommand("spSaveImage", mycon);
        cmd.CommandType = CommandType.StoredProcedure;

        for (int i = 0; i < parameters.Count; i++)
        {
            cmd.Parameters.AddWithValue("@" + parameters.ElementAt(i).Key, parameters.ElementAt(i).Value);
        }
        cmd.Connection = mycon;
        if (mycon.State == ConnectionState.Closed)
        {
            mycon.Open();
        }
        cmd.ExecuteNonQuery();
        mycon.Close();
    }
    public void DeleteImage(int ImageID)
    {
        string cmdtxt = string.Empty;
        string cmdval = string.Empty;
        SqlCommand cmd = new SqlCommand("spDeleteImage", mycon);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@ImageID", ImageID);
        cmd.Connection = mycon;
        if (mycon.State == ConnectionState.Closed)
        {
            mycon.Open();
        }
        cmd.ExecuteNonQuery();
        mycon.Close();
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer Essential Solve LLC
India India
I am flexible, responsive, creative and enthusiastic with ability to manage multiple initiatives with deadline. I have willingness to pick up and develop new skills and ability to balance a number of conflicting priorities and make decisions. I am results oriented - focused on productive and high-yield activities.

Comments and Discussions