Click here to Skip to main content
16,007,610 members
Home / Discussions / C#
   

C#

 
Questiondisplay a dialog in another dialog Pin
nathan729-Apr-07 20:46
nathan729-Apr-07 20:46 
AnswerRe: display a dialog in another dialog Pin
Colin Angus Mackay29-Apr-07 21:45
Colin Angus Mackay29-Apr-07 21:45 
Questionneed help for converting c# code to c++ Pin
MIsahq29-Apr-07 20:16
MIsahq29-Apr-07 20:16 
AnswerRe: need help for converting c# code to c++ Pin
Christian Graus29-Apr-07 23:13
protectorChristian Graus29-Apr-07 23:13 
GeneralRe: need help for converting c# code to c++ Pin
MIsahq30-Apr-07 4:20
MIsahq30-Apr-07 4:20 
GeneralRe: need help for converting c# code to c++ Pin
Christian Graus30-Apr-07 11:13
protectorChristian Graus30-Apr-07 11:13 
Questiontree view in C#.Net Pin
Shahid Ahmed29-Apr-07 20:14
Shahid Ahmed29-Apr-07 20:14 
AnswerRe: tree view in C#.Net Pin
manoharseetha29-Apr-07 21:19
manoharseetha29-Apr-07 21:19 
below code should be written in code behind i.e .ascx.cs
----------------------------------------------------------------------------
public partial class PresentationTier_Controls_MenuCreationControl : System.Web.UI.UserControl
{
//Creating Object for Class
MenuCreationBLL obj = new MenuCreationBLL();
UserCreationBLL uc = new UserCreationBLL();

//Variable Declarions
int childid = 1;
string Who; //CreatedBy
int ClientId;
string f1;
string f2;
string i1;
string i2;
string ids = "";
string RoleName = "";
static string s = "";
public int Count1;
public int Count2;
public static int pqr;
public static string flag2;
public static int c1;
public static int cout = 0;
public static int cout1 = 0;
public static string abc = "";
public static int count = 0;
public static int child;
public static int menuid;
public static int reply;
public static int aaa;
public static int val;
public static int val1;
public static int bbb;
public static int flg3;
public static int pid;
public static int threaddown;
public static int replyup;
public static int replydown;
public static int meid;
public static DataTable dt = new DataTable();
public static DataTable dt1 = new DataTable();
public DataTable myDataTable = new DataTable();
public static DataTable MyDtab = new DataTable();
public static DataTable MyDset = new DataTable();
public static DataView threads = new DataView();
DataTable dt2 = new DataTable();
DataView dv = new DataView();
string tempnme;

public static DataTable dt3 = new DataTable();
public static DataTable dsrole = new DataTable();



//*****************************PageLoad****************************************************//
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Session.Count > 0)
{
tempnme = "";
Who = Session["SAName"].ToString();

ClientId = Convert.ToInt32(Session["SClientId"].ToString());
btnSubmit.Attributes.Add("onclick", "return validation();");
Edit.Attributes.Add("onclick", "return Message();");
AddSibling.Attributes.Add("onclick", "return Message();");
AddChild.Attributes.Add("onclick", "return Message();");
MoveUp.Attributes.Add("onclick", "return Message();");
MoveDown.Attributes.Add("onclick", "return Message();");
Delete.Attributes.Add("onclick", "return Message();");

if (!IsPostBack)
{
meid = 0;
pqr = 0;
threaddown = 0;
aaa = 0;
bbb = 0;
PopulateNodes();
s = "";
TreeView1.ExpandDepth = 0;
GetStatus();
GetTemplate();
DisplayErr();
table2.Attributes.Add("style", "Display:block");

}
}
else
{
Response.Redirect("~/AdminLogin.aspx");
}
}


catch (Exception ex)
{
lblErrorMessage.Text = ex.Message;
}

if (ddlMenuStatus.SelectedItem.Text == "Drafts")
{
QLink.Attributes.Add("style", "Display:none");
chkQuickLinks.Checked = false;
}
if (ddlMenuStatus.SelectedItem.Text == "Backoffice" || ddlMenuStatus.SelectedItem.Text == "Active")
{
QLink.Attributes.Add("style", "Display:block");
QLink.Focus();
}
if (ddlMenuStatus.SelectedItem.Text == "--Choose--")
{
chkQuickLinks.Checked = false;
}


}
//*****************************************************************************************//
// For TreeView Display
//*****************************************************************************************//
public void PopulateNodes()
{
try
{
TreeView1.Nodes.Clear();
DataTable MName = obj.GetAllMenus(1, ClientId,tempnme);
threads = GetThreads(MName);

menuid = Convert.ToInt32(threads.Table.Rows[0]["MenuId"].ToString());
foreach (DataRowView row in threads)
{
TreeNode threadNode = new TreeNode();
threadNode.Text = row["MenuName"].ToString();
threadNode.Value = row["MenuId"].ToString();

threaddown++;
val = Convert.ToInt32(threadNode.Value);

if (threaddown == 2)
{
menuid = Convert.ToInt32(threadNode.Value);
}
if (threaddown == row.DataView.Count)
{
threaddown = Convert.ToInt32(threadNode.Value);
}

if (row.DataView.Count == 1)
{
threaddown = Convert.ToInt32(threadNode.Value);
menuid = Convert.ToInt32(threadNode.Value);
}
if (Convert.ToInt32(threadNode.Value) == pqr)
{
threadNode.Expand();
cout = 1;
abc += Convert.ToString(threadNode.Value) + ",";
count = 1;
}
TreeView1.Nodes.Add(threadNode);
reply = 0;
AddReplies(MName, threadNode);
if (val1 == Convert.ToInt32(threadNode.Value))
{
threadNode.Expand();
}
}
if (count == 1)
{
Hidegrid.Attributes.Add("style", "Display:block");
}
if (pqr != 0)
{
displayGrid();
}
table2.Attributes.Add("style", "Display:none");
}
catch (Exception ex)
{
lblErrorMessage.Text = ex.Message;
}
}
//************************
//********************************************************//
//Get Threads in TreeView
//********************************************************************************//
public DataView GetThreads(DataTable discuss)
{
DataView view = new DataView(discuss);
view.RowFilter = "ParentId=0";
int w = view.Table.Rows.Count;
return view;
}

//********************************************************************************//
// Add Replies in TreeView *//
//********************************************************************************//
public void AddReplies(DataTable messages, TreeNode node)
{
try
{

DataView replies = GetReplies(messages, node.Value);
foreach (DataRowView row in replies)
{
aaa = Convert.ToInt32(obj.GetMaxCount(Convert.ToInt32(node.Value), 1));
bbb = Convert.ToInt32(obj.GetMaxCount(Convert.ToInt32(node.Value), 2));
TreeNode replyNode = new TreeNode();
replyNode.Text = row["MenuName"].ToString();
replyNode.Value = row["MenuId"].ToString();
reply++;

if (replyup == 0)
{
if (bbb == flg3)
{
replyup = Convert.ToInt32(replyNode.Value);
}
}
if ((aaa == flg3))
{
if (i1 == null)
{
replydown = Convert.ToInt32(replyNode.Value);
}
}
if ((aaa == pqr) && (bbb == pqr))
{
replyup = Convert.ToInt32(replyNode.Value);
replydown = Convert.ToInt32(replyNode.Value);
}
if (Convert.ToInt32(replyNode.Value) == pqr)
{
if (cout1 == 1)
{
replyNode.Collapse();
cout1 = 0;
}
else
{
replyNode.Expand();
cout1 = 1;
}
if (cout == 1)
{
node.Expand();
}
abc += Convert.ToString(replyNode.Value) + ",";
node.Expand();
count = 1;
val1 = val;
displayGrid();
}
node.ChildNodes.Add(replyNode);
AddReplies(messages, replyNode);
}
}
catch (Exception ex)
{
lblErrorMessage.Text = ex.Message;
}

}

//********************************************************************************//
// Get Replies in TreeView *//
//********************************************************************************//
public DataView GetReplies(DataTable messages, string messageID)
{
DataView view = new DataView(messages);
view.RowFilter = "ParentId=" + messageID;
return view;
}

//*****************************************************************************************//
//For DisplayGrid
//*****************************************************************************************//
public void displayGrid()
{
try
{
DataColumn myDataColumn;
DataRow myDataRow;

//create the first column
//myDataTable.Columns.Clear();
myDataColumn = new DataColumn();

myDataColumn.DataType = System.Type.GetType("System.Int32");
myDataColumn.ColumnName = "MenuId";
myDataColumn.ReadOnly = true;
myDataColumn.Unique = true;
//myDataTable.Columns.Add(myDataColumn);

if (meid == 0)
{
myDataTable.Columns.Add(myDataColumn);
}

//Create and add the second column
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "MenuName";
myDataColumn.ReadOnly = false;
////myDataTable.Columns.Add(myDataColumn);
if (meid == 0)
{
myDataTable.Columns.Add(myDataColumn);
}

//Create and add the second column
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "TemplateName";
myDataColumn.ReadOnly = false;
////myDataTable.Columns.Add(myDataColumn);
if (meid == 0)
{
myDataTable.Columns.Add(myDataColumn);
}


//Create and add the Third column
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "Description";
myDataColumn.ReadOnly = false;
//myDataTable.Columns.Add(myDataColumn);
if (meid == 0)
{
myDataTable.Columns.Add(myDataColumn);
}

//Create and add the second column
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "MetaTags";
myDataColumn.ReadOnly = false;
//myDataTable.Columns.Add(myDataColumn);
if (meid == 0)
{
myDataTable.Columns.Add(myDataColumn);
}

// Create and add the second column
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "MetaKeyWords";
myDataColumn.ReadOnly = false;
//myDataTable.Columns.Add(myDataColumn);
if (meid == 0)
{
myDataTable.Columns.Add(myDataColumn);
}

//Create and add the second column
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "MenuStatus";
myDataColumn.ReadOnly = false;
////myDataTable.Columns.Add(myDataColumn);
if (meid == 0)
{
myDataTable.Columns.Add(myDataColumn);
}

//Create and add the second column
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "ParentId";
myDataColumn.ReadOnly = false;
//myDataTable.Columns.Add(myDataColumn);
if (meid == 0)
{
myDataTable.Columns.Add(myDataColumn);
}

//Create and add the second column
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.Int32");
myDataColumn.ColumnName = "Flag1";
myDataColumn.ReadOnly = false;
////myDataTable.Columns.Add(myDataColumn);
if (meid == 0)
{
myDataTable.Columns.Add(myDataColumn);
}
//meid++;
dt = obj.GetMenu(pqr, ClientId);
string[] x = abc.Split(',');
int asd = abc.Length;
count = 1;
for (int a = 0; a < count; a++)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
if (x[a] == Convert.ToString(dt.Rows[i]["MenuId"]))
{
int Mi = Convert.ToInt32(dt.Rows[i]["MenuId"]);
string Mt = Convert.ToString(dt.Rows[i]["MenuName"]);
string temp = Convert.ToString(dt.Rows[i]["TemplateName"]);
string desc = Convert.ToString(dt.Rows[i]["Description"]);
string mtag = Convert.ToString(dt.Rows[i]["MetaTags"]);
string mkey = Convert.ToString(dt.Rows[i]["MetaKeyWords"]);
string status = Convert.ToString(dt.Rows[i]["MenuStatus"]);
int cid = Convert.ToInt32(dt.Rows[i]["ParentId"]);
int flg1 = Convert.ToInt32(dt.Rows[i]["Flag1"]);
flg3 = flg1;
myDataRow = myDataTable.NewRow();
myDataRow["MenuId"] = Mi;
myDataRow["MenuName"] = Mt;
myDataRow["TemplateName"] = temp;
myDataRow["Description"] = desc;
myDataRow["MetaTags"] = mtag;
myDataRow["MetaKeyWords"] = mkey;
myDataRow["MenuStatus"] = status;
myDataRow["ParentId"] = cid;
myDataTable.Rows.Add(myDataRow);
}
}
}
dgMenu.DataSource = myDataTable;
dgMenu.DataBind();
count = 0;
abc = "";

}
catch (Exception ex)
{
//lblErrorMessage.Text = ex.Message;
}

}

//*****************************************************************************************//
//Retriving values from lookup table to dropdownlist of Status
//*****************************************************************************************//
public void GetStatus()
{
try
{
string s = "Status";
ddlMenuStatus.DataSource = obj.GetStatus(s, ClientId);
ddlMenuStatus.DataTextField = "LookUpText";
ddlMenuStatus.DataBind();
ddlMenuStatus.Items.Insert(0, new ListItem("--Choose--"));
}
catch (Exception ex)
{
lblErrorMessage.Text = ex.Message;
}
}

//*****************************************************************************************//
//Retriving values from lookup table to dropdownlist of Templates
//*****************************************************************************************//
public void GetTemplate()
{
try
{
ddlAddTemplate.DataSource = obj.GetTemplates(ClientId);
ddlAddTemplate.DataTextField = "TemplateName";
ddlAddTemplate.DataBind();
ddlAddTemplate.Items.Insert(0, new ListItem("--Choose--"));
}
catch (Exception ex)
{
lblErrorMessage.Text=ex.Message;
}
}

//*****************************************************************************************//
//(Event Submit)Code for Submit or Save the records
//*****************************************************************************************//
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
string jv1;
string menname = "";
string status = "";
string menid = "";
int qid;
int QL;

DataTable dt4 = obj.GetLinkCount(ClientId);
QL = Convert.ToInt32(dt4.Rows[0]["QuickLinkId"]);

if (chkQuickLinks.Checked == true)
{
//int QL;
//DataTable dt4 = obj.GetLinkCount(ClientId);
//QL = Convert.ToInt32(dt4.Rows[0]["QuickLinkId"]);
//if (QL > 7)
//{
// jv1 = "alert('QuickLink Limit Completed');";
// this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
//}
//else
//{
qid = 1;
//}
}
else
{
qid = 0;
}
string MenuName = txtMenuTitle.Text.ToString();

if (menuid == 0)
{
MyDtab = obj.ChkMenuNames(txtMenuTitle.Text.Trim());
foreach (DataRow r in MyDtab.Rows)
{
menid = Convert.ToString(MyDtab.Rows[0]["MenuId"]);
menname = Convert.ToString(MyDtab.Rows[0]["MenuName"]);
status = Convert.ToString(MyDtab.Rows[0]["DStatus"]);
}
if (menname == "" && status == "" && txtMenuId.Text == "")
{
if (btnSubmit.Text == "Submit")
{
if ((chkQuickLinks.Checked == true) && (QL > 7))
{
jv1 = "alert('QuickLink Limit Completed');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
qid = 0;
chkQuickLinks.Focus();
}
else
{
menid = "0";
menname = txtMenuTitle.Text.Trim();
obj.GetSave(ClientId, menuid, qid, txtMenuTitle.Text.Trim(), c1, ddlAddTemplate.Text.Trim(), txtDescription.Text.Trim(), txtAddMetaTag.Text.Trim(), txtAddMetaKeyWord.Text.Trim(), ddlMenuStatus.Text.Trim(), Who, Convert.ToString(menuid));
Clear();
table2.Attributes.Add("style", "display:none");
jv1 = "alert('Record Saved Successfully');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
table1.Attributes.Add("style", "display:none");
MyDtab = obj.GetAllMenus(1, ClientId, tempnme);
dv = MyDtab.DefaultView;
}
}
}
}
else if (menuid != 0)
{
MyDtab = obj.ChkMenuNames(txtMenuTitle.Text.Trim());

foreach (DataRow r in MyDtab.Rows)
{
menid = Convert.ToString(MyDtab.Rows[0]["MenuId"]);
menname = Convert.ToString(MyDtab.Rows[0]["MenuName"]);
status = Convert.ToString(MyDtab.Rows[0]["DStatus"]);
}
string nameupper1 = txtMenuTitle.Text.ToUpper();
string nameupper2 = menname.ToUpper();

if ((menid != txtMenuId.Text.ToString()) && (nameupper1 != nameupper2) && (status != "1"))
{
MyDtab = obj.GetAllMenus(1, ClientId,tempnme);
dv = MyDtab.DefaultView;
if (btnSubmit.Text == "Submit")
{
if ((chkQuickLinks.Checked == true)&&(QL > 7))
{
jv1 = "alert('QuickLink Limit Completed');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
qid = 0;
chkQuickLinks.Focus();
}

else
{
obj.GetSave(ClientId, Convert.ToInt32(txtMenuId.Text.Trim()), qid, txtMenuTitle.Text.Trim(), c1, ddlAddTemplate.SelectedItem.Text, txtDescription.Text.Trim(), txtAddMetaTag.Text.Trim(), txtAddMetaKeyWord.Text.Trim(), ddlMenuStatus.SelectedItem.Text, Who, Convert.ToString(flg3));
jv1 = "alert('Record Updated Successfully');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
Clear();
}

}
else if (btnSubmit.Text == "Add Sibling")
{
if ((chkQuickLinks.Checked == true) && (QL > 7))
{
jv1 = "alert('QuickLink Limit Completed');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
qid = 0;
chkQuickLinks.Focus();
}
else
{
menuid = 0;
obj.GetSave(ClientId, menuid, qid, txtMenuTitle.Text.Trim(), pid, ddlAddTemplate.SelectedItem.Text, txtDescription.Text, txtAddMetaTag.Text, txtAddMetaKeyWord.Text, ddlMenuStatus.SelectedItem.Text, Who, Convert.ToString(menuid));
jv1 = "alert('Record Saved Successfully');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
btnSubmit.Text = "Submit";
Clear();
table2.Attributes.Add("style", "display:none");
table1.Attributes.Add("style", "display:none");

replyup = 0; replydown = 0;
threaddown = 0; menuid = 0;
int mm = Convert.ToInt32(dt.Rows[0]["MenuId"]);//retreiving menuid
int pp = Convert.ToInt32(dt.Rows[0]["ParentId"]);//retreiving parentid
if (pp.ToString() == "0")//1st level(TreeView)
{
replydown = pqr + 1;
threaddown = pqr + 1;
}
else
{
mm = pp;
DataTable dt3 = obj.NodeLevel(mm, ClientId);
mm = 0; pp = 0;
int kk = 0;
kk = Convert.ToInt32(dt3.Rows[0]["ParentId"]);
if (kk.ToString() == "0")
{
replydown = pqr - 1;
threaddown = pqr - 1;
}
else
{
replydown = pqr + 1;
threaddown = pqr + 1;
}
}
}

}

else if (btnSubmit.Text == "Add Child")
{
if ((chkQuickLinks.Checked == true) && (QL > 7))
{
jv1 = "alert('QuickLink Limit Completed');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
qid = 0;
chkQuickLinks.Focus();
}
else
{
menuid = 0;
obj.GetSave(ClientId, menuid, qid, txtMenuTitle.Text.Trim(), pqr, ddlAddTemplate.SelectedItem.Text, txtDescription.Text, txtAddMetaTag.Text, txtAddMetaKeyWord.Text, ddlMenuStatus.SelectedItem.Text, Who, Convert.ToString(menuid));
jv1 = "alert('Record Saved Successfully');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
btnSubmit.Text = "Submit";
Clear();
table2.Attributes.Add("style", "display:none");
table1.Attributes.Add("style", "display:none");
}
}
}
else if ((menid == txtMenuId.Text.ToString()) && (nameupper1 == nameupper2) && (status == "0"))
{
MyDtab = obj.GetAllMenus(1, ClientId,tempnme);
dv = MyDtab.DefaultView;
if (btnSubmit.Text == "Submit")
{
if ((chkQuickLinks.Checked == true) && (QL > 7))
{
jv1 = "alert('QuickLink Limit Completed');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
qid = 0;
//jv1 = "document.getelementById(ctl00_ContentPlaceHolder1_MenuCreationControl1_chkQuickLinks).select();";
//this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
chkQuickLinks.Focus();
}
else
{
obj.GetSave(ClientId, Convert.ToInt32(txtMenuId.Text.Trim()), qid, txtMenuTitle.Text.Trim(), c1, ddlAddTemplate.SelectedItem.Text, txtDescription.Text.Trim(), txtAddMetaTag.Text.Trim(), txtAddMetaKeyWord.Text.Trim(), ddlMenuStatus.SelectedItem.Text, Who, Convert.ToString(flg3));
Clear();
jv1 = "alert('Record Updated Successfully');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
table2.Attributes.Add("style", "display:none");
table1.Attributes.Add("style", "display:none");
}
}
else if (btnSubmit.Text == "Add Sibling")
{
if (menid == txtMenuId.Text.ToString())
{
jv1 = "alert('Menu Name already exists');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
}
else
{
if ((chkQuickLinks.Checked == true) && (QL > 7))
{
jv1 = "alert('QuickLink Limit Completed');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
qid = 0;
chkQuickLinks.Focus();
}
else
{
obj.GetSave(ClientId, menuid, qid, txtMenuTitle.Text.Trim(), c1, ddlAddTemplate.SelectedItem.Text, txtDescription.Text, txtAddMetaTag.Text, txtAddMetaKeyWord.Text, ddlMenuStatus.SelectedItem.Text, Who, Convert.ToString(menuid));
jv1 = "alert('Record Saved Successfully');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
btnSubmit.Text = "Submit";
Clear();
table2.Attributes.Add("style", "display:none");
table1.Attributes.Add("style", "display:none");
}
}
}
else if (btnSubmit.Text == "Add Child")
{
if (menid == txtMenuId.Text.ToString())
{
jv1 = "alert('Menu Name already exists');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
}
else
{
if ((chkQuickLinks.Checked == true) && (QL > 7))
{
jv1 = "alert('QuickLink Limit Completed');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
qid = 0;
//jv1 = "document.getelementById(ctl00_ContentPlaceHolder1_MenuCreationControl1_chkQuickLinks).select();" ;
//this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
chkQuickLinks.Focus();
}
else
{
obj.GetSave(ClientId, menuid, qid, txtMenuTitle.Text.Trim(), pqr, ddlAddTemplate.SelectedItem.Text, txtDescription.Text, txtAddMetaTag.Text, txtAddMetaKeyWord.Text, ddlMenuStatus.SelectedItem.Text, Who, Convert.ToString(menuid));
jv1 = "alert('Record Saved Successfully');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
btnSubmit.Text = "Submit";
Clear();
table2.Attributes.Add("style", "display:none");
table1.Attributes.Add("style", "display:none");
}

}
}
if ((Count1 == 1) && (Count2 != 1))
{
btnSubmit.Enabled = false;
}
}
else
{
if (status == "0" && menid != txtMenuId.Text.ToString())
{
jv1 = "alert('Menu Name already exist');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
}
else if (status == "1" && menid != txtMenuId.Text.ToString())
{
jv1 = "alert('Menu Name already exists but moved to Recyclebin');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
}
else if (status == "0")
{
jv1 = "alert('Menu Name already exists');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
}
else if (status == "1")
{
jv1 = "alert('Menu Name already exists but moved to Recyclebin');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
}
}
}
if (status == "0" && menid != "")
{
jv1 = "alert('Menu Name already exists');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
}
if (status == "1" && menid != "")
{
jv1 = "alert('Menu Name already exists but moved to Recyclebin');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);
}
menuid = 0;
}
catch (Exception ex)
{
lblErrorMessage.Text = ex.Message;
}
PopulateNodes();
}

//*****************************************************************************************//
//For Clear All TextBoxes
//*****************************************************************************************//
public void Clear()
{
try
{
txtMenuTitle.Text = "";
txtDescription.Text = "";
ddlAddTemplate.SelectedItem.Text = "";
GetTemplate();
txtAddMetaTag.Text = "";
txtAddMetaKeyWord.Text = "";
ddlMenuStatus.SelectedItem.Text = "";
GetStatus();
chkQuickLinks.Checked = false;
txtMenuTitle.Enabled = true;
}
catch (Exception ex)
{
lblErrorMessage.Text = ex.Message;
}
}
//*****************************************************************************************//
// * indicate For Mandatory Fields purpose
//*****************************************************************************************//
public void DisplayErr()
{
try
{
lblMenuStatusErr.Text = "*";
lblAddTemplateErr.Text = "*";
lblMenuTitleErr.Text = "*";
}
catch (Exception ex)
{
lblErrorMessage.Text = ex.Message;
}
}
//*****************************************************************************************//
//(TreeView Event)To Get MenuTitle In TreeView
//*****************************************************************************************//
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
selectNode();
}

void selectNode()
{
try
{
pqr = 0;
flg3 = 0;
aaa = 0;
bbb = 0;
val = 0;
val1 = 0;
pid = 0;
menuid = 0;
threaddown = 0;
replyup = 0;
replydown = 0;
s = TreeView1.SelectedNode.Text;

pqr = Convert.ToInt32(obj.GetMenuTitle(s, ClientId));
dt = obj.GetMenu(pqr, ClientId);
pid = Convert.ToInt32(dt.Rows[0]["ParentId"]);
flg3 = Convert.ToInt32(dt.Rows[0]["Flag1"]);
PopulateNodes();
}
catch (Exception ex)
{
lblErrorMessage.Text = ex.Message;
}
table1.Attributes.Add("style", "Display:none");
table2.Attributes.Add("style", "display:none");
Hidegrid.Attributes.Add("style", "Display:block");


}

//*****************************************************************************************//
//(Edit Event)Getting Values From Grid To TextBoxes
//*****************************************************************************************//
protected void dgMenu_EditCommand(object source, DataGridCommandEventArgs e)
{
try
{
string mi = dgMenu.Items[e.Item.ItemIndex].Cells[1].Text;
if (mi == "About Us" || mi == "Disclaimer" || mi == "Credit" || mi == "Contact Us" || mi == "Terms & Conditions")
{
txtMenuTitle.Enabled = false;
txtDescription.Focus();
}
else
{
txtMenuTitle.Enabled = true;
txtMenuTitle.Focus();
}
menuid = Convert.ToInt32(txtMenuId.Text);
lblErrorMessage.Text = "";
txtMenuTitle.Text = dgMenu.Items[e.Item.ItemIndex].Cells[1].Text;

int temp = Convert.ToInt32(dgMenu.Items[e.Item.ItemIndex].Cells[2].Text);
string tmp = obj.EditTemplate(temp);
GetTemplate();
ddlAddTemplate.SelectedValue = Convert.ToString(tmp);
txtDescription.Text = dgMenu.Items[e.Item.ItemIndex].Cells[3].Text;
txtAddMetaTag.Text = dgMenu.Items[e.Item.ItemIndex].Cells[4].Text;
txtAddMetaKeyWord.Text = dgMenu.Items[e.Item.ItemIndex].Cells[5].Text;
GetStatus();
ddlMenuStatus.SelectedValue = dgMenu.Items[e.Item.ItemIndex].Cells[6].Text;
ddlMenuStatus.SelectedItem.Text = dgMenu.Items[e.Item.ItemIndex].Cells[6].Text;
child = Convert.ToInt32(dgMenu.Items[e.Item.ItemIndex].Cells[7].Text);
flag2 = Convert.ToString(dgMenu.Items[e.Item.ItemIndex].Cells[8].Text);

childid = Convert.ToInt32(child);
c1 = child;
btnSubmit.Text = "Submit";
if (txtDescription.Text == " ")
{
txtDescription.Text = "";
}
if (txtAddMetaKeyWord.Text == " ")
{
txtAddMetaKeyWord.Text = "";
}
if (txtAddMetaTag.Text == " ")
{
txtAddMetaTag.Text = "";
}
table1.Attributes.Add("style", "Display:block");
table2.Attributes.Add("style", "display:none");
if ((Count1 == 1) && (Count2 != 1))
{
btnSubmit.Enabled = true;
}
if (ddlMenuStatus.SelectedItem.Text == "Drafts")
{
QLink.Attributes.Add("style", "Display:none");
}
if (ddlMenuStatus.SelectedItem.Text == "Backoffice" || ddlMenuStatus.SelectedItem.Text == "Active")
{

MyDtab = obj.GetAllMenus(1, ClientId,tempnme);
int QLid = Convert.ToInt32(dt.Rows[0]["QuickLinkId"]);
if (QLid == 1)
{
chkQuickLinks.Checked = true;
}
else
{
chkQuickLinks.Checked = false;
}
QLink.Attributes.Add("style", "Display:block");
}
}

catch (Exception ex)
{
lblErrorMessage.Text = ex.Message;
}
}
//*****************************************************************************************//
//(Delete Event)Delete Records fromMenu
//*****************************************************************************************//
protected void dgMenu_DeleteCommand(object source, DataGridCommandEventArgs e)
{
try
{
Clear();
string jv1;
int temp = Convert.ToInt32(dgMenu.Items[e.Item.ItemIndex].Cells[0].Text);
int count = Convert.ToInt32(obj.GetDeleteOrder(temp));
if (count == 0)
{
string mi = dgMenu.Items[e.Item.ItemIndex].Cells[1].Text;

if (mi == "About Us" || mi == "Disclaimer" || mi == "Credit" || mi == "Contact Us" || mi == "Terms & Conditions")
{
jv1 = "alert('This Menu cannot be Deleted because It is in Footer');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);

PopulateNodes();
Hidegrid.Attributes.Add("style", "display:block");
table1.Attributes.Add("style", "display:none");
table2.Attributes.Add("style", "display:none");
}
else
{
obj.GetDelete(temp);
jv1 = "alert('Record Deleted Successfully');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);

PopulateNodes();
table1.Attributes.Add("style", "display:none");
table2.Attributes.Add("style", "display:block");
Hidegrid.Attributes.Add("style", "display:none");
}
}
else
{
jv1 = "alert('Cannot delete parent item without deleting child items');";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jv1, true);

PopulateNodes();
Hidegrid.Attributes.Add("style", "display:block");
table1.Attributes.Add("style", "display:none");
table2.Attributes.Add("style", "display:none");
}
}
catch (Exception ex)
{
lblErrorMessage.Text = ex.Message;
}
}
//*****************************************************************************************//
//(Grid Event)To Display Grid Order by Treeview Selection
//*****************************************************************************************//
protected void dgMenu_ItemCommand(object source, DataGridCommandEventArgs e)
{
try
{
int mid, cid, flag;

txtMenuId.Text = dgMenu.Items[e.Item.ItemIndex].Cells[0].Text;
int flg = Convert.ToInt32(txtMenuId.Text);
dt = obj.GetMenu(flg,ClientId);
string flg1 = Convert.ToString(dt.Rows[0]["Flag1"]);
string child = dgMenu.Items[e.Item.ItemIndex].Cells[7].Text;
int c1 = Convert.ToInt32(child);

// To Add Sibling
if (e.CommandName == "Add Sibling")
{
Clear();
txtMenuTitle.Focus();
btnSubmit.Text = "Add Sibling";
table1.Attributes.Add("style", "Display:block");
table2.Attributes.Add("style", "display:none");
}
else

//To Add Child
if (e.CommandName == "Add Child")
{
Clear();
int mm = Convert.ToInt32(dt.Rows[0]["MenuId"]);//retreiving menuid
int pp = Convert.ToInt32(dt.Rows[0]["ParentId"]);//retreiving parentid
if (pp.ToString() == "0")//1st level(TreeView)
{
btnSubmit.Text = "Add Child";
table1.Attributes.Add("style", "Display:block");
table2.Attributes.Add("style", "display:none");
txtMenuTitle.Focus();
}
else
{
mm = pp;
DataTable dt3 = obj.NodeLevel(mm, ClientId);
mm = 0;
pp = 0;
int kk = 0;
kk = Convert.ToInt32(dt3.Rows[0]["ParentId"]);
if (kk.ToString() == "0")//2nd level(TreeView)
{
btnSubmit.Text = "Add Child";
table1.Attributes.Add("style", "Display:block");
table2.Attributes.Add("style", "display:none");
txtMenuTitle.Focus();
}
else
{
//mm = kk;
//DataTable dt4 = obj.NodeLevel(mm, ClientId);
//int ff = Convert.ToInt32(dt4.Rows[0]["ParentId"]);
//if (ff.ToString() == "0")//3rd level(TreeView)
//{
// btnSubmit.Text = "Add Child";
// table1.Attributes.Add("style", "Display:block");
// table2.Attributes.Add("style", "display:none");
// txtMenuTitle.Focus();
//}
//else
//{
string jj = "alert('Maximum 3 Levels Allowed');";//3rd level of TreeView
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", jj, true);
//}
}
}
}
//For Move Down
else if (e.CommandName == "Move Down")
{
table1.Attributes.Add("style", "Display:none");
table2.Attributes.Add("style", "display:none");
dt2 = obj.MoveUp(c1, ClientId);
int count1 = 0;
string abc1 = "";
string abc2 = "";
DataView dv;
dv = dt2.DefaultView;
int i;
for (i = 0; i < dt2.Rows.Count; i++)
{
mid = Convert.ToInt32(dt2.Rows[i]["MenuId"]);
cid = Convert.ToInt32(dt2.Rows[i]["ParentId"]);
flag = Convert.ToInt32(dt2.Rows[i]["Flag1"]);
count1++;
abc1 += Convert.ToString(flag) + ",";
abc2 += Convert.ToString(mid) + ",";

}
string[] x1 = abc1.Split(',');
string[] x2 = abc2.Split(',');

for (int a = 0; a < count1; a++)
{
if (x1[a] == flg1)
{
f1 = x1[a + 1];
f2 = x1[a];
i1 = x2[a + 1];
i2 = x2[a];
}
}
obj.GetUpdate(Convert.ToInt32(child), f2, Convert.ToInt32(i1), ClientId);
obj.GetUpdate(Convert.ToInt32(child), f1, Convert.ToInt32(i2), ClientId);

replyup = 0;
replydown = 0;
replydown = int.Parse(x2[count1 - 2].ToString());

threaddown = 0;
menuid = 0;
threaddown = int.Parse(x2[count1 - 2].ToString());

PopulateNodes();
f1 = "";
f2 = "";
i1 = "";
i2 = "";
}

//For Move Up
else if (e.CommandName == "Move Up")
{
table1.Attributes.Add("style", "Display:none");
table2.Attributes.Add("style", "display:none");
dt2 = obj.MoveUp(c1, ClientId);
int count1 = 0;
string abc1 = "";
string abc2 = "";
DataView dv;
dv = dt2.DefaultView;
for (int i = 0; i < dt2.Rows.Count; i++)
{
mid = Convert.ToInt32(dt2.Rows[i]["MenuId"]);
cid = Convert.ToInt32(dt2.Rows[i]["ParentId"]);
flag = Convert.ToInt32(dt2.Rows[i]["Flag1"]);
count1++;
abc1 += Convert.ToString(flag) + ",";
abc2 += Convert.ToString(mid) + ",";
}
string[] x1 = abc1.Split(',');
string[] x2 = abc2.Split(',');

for (int a = 0; a < count1; a++)
{
if (x1[a] == flg1)
{
f1 = x1[a - 1];
f2 = x1[a];
i1 = x2[a - 1];
i2 = x2[a];
}
}
string c2 = x1[count1 - 1];
obj.GetUpdate(Convert.ToInt32(child), f2, Convert.ToInt32(i1), ClientId);
obj.GetUpdate(Convert.ToInt32(child), f1, Convert.ToInt32(i2), ClientId);

replyup = 0;
replydown = 0;
replyup = int.Parse(x2[1].ToString());

threaddown = 0;
menuid = 0;
menuid = int.Parse(x2[1].ToString());

f1 = "";
f2 = "";
i1 = "";
i2 = "";
PopulateNodes();
}

flg = 0;
flg1 = "";
}
catch (Exception ex)
{
string s = ex.Message;
}
}
//*********************************************************************************************//
// For Edit, AddSibling,AddChild...
//*********************************************************************************************//

protected void dgMenu_ItemCreated(object sender, DataGridItemEventArgs e)
{
try
{
table1.Focus();
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (pqr == 1 || pqr == 71 || pqr == 72 || pqr == 73 || pqr == 74 || pqr == 75)
{
}
else
{
Button _myButton = (Button)e.Item.FindControl("btnDelete");
_myButton.Attributes.Add("onclick", "return confirm_delete();");
}
}
if (e.Item.ItemType == ListItemType.Item)
{
e.Item.Cells[9].ToolTip = "To Edit";
e.Item.Cells[10].ToolTip = "To add Sibling";
e.Item.Cells[11].ToolTip = "To add Child ";
e.Item.Cells[12].ToolTip = "To Move Up";
e.Item.Cells[13].ToolTip = "To Move Down";
e.Item.Cells[14].ToolTip = "To Delete";
}

if (pqr == menuid || pqr==1 )
{
Button b = (Button)e.Item.FindControl("btn1");
if (b != null)
b.Enabled = false;
}
if (pqr == threaddown || pqr==1)
{
Button b = (Button)e.Item.FindControl("btnMoveDown");
if (b != null)
b.Enabled = false;
}
if (pqr == replyup )
{
Button b = (Button)e.Item.FindControl("btn1");
if (b != null)
b.Enabled = false;
}
if (pqr == replydown)
{
Button b = (Button)e.Item.FindControl("btnMoveDown");
if (b != null)
b.Enabled = false;
}

RoleName = Convert.ToString(Session["RN"]);
dsrole = uc.GetOptions(RoleName);
if (dsrole.Rows.Count == 0)
{
ids = "10" + "," + "11" + "," + "12" + "," + "13";
}
else
{
string s = dsrole.Rows[0]["RoleDescription"].ToString();
string[] names = s.Split(',');
for (int i = 0; i < names.Length; i++)
{
dt3 = uc.TopMenu_LookupId(names[i].ToString());
ids = ids + dt3.Rows[0]["lookupid"].ToString() + ",";
}
if (dt.Rows.Count != 0)
{
ids = ids.Substring(0, ids.Length - 1);
}
}
Array id = ids.Split(',');
for (int i = 0; i < id.Length; i++)
{
if (id.GetValue(i).ToString() == "10")
{
if (pqr == 1)
{
Button b = (Button)e.Item.FindControl("btnEdit");
b.Enabled = false;
}
else
{
Button b = (Button)e.Item.FindControl("btnEdit");
if (b != null)
b.Enabled = true;
}
Count1 = 1;
}
if (id.GetValue(i).ToString() == "12")
{
btnSubmit.Enabled = true;

Button b = (Button)e.Item.FindControl("btnAddSibling");
if (b != null)
b.Enabled = true;

Button b3 = (Button)e.Item.FindControl("btnAddChild");
if (b3 != null)
b3.Enabled = true;
Count2 = 2;
}
if (id.GetValue(i).ToString() == "11")
{
if (pqr == 1)
{
Button b = (Button)e.Item.FindControl("btnDelete");
b.Enabled = false;
}
else
{
Button b = (Button)e.Item.FindControl("btnDelete");
if (b != null)
b.Enabled = true;
}

}
}

}

catch (Exception ex)
{
string s = ex.Message;
}
}

protected void Edit_Click(object sender, EventArgs e)
{

}
protected void AddSibling_Click(object sender, EventArgs e)
{
}
protected void AddChild_Click(object sender, EventArgs e)
{
}
protected void MoveUp_Click(object sender, EventArgs e)
{
}
protected void MoveDown_Click(object sender, EventArgs e)
{
}
protected void Delete_Click(object sender, EventArgs e)
{
}

}
=============================================================================

data base should be developed your self

hi

JokeRe: tree view in C#.Net Pin
Nouman Bhatti30-Apr-07 1:40
Nouman Bhatti30-Apr-07 1:40 
QuestionProcess.Start Parameter with space Pin
satsumatable29-Apr-07 18:30
satsumatable29-Apr-07 18:30 
AnswerRe: Process.Start Parameter with space Pin
Christian Graus29-Apr-07 18:33
protectorChristian Graus29-Apr-07 18:33 
GeneralRe: Process.Start Parameter with space Pin
satsumatable29-Apr-07 18:57
satsumatable29-Apr-07 18:57 
GeneralRe: Process.Start Parameter with space Pin
Christian Graus29-Apr-07 19:35
protectorChristian Graus29-Apr-07 19:35 
GeneralRe: Process.Start Parameter with space Pin
Luc Pattyn30-Apr-07 4:23
sitebuilderLuc Pattyn30-Apr-07 4:23 
GeneralRe: Process.Start Parameter with space Pin
PIEBALDconsult3-May-07 15:40
mvePIEBALDconsult3-May-07 15:40 
GeneralRe: Process.Start Parameter with space Pin
Luc Pattyn3-May-07 22:24
sitebuilderLuc Pattyn3-May-07 22:24 
GeneralRe: Process.Start Parameter with space Pin
PIEBALDconsult4-May-07 16:45
mvePIEBALDconsult4-May-07 16:45 
GeneralRe: Process.Start Parameter with space Pin
Luc Pattyn4-May-07 23:30
sitebuilderLuc Pattyn4-May-07 23:30 
Questionhow to display video files using asp.net Pin
manoharseetha29-Apr-07 17:06
manoharseetha29-Apr-07 17:06 
AnswerRe: how to display video files using asp.net Pin
Christian Graus29-Apr-07 17:26
protectorChristian Graus29-Apr-07 17:26 
Questioni need help in my project... Pin
hazem maher29-Apr-07 11:26
hazem maher29-Apr-07 11:26 
AnswerRe: i need help in my project... Pin
Christian Graus29-Apr-07 12:30
protectorChristian Graus29-Apr-07 12:30 
GeneralRe: i need help in my project... Pin
Paul Conrad29-Apr-07 13:44
professionalPaul Conrad29-Apr-07 13:44 
GeneralRe: i need help in my project... Pin
Christian Graus29-Apr-07 14:51
protectorChristian Graus29-Apr-07 14:51 
GeneralRe: i need help in my project... Pin
Paul Conrad29-Apr-07 14:57
professionalPaul Conrad29-Apr-07 14:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.