Friday, December 20, 2013

dfdfdgfdgf

using System;

using System.Data;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data.SqlClient;

using System.Web.Services;

using System.Configuration;

using Business;

public partial class admin_vproduct : System.Web.UI.Page



{

private static int PageSize = 10;

protected void Page_Load(object sender, EventArgs e)



{

if (!IsPostBack)



{

BindDummyRow();

}

}

private void BindDummyRow()



{

DataTable dummy = new DataTable();

dummy.Columns.Add("ProductID");

dummy.Columns.Add("ProductCode");

dummy.Columns.Add("Isactive");

dummy.Columns.Add("del");

dummy.Columns.Add("Edt");



dummy.Rows.Add();

gvProducts.DataSource = dummy;

gvProducts.DataBind();

}

[WebMethod]

public static int ActiveProduct(int ProductId)



{

Product objproduct = new Product();

objproduct.ActiveInActiveProduct(Convert.ToInt32(ProductId));

return 1;



}

[WebMethod]

public static int DelProduct(int ProductId)



{

Product objproduct = new Product();

objproduct.DeleteProduct(Convert.ToInt32(ProductId));

return 1;



}

[WebMethod]

public static string GetProduct(int pageIndex)



{

string query = "[GetProducts_Pager]";

SqlCommand cmd = new SqlCommand(query);

cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.AddWithValue("@PageIndex", pageIndex);

cmd.Parameters.AddWithValue("@PageSize", PageSize);

cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 4).Direction = ParameterDirection.Output;

return GetData(cmd, pageIndex).GetXml();



}

[WebMethod]

public static string GetProduct1(int pageIndex, string strSearch)



{

// string strSearch = "STV151";

string query = "[GetProducts_Pager_search]";

SqlCommand cmd = new SqlCommand(query);

cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.AddWithValue("@strSearch", strSearch);

cmd.Parameters.AddWithValue("@PageIndex", pageIndex);

cmd.Parameters.AddWithValue("@PageSize", PageSize);

cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 4).Direction = ParameterDirection.Output;

return GetData(cmd, pageIndex).GetXml();



}

private static DataSet GetData(SqlCommand cmd, int pageIndex)



{

string strConnString = ConfigurationManager.ConnectionStrings["STVConnectionString"].ConnectionString;

using (SqlConnection con = new SqlConnection(strConnString))



{

using (SqlDataAdapter sda = new SqlDataAdapter())



{

cmd.Connection = con;

sda.SelectCommand = cmd;

using (DataSet ds = new DataSet())



{

sda.Fill(ds, "Products");

DataTable dt = new DataTable("Pager");

dt.Columns.Add("PageIndex");

dt.Columns.Add("PageSize");

dt.Columns.Add("RecordCount");



dt.Rows.Add();

dt.Rows[0]["PageIndex"] = pageIndex;

dt.Rows[0]["PageSize"] = PageSize;

dt.Rows[0]["RecordCount"] = cmd.Parameters["@RecordCount"].Value;



ds.Tables.Add(dt);

return ds;



 

}

}

}

}

public List<CountryInfo> CountryInformation { get; set; }

[WebMethod]

public List<CountryInfo> LoadCountry()



{

CountryInfo ci = new CountryInfo();

List<CountryInfo> CountryInformation = new List<CountryInfo>();

DataSet ds;

using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["STVConnectionString"].ConnectionString))



{

using (SqlCommand cmd = new SqlCommand("select CategoryId ,CategoryName from tblCategoryDetail where CategoryId in (select categoryid from tblCategory where SubCategoryId=0)", con))



{

con.Open();

cmd.Connection = con;

cmd.CommandType = CommandType.Text;

using (SqlDataAdapter da = new SqlDataAdapter(cmd))



{

ds = new DataSet();



da.Fill(ds);

}

}

}

try



{

if (ds != null)



{

if (ds.Tables.Count > 0)



{

if (ds.Tables[0].Rows.Count > 0)



{

foreach (DataRow dr in ds.Tables[0].Rows)



{

CountryInformation.Add(new CountryInfo()



{

CategoryId = Convert.ToInt32(dr["CategoryId"]),

CategoryName = dr["CategoryName"].ToString()



});

}

}

}

}

}

catch (Exception ex)



{

throw ex;



}

return CountryInformation;



}

}

public class CountryInfo



{

public int CategoryId { get; set; }

public string CategoryName { get; set; }



}

No comments:

Post a Comment