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 Admin_SubCategoryManagement : System.Web.UI.Page
{
DAL dal = new DAL();
protected void Page_Load(object sender, EventArgs e)
{
if (Request["i"] != null)
{
if (Request["i"].ToString() == "1")
{
td_gridder.Visible = false;
td_editter.Visible = true;
}
else if (Request["i"].ToString() == "2")
{
td_gridder.Visible = true;
td_editter.Visible = false;
}
}
else
{
Response.Redirect("Default.aspx");
}
if (!IsPostBack)
{
dal.FillCombo(ddl_Category, "ProductCategory_Master_Sp 's'", "Category", "PK_ID", "--select Category--", 0);
}
if (ViewState["PK_ID"] != null)
{
btn_edit.Visible = true;
btn_save.Visible = false;
}
else
{
btn_edit.Visible = false;
btn_save.Visible = true;
}
}
protected void ddl_Category_Indexchanged(object sender, EventArgs e)
{
if (ddl_Category.SelectedIndex != 0)
{
dal.FillGrid(grd_News, "ProductSubCategroy_Master_Sp 's','','" + ddl_Category.SelectedValue + "'");
}
else
{
grd_News.DataSource = null;
grd_News.DataBind();
}
}
protected void btn_save_Click(object sender, EventArgs e)
{
if (ddl_Category.SelectedIndex != 0)
{
dal.PutData("ProductSubCategroy_Master_Sp 'i','','" + ddl_Category.SelectedValue + "','" + txt_title.Text + "'");
dal.FillGrid(grd_News, "ProductSubCategroy_Master_Sp 's','','" + ddl_Category.SelectedValue + "'");
}
}
protected void btn_edit_Click(object sender, EventArgs e)
{
dal.PutData("ProductSubCategroy_Master_Sp 'u','" + ViewState["PK_ID"] + "','" + ddl_Category.SelectedValue + "','" + txt_title.Text + "'");
dal.FillGrid(grd_News, "ProductSubCategroy_Master_Sp 's','','" + ddl_Category.SelectedValue + "'");
ControlClear();
btn_edit.Visible = false;
btn_save.Visible = true;
td_gridder.Visible = true;
td_editter.Visible = false;
}
private void ControlClear()
{
txt_title.Text = string.Empty;
ViewState["PK_ID"] = null;
}
protected void btn_cancel_Click(object sender, EventArgs e)
{
ControlClear();
}
protected void btn_grd_delete_click(object sender, CommandEventArgs e)
{
dal.PutData("ProductSubCategroy_Master_Sp 'd','" + e.CommandArgument.ToString() + "'");
dal.FillGrid(grd_News, "ProductSubCategroy_Master_Sp 's','','" + ddl_Category.SelectedValue + "'");
}
protected void btn_grd_edit_click(object sender, CommandEventArgs e)
{
ViewState["PK_ID"] = e.CommandArgument.ToString();
DataTable dt = new DataTable();
dt = dal.GetDataTable("ProductSubCategroy_Master_Sp 'e','" + ViewState["PK_ID"].ToString() + "'");
txt_title.Text = dt.Rows[0]["SubCategory"].ToString();
btn_edit.Visible = true;
btn_save.Visible = false;
td_gridder.Visible = false;
td_editter.Visible = true;
}
}