Sunday, April 1, 2012

Product Catelog App class in asp.net c# -5


Add_view_category.aspx.cs

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Add_view_category : System.Web.UI.Page
{
    BALCategoryMaster bal = new BALCategoryMaster();
    DALCategoryMaster dal = new DALCategoryMaster();
    DALProductMaster prodal = new DALProductMaster();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["id"] != null)
            {
                int CategoryId = int.Parse(Request.QueryString["id"].ToString());
                bal.CategoryId = CategoryId;
                DataTable dt = dal.select_CategoryMasterByCategoryId(bal);
                if (dt.Rows.Count != 0)
                {
                    txtcategory.Text = dt.Rows[0]["CategoryName"].ToString();
                }
            }
            gvbind();
        }
      
    }
    public void gvbind()
    {
        DataTable dt = dal.Select_CategoryMaster();
        gvcategory.DataSource = dt;
        gvcategory.DataBind();
        ViewState["dtcat"] = dt;
    }


    protected void gvcategory_RowEditing(object sender, GridViewEditEventArgs e)
    {
        string categoryid = gvcategory.DataKeys[e.NewEditIndex].Value.ToString();
        Response.Redirect("Add_view_category.aspx?id=" + categoryid);

    }
    protected void gvcategory_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int categoryid = int.Parse(gvcategory.DataKeys[e.RowIndex].Value.ToString());
        bal.CategoryId = categoryid;
        dal.delete_CategoryMaster(bal);
        gvbind();
    }

    protected void gvcategory_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvcategory.PageIndex = e.NewPageIndex;
        gvcategory.DataSource = (DataTable)ViewState["dtcat"];
        gvcategory.DataBind();

    }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] != null)
        {
            bal.CategoryName = txtcategory.Text.Trim().ToString().ToUpper();
            bal.CategoryId = int.Parse(Request.QueryString["id"].ToString());
            dal.update_CategoryMaster(bal);
            Response.Redirect("Add_view_category.aspx");
        }
        else
        {

            bal.CategoryName = txtcategory.Text.Trim().ToString().ToUpper();
            dal.insert_CategoryMaster(bal);
            Response.Redirect("Add_view_category.aspx");

        }
    }
    protected void Submit_Click(object sender, EventArgs e)
    {
        string search = txtsearch.Text.ToString();
        DataTable dt = dal.Select_CategoryMasterSearch(search);
        gvcategory.DataSource = dt;
        gvcategory.DataBind();
        ViewState["dtcat"] = dt;
    }
}
 


Add_view_category.aspx

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="Add_view_category.aspx.cs" Inherits="Add_view_category" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table>
        <tr>
            <td width="63%" align="right" valign="top">
                <table width="90%" border="0" align="right" cellpadding="0" cellspacing="0" style="padding: 40px 0 0 0;
                    margin-top: 10px;">
                    <tr>
                        <td width="90%" align="right" valign="top">
                            <table width="90%" border="0" align="right" cellpadding="0" cellspacing="0" style="margin-bottom: 25px;">
                                <tr>
                                    <td align="left">
                                        <table width="98%" align="left" cellpadding="0" cellspacing="0" style="margin: 25px 0 0 0;">
                                            <tr>
                                                <td align="left" valign="top" class="style13">
                                                    CREATE CATEGORY
                                                </td>
                                                <td width="198" height="35" align="right" valign="middle" class="style4">
                                                </td>
                                            </tr>
                                            </TBODY>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="left">
                                        <table width="535" border="0" align="center" cellpadding="0" cellspacing="0">
                                            <tr>
                                                <td height="10">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="520" align="left" valign="top">
                                                    <table width="90%" border="0" cellspacing="0" cellpadding="0">
                                                        <tr>
                                                            <td width="225" align="left" valign="middle" class="fields">
                                                                CATEGORY NAME:
                                                            </td>
                                                            <td width="147" align="left" valign="middle">
                                                                <asp:TextBox ID="txtcategory" runat="server" Width="147" class="fields"></asp:TextBox>
                                                            </td>
                                                            <td width="142">
                                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtcategory"
                                                                    ErrorMessage="*" ValidationGroup="ok"></asp:RequiredFieldValidator>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td width="225" align="left" valign="middle" class="fields">
                                                                &nbsp;
                                                            </td>
                                                            <td width="147" align="left" valign="middle">
                                                                &nbsp;
                                                            </td>
                                                            <td width="142">
                                                                &nbsp;
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td height="15" colspan="3" align="left" valign="middle" class="fields">
                                                                &nbsp;
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td colspan="3" align="center" valign="middle">
                                                                <table width="82%" border="0" cellspacing="0" cellpadding="0">
                                                                    <tr>
                                                                        <td align="left" valign="middle">
                                                                            &nbsp;
                                                                        </td>
                                                                        <td width="60">
                                                                            <asp:Button ID="btnsubmit" runat="server" Text="Submit" OnClick="btnsubmit_Click" />
                                                                        </td>
                                                                        <td align="right" valign="middle">
                                                                            &nbsp;
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td height="60" colspan="3" align="left" valign="middle">
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="left" valign="middle">
                                                                &nbsp;
                                                            </td>
                                                            <td>
                                                                &nbsp;
                                                            </td>
                                                            <td align="left" valign="middle">
                                                                <a style="border: none;" class="thickbox">&nbsp;</a>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <table align="center" border="0" cellpadding="0" cellspacing="0" width="535">
                                                        <tr>
                                                            <td height="10">
                                                                <asp:TextBox ID="txtsearch" runat="server"></asp:TextBox>
                                                                <asp:Button ID="Submit" runat="server" Text="Button" />
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="left" valign="top" width="520">
                                                                <table border="0" cellpadding="0" cellspacing="0" width="90%">
                                                                    <tr>
                                                                        <td align="center" colspan="3" height="15" valign="middle">
                                                                            <h1>
                                                                                <asp:GridView ID="gvcategory" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                                                                    CellPadding="5" DataKeyNames="CategoryId" OnPageIndexChanging="gvcategory_PageIndexChanging"
                                                                                    OnRowDeleting="gvcategory_RowDeleting" OnRowEditing="gvcategory_RowEditing" Width="80%">
                                                                                    <HeaderStyle CssClass="Head" />
                                                                                    <RowStyle CssClass="rowtext" />
                                                                                    <Columns>
                                                                                        <asp:TemplateField HeaderText="ID" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="7%">
                                                                                            <ItemTemplate>
                                                                                                <%#Container.DataItemIndex+1 %>
                                                                                            </ItemTemplate>
                                                                                            <ItemStyle HorizontalAlign="Center" Width="7%" />
                                                                                        </asp:TemplateField>
                                                                                        <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" ItemStyle-HorizontalAlign="Left">
                                                                                            <ItemStyle HorizontalAlign="Left" />
                                                                                        </asp:BoundField>
                                                                                        <asp:CommandField ControlStyle-CssClass="link" ItemStyle-HorizontalAlign="Center"
                                                                                            ShowEditButton="True">
                                                                                            <ControlStyle CssClass="link" />
                                                                                            <ItemStyle HorizontalAlign="Center" />
                                                                                        </asp:CommandField>
                                                                                        <asp:CommandField ControlStyle-CssClass="link" ItemStyle-HorizontalAlign="Center"
                                                                                            ShowDeleteButton="True">
                                                                                            <ControlStyle CssClass="link" />
                                                                                            <ItemStyle HorizontalAlign="Center" />
                                                                                        </asp:CommandField>
                                                                                    </Columns>
                                                                                </asp:GridView>
                                                                            </h1>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td align="center" colspan="3" valign="middle">
                                                                            <table border="0" cellpadding="0" cellspacing="0" width="82%">
                                                                                <tr>
                                                                                    <td width="60">
                                                                                        &nbsp;
                                                                                    </td>
                                                                                </tr>
                                                                            </table>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td align="left" colspan="3" height="60" valign="middle">
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td align="left" valign="middle">
                                                                            &nbsp;
                                                                        </td>
                                                                        <td>
                                                                            &nbsp;
                                                                        </td>
                                                                        <td align="left" valign="middle">
                                                                           
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                &nbsp;
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="left" valign="top">
                                                                &nbsp;
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="left" valign="top">
                                                    &nbsp;
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</asp:Content>
 







Product Catelog App class in asp.net c# -3


 Abstract  Connection Class

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

/// <summary>
/// Summary description for Connection
/// </summary>
public class Connection
{
    SqlConnection sqlcon = new SqlConnection();
    string sqlConnect;

    public Connection()
    {
        sqlConnect = ConfigurationManager.ConnectionStrings["connsql"].ConnectionString;
    }

    protected SqlConnection FetchConnection()
    {
        sqlcon = new SqlConnection(sqlConnect);
        return sqlcon;

    }
}

Product Catelog App class in asp.net c# -2


DALCategoryMaster.cs

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;

/// <summary>
/// Summary description for DALCategoryMaster
/// </summary>
public class DALCategoryMaster : Connection
{

    SqlConnection sqlcon = new SqlConnection();

    public DALCategoryMaster()
    {
        sqlcon = FetchConnection();
    }
    
    public DataTable SelectCategory()
    {
        sqlcon = FetchConnection();
        DataTable dt = new DataTable();
        string cate = "select * from tbl_category";
        SqlDataAdapter da = new SqlDataAdapter(cate, sqlcon);
        da.SelectCommand.CommandType = CommandType.Text;
        da.Fill(dt);
        return dt;
    }
    public void insert_CategoryMaster(BALCategoryMaster bal)
    {
        string insert = "insert into tbl_category (category) values (@category)";
        SqlCommand sqlCmd = new SqlCommand(insert, sqlcon);
        sqlCmd.CommandType = CommandType.Text;

        SqlParameter paraCategoryName = new SqlParameter("@Category", SqlDbType.VarChar);
        paraCategoryName.Value = bal.CategoryName;
        sqlCmd.Parameters.Add(paraCategoryName);

        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }

        sqlCmd.ExecuteNonQuery();
        sqlcon.Close();
    }
    public DataTable Select_CategoryMaster()
    {
        string str = "select * from tbl_category order by id asc";
        SqlCommand sqlCmd = new SqlCommand(str, sqlcon);
        sqlCmd.CommandType = CommandType.Text;
        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }
        DataSet ds = new DataSet();
        SqlDataAdapter adp = new SqlDataAdapter(str, sqlcon);
        adp.Fill(ds);
        sqlcon.Close();
        return ds.Tables[0];
    }
    public DataTable Select_CategoryMasterSearch(string search)
    {
        string str = "select * from tbl_category where category like '%[" + search + "]%' order by id asc";
        SqlCommand sqlCmd = new SqlCommand(str, sqlcon);
        sqlCmd.CommandType = CommandType.Text;
        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }
        DataSet ds = new DataSet();
        SqlDataAdapter adp = new SqlDataAdapter(str, sqlcon);
        adp.Fill(ds);
        sqlcon.Close();
        return ds.Tables[0];
    }
    public void delete_CategoryMaster(BALCategoryMaster bal)
    {
        string delete = "delete from tbl_category where id=@CategoryId";
        SqlCommand sqlCmd = new SqlCommand(delete, sqlcon);
        sqlCmd.CommandType = CommandType.Text;
        SqlParameter CategoryId = new SqlParameter("@CategoryId", SqlDbType.Int);
        CategoryId.Value = bal.CategoryId;
        sqlCmd.Parameters.Add(CategoryId);
        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }
        sqlCmd.ExecuteNonQuery();
        sqlcon.Close();
    }
    public void update_CategoryMaster(BALCategoryMaster bal)
    {
        string str = "update tbl_category set category=@CategoryName where id=@CategoryId";
        SqlCommand sqlCmd = new SqlCommand(str, sqlcon);
        sqlCmd.CommandType = CommandType.Text;
        SqlParameter paraCategoryName = new SqlParameter("@CategoryName", SqlDbType.VarChar);
        paraCategoryName.Value = bal.CategoryName;
        sqlCmd.Parameters.Add(paraCategoryName);
        SqlParameter paraCategoryId = new SqlParameter("@CategoryId", SqlDbType.Int);
        paraCategoryId.Value = bal.CategoryId;
        sqlCmd.Parameters.Add(paraCategoryId);
        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }
        try
        {
            sqlCmd.ExecuteNonQuery();
        }
        catch (SqlException xe)
        {

        }
        sqlcon.Close();

    }
    public DataTable select_CategoryMasterByCategoryId(BALCategoryMaster bal)
    {
        string strcat = "select * from tbl_category where id=@CategoryId";
        SqlCommand sqlCmd = new SqlCommand(strcat, sqlcon);
        sqlCmd.CommandType = CommandType.Text;
        SqlParameter CategoryId = new SqlParameter("@CategoryId", SqlDbType.Int);
        CategoryId.Value = bal.CategoryId;
        sqlCmd.Parameters.Add(CategoryId);
        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }
        DataTable dt = new DataTable();
        SqlDataAdapter adp = new SqlDataAdapter(sqlCmd);
        adp.Fill(dt);
        sqlcon.Close();
        return dt;
    }
}






DALProductMaster.cs

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
/// <summary>
/// Summary description for DALProductMaster
/// </summary>
public class DALProductMaster : Connection
{
    SqlConnection sqlcon = new SqlConnection();

    public DALProductMaster()
    {
        sqlcon = FetchConnection();
    }

    public void insert_ProductMaster(BALProductMaster bal)
    {
        string insert = "insert into tbl_product (productname,productcode,cat_id,image,detail) values (@productname,@productcode,@cat_id,@image,@detail)";
        SqlCommand sqlCmd = new SqlCommand(insert, sqlcon);
        sqlCmd.CommandType = CommandType.Text;
        SqlParameter paraCategoryName = new SqlParameter("@productname", SqlDbType.VarChar);
        paraCategoryName.Value = bal.ProductName;
        sqlCmd.Parameters.Add(paraCategoryName);

        SqlParameter paraCategorycode = new SqlParameter("@productcode", SqlDbType.VarChar);
        paraCategorycode.Value = bal.ProductCode;
        sqlCmd.Parameters.Add(paraCategorycode);

        SqlParameter cat_id = new SqlParameter("@cat_id", SqlDbType.Int);
        cat_id.Value = bal.CategoryId;
        sqlCmd.Parameters.Add(cat_id);

        SqlParameter image = new SqlParameter("@image", SqlDbType.VarChar);
        image.Value = bal.Image;
        sqlCmd.Parameters.Add(image);

        SqlParameter detail = new SqlParameter("@detail", SqlDbType.VarChar);
        detail.Value = bal.Detail;
        sqlCmd.Parameters.Add(detail);

        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }

        sqlCmd.ExecuteNonQuery();
        sqlcon.Close();
    }
    public DataTable Select_ProductMaster()
    {
        string str = "select * from tbl_product order by id desc";
        SqlCommand sqlCmd = new SqlCommand(str, sqlcon);
        sqlCmd.CommandType = CommandType.Text;
        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }
        DataSet ds = new DataSet();
        SqlDataAdapter adp = new SqlDataAdapter(str, sqlcon);
        adp.Fill(ds);
        sqlcon.Close();
        return ds.Tables[0];
    }

    public void delete_ProductMaster(BALProductMaster bal)
    {
        string delete = "delete from tbl_Product where id=@ProductID";
        SqlCommand sqlCmd = new SqlCommand(delete, sqlcon);
        sqlCmd.CommandType = CommandType.Text;
        SqlParameter ProductID = new SqlParameter("@ProductID", SqlDbType.Int);
        ProductID.Value = bal.ProductID;
        sqlCmd.Parameters.Add(ProductID);
        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }
        sqlCmd.ExecuteNonQuery();
        sqlcon.Close();
    }

    public void updateR_ProductMaster(BALProductMaster bal)
    {
        string str = "update tbl_product set productname=@productname,productcode=@productcode,cat_id=@cat_id,image=@image,detail=@detail where id=@ProductID";
        SqlCommand sqlCmd = new SqlCommand(str, sqlcon);
        sqlCmd.CommandType = CommandType.Text;

        SqlParameter productid = new SqlParameter("@ProductID", SqlDbType.Int);
        productid.Value = bal.ProductID;
        sqlCmd.Parameters.Add(productid);

        SqlParameter paraCategoryName = new SqlParameter("@productname", SqlDbType.VarChar);
        paraCategoryName.Value = bal.ProductName;
        sqlCmd.Parameters.Add(paraCategoryName);

        SqlParameter paraCategorycode = new SqlParameter("@productcode", SqlDbType.VarChar);
        paraCategorycode.Value = bal.ProductCode;
        sqlCmd.Parameters.Add(paraCategorycode);

        SqlParameter cat_id = new SqlParameter("@cat_id", SqlDbType.Int);
        cat_id.Value = bal.CategoryId;
        sqlCmd.Parameters.Add(cat_id);


        SqlParameter image = new SqlParameter("@image", SqlDbType.VarChar);
        image.Value = bal.Image;
        sqlCmd.Parameters.Add(image);

        SqlParameter detail = new SqlParameter("@detail", SqlDbType.VarChar);
        detail.Value = bal.Detail;
        sqlCmd.Parameters.Add(detail);

        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }
        try
        {
            sqlCmd.ExecuteNonQuery();
        }
        catch (SqlException ex)
        {

        }
        sqlcon.Close();

    }

    public DataTable select_ProductMasterByProductId(BALProductMaster bal)
    {
        string strcat = "select * from tbl_product where id=@ProductId";
        SqlCommand sqlCmd = new SqlCommand(strcat, sqlcon);
        sqlCmd.CommandType = CommandType.Text;
        SqlParameter CategoryId = new SqlParameter("@ProductId", SqlDbType.Int);
        CategoryId.Value = bal.ProductID;
        sqlCmd.Parameters.Add(CategoryId);
        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }
        DataTable dt = new DataTable();
        SqlDataAdapter adp = new SqlDataAdapter(sqlCmd);
        adp.Fill(dt);
        sqlcon.Close();
        return dt;

    }
    public void Image_remove(BALProductMaster bal)
    {
        string updateimage = "update tbl_product set image=@image where id=@productid";
        SqlCommand sqlCmd = new SqlCommand(updateimage, sqlcon);
        sqlCmd.CommandType = CommandType.Text;
        SqlParameter ProductID = new SqlParameter("@productid", SqlDbType.VarChar);
        ProductID.Value = bal.ProductID;
        sqlCmd.Parameters.Add(ProductID);

        SqlParameter image = new SqlParameter("@image", SqlDbType.VarChar);
        image.Value = "";
        sqlCmd.Parameters.Add(image);

        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }
        sqlCmd.ExecuteNonQuery();
        sqlcon.Close();
    }
    public DataTable Select_ProductMasterSearch(string search)
    {
        string str = "select * from tbl_product where productname like '%[" + search + "]%' order by id asc";
        SqlCommand sqlCmd = new SqlCommand(str, sqlcon);
        sqlCmd.CommandType = CommandType.Text;
        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }
        DataSet ds = new DataSet();
        SqlDataAdapter adp = new SqlDataAdapter(str, sqlcon);
        adp.Fill(ds);
        sqlcon.Close();
        return ds.Tables[0];
    }
    public DataTable selectR_ProductMasterByCategoryId(BALCategoryMaster bal)
    {
        string strcat = "select * from tbl_product where cate_id=@CategoryID";
        SqlCommand sqlCmd = new SqlCommand(strcat, sqlcon);
        sqlCmd.CommandType = CommandType.Text;
        SqlParameter CategoryId = new SqlParameter("@CategoryID", SqlDbType.Int);
        CategoryId.Value = bal.CategoryId;
        sqlCmd.Parameters.Add(CategoryId);
        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }
        DataTable dt = new DataTable();
        SqlDataAdapter adp = new SqlDataAdapter(sqlCmd);
        adp.Fill(dt);
        sqlcon.Close();
        return dt;

    }

}

 

Product Catelog App class in asp.net c# -1


BALCategoryMaster.cs

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
/// <summary>
/// Summary description for BALCategoryMaster
/// </summary>
public class BALCategoryMaster
{
    private int _CategoryId;
    public int CategoryId
    {
        get { return _CategoryId; }
        set { _CategoryId = value; }
    }
    private string _CategoryName;
    public string CategoryName
    {
        get { return _CategoryName; }
        set { _CategoryName = value; }
    }
}

BALProductMaster.cs


using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for BALProductMaster
/// </summary>
public class BALProductMaster
{
    public BALProductMaster()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    private string _ProductName;
    public string ProductName
    {
        get { return _ProductName; }
        set { _ProductName = value; }
    }
    private int _ProductID;
    public int ProductID
    {
        get { return _ProductID; }
        set { _ProductID = value; }
    }

    private string _ProductCode;
    public string ProductCode
    {
        get { return _ProductCode; }
        set { _ProductCode = value; }
    }
    private int _CategoryId;
    public int CategoryId
    {
        get { return _CategoryId; }
        set { _CategoryId = value; }
    }
    private string _Image;
    public string Image
    {
        get { return _Image; }
        set { _Image = value; }
    }
    private string _Detail;
    public string Detail
    {
        get { return _Detail; }
        set { _Detail = value; }
    }
}


Dropbox API For asp.net c#

static public class FileUtils
    {
        public enum FolderMode
        {
            /// <summary>
            /// Operate on sub-folders recursively
            /// </summary>
            Recursive,

            /// <summary>
            /// Operate on just the specified folder
            /// </summary>
            NonRecursive,
        }

        public enum CopyFileMode
        {
            /// <summary>
            /// Replace all existing files
            /// </summary>
            Replace,

            /// <summary>
            /// Replace existing files if the file write date is newer
            /// </summary>
            ReplaceIfNewer,

            /// <summary>
            /// Do not replace existing files
            /// </summary>
            SkipIfExists
        }

        /// <summary>
        /// Copy a folder to another folder with optional recursive behavior.
        /// </summary>
        static public void CopyFolder(string source, string dest, FolderMode mode, CopyFileMode fileMode)
        {
            DirectoryInfo sourceDI = new DirectoryInfo(source);
            DirectoryInfo destDI = new DirectoryInfo(dest);

            CopyFolder(sourceDI, destDI, mode, fileMode);
        }

        /// <summary>
        /// Create a folder if it does not exist
        /// </summary>
        static public void CreateFolderIfDoesNotExist(string path)
        {
            DirectoryInfo di = new DirectoryInfo(Path.GetDirectoryName(path));
            if (!di.Exists)
            {
                di.Create();
            }
        }

        /// <summary>
        /// Moves a folder to another location. If the folders are on different volumes,
        /// the source folder will be copied to the destination folder then deleted.
        /// </summary>
        static public void MoveFolder(string source, string dest)
        {
            MoveFolder(new DirectoryInfo(source), new DirectoryInfo(dest));
        }

        /// <summary>
        /// Moves a folder to another location. If the folders are on different volumes,
        /// the source folder will be copied to the destination folder then deleted.
        /// </summary>
        static public void MoveFolder(DirectoryInfo source, DirectoryInfo dest)
        {
            if (source.Root == dest.Root)
            {
                source.MoveTo(dest.FullName);
            }
            else
            {
                dest.Create();
                CopyFolder(source, dest, FolderMode.Recursive, CopyFileMode.Replace);
                DeleteFolder(source.FullName);
            }
        }

        /// <summary>
        /// Copy a folder to another folder with optional recursive behavior.
        /// </summary>
        static public void CopyFolder(DirectoryInfo sourceInfo, DirectoryInfo destInfo, FolderMode mode, CopyFileMode fileMode)
        {
            if (!destInfo.Exists)
            {
                destInfo.Create();
            }

            foreach (FileInfo fi in sourceInfo.GetFiles())
            {
                CopyFile(fi, destInfo, fileMode);
            }

            if (mode == FolderMode.Recursive)
            {
                foreach (DirectoryInfo di in sourceInfo.GetDirectories())
                {
                    DirectoryInfo childDestDir = new DirectoryInfo(destInfo.FullName + "\\" + di.Name);
                    CopyFolder(di, childDestDir, mode, fileMode);
                }
            }
        }

        /// <summary>
        /// Copy a list of specified files.
        /// </summary>
        static public void CopyFiles(string sourceDir, string destDir, List<string> relativeFiles, CopyFileMode fileMode)
        {
            foreach (string file in relativeFiles)
            {
                FileInfo sourceInfo = new FileInfo(sourceDir + "\\" + file);
                DirectoryInfo destInfo = new DirectoryInfo(Path.GetDirectoryName(destDir + "\\" + file));

                CopyFile(sourceInfo, destInfo, fileMode);
            }
        }

        /// <summary>
        /// Copy a specified file.
        /// </summary>
        /// <param name="source">Source file or directory</param>
        /// <param name="dest">Destination file or directory</param>
        static public void CopyFile(string source, string dest, CopyFileMode mode)
        {
            FileInfo sourceInfo = new FileInfo(source);
            if (!sourceInfo.Exists)
            {
                return;
            }

            DirectoryInfo destInfo = new DirectoryInfo(dest);

            CopyFile(sourceInfo, destInfo, mode);
        }

        /// <summary>
        /// Copy a specified file.
        /// </summary>
        /// <param name="sourceInfo">Source file to copy.</param>
        /// <param name="destInfo">Destination directory.</param>
        static public void CopyFile(System.IO.FileInfo sourceInfo, System.IO.DirectoryInfo destInfo, CopyFileMode mode)
        {
            System.Diagnostics.Debug.Assert(sourceInfo.Exists == true, "Source file does not exist!");

            // Avoid a missing folder exception
            if (!destInfo.Exists)
            {
                destInfo.Create();
            }

            // Avoid copying over a read only file exception
            FileInfo destPathInfo = new FileInfo(destInfo.FullName + "\\" + sourceInfo.Name);

            if (destPathInfo.Exists)
            {
                if (mode == CopyFileMode.Replace ||
                    (mode == CopyFileMode.ReplaceIfNewer && destPathInfo.LastWriteTime < sourceInfo.LastWriteTime))
                {
                    destPathInfo.IsReadOnly = false;
                    destPathInfo.Delete();
                }
                else // SkipIfExists or ReplaceIfNewer fails
                {
                    return;
                }
            }

            // Perform the actual copy
            sourceInfo.CopyTo(destPathInfo.FullName, true);
        }

        /// <summary>
        /// Make the specified file read/writable
        /// </summary>
        static public void MakeFileWritable(System.IO.FileInfo fileInfo)
        {
            if (fileInfo.Exists)
            {
                fileInfo.IsReadOnly = false;
            }
        }

        /// <summary>
        /// Make the specified file read/writable
        /// </summary>
        static public void MakeFolderContentsWritable(System.IO.DirectoryInfo dirInfo, FolderMode mode)
        {
            foreach (FileInfo fi in dirInfo.GetFiles())
            {
                MakeFileWritable(fi);
            }

            if (mode == FolderMode.Recursive)
            {
                foreach (DirectoryInfo di in dirInfo.GetDirectories())
                {
                    DirectoryInfo childDestDir = new DirectoryInfo(dirInfo.FullName + "\\" + di.Name);
                    MakeFolderContentsWritable(childDestDir, mode);
                }
            }
        }

        /// <summary>
        /// Delete the specified folder (and any sub-folders/files)
        /// </summary>
        static public void DeleteFolder(string dir)
        {
            DeleteFolder(new DirectoryInfo(dir));
        }

        /// <summary>
        /// Delete the specified folder (and any sub-folders/files)
        /// </summary>
        static public void DeleteFolder(DirectoryInfo dirInfo)
        {
            if (dirInfo.Exists)
            {
                MakeFolderContentsWritable(dirInfo, FolderMode.Recursive);
                dirInfo.Delete(true);
            }
        }

        /// <summary>
        /// Given a directory select a random file from it.
        /// </summary>
        static public string SelectRandomFileFromFolder(string folderName)
        {
            DirectoryInfo di = new DirectoryInfo(folderName);

            if (di.Exists)
            {
                FileInfo[] files = di.GetFiles();
                if (files.Length > 0)
                {
                    Random randGenerator = new Random();
                    int index = randGenerator.Next(0, files.Length - 1);
                    return files[index].FullName;
                }
            }

            return null;
        }
      
        /// <summary>
        /// Computes the MD5 checksum for a single file.
        /// </summary>
        public static string ComputeMD5ForFile(string file)
        {
            FileInfo finfo = new FileInfo(file);
            BinaryReader br = new BinaryReader(finfo.OpenRead());
            byte[] fileBytes = br.ReadBytes((int)finfo.Length);
            br.Close();

            MD5 hasher = MD5.Create();
            byte[] hash = hasher.ComputeHash(fileBytes);

            StringBuilder hashString = new StringBuilder();
            foreach (byte b in hash)
            {
                hashString.Append(b.ToString("x2"));
            }
            return hashString.ToString();
        }
    }