|
|
Hi all,
This is the scenario: the user is able to initiate some process by selecting some data from a form, dragging it and dropping it onto another independent form. I want to add the option of introducing a context menu if the user were to use the right mouse button to do the drag&drop just before said process is initiated (using the context menu, the user can define how that process behaves).
My initial attempt looks something like this:
<br />
...<br />
private void HandleDragDrop()<br />
{<br />
doSomething<br />
...<br />
contextMenuStrip.Show();<br />
...<br />
doSomethingElse<br />
}<br />
Two problems with this:
1. contextMenuStrip.Show(); by itself doesn't appear to be blocking. It does display the context menu but then goes ahead and executes all subsequent commands without waiting for user input.
2. The selection made is handled elsewhere using a standard Click event handler so even if I were able to stop the program to await user selection, I wonder if the context would leap from the Click event handler back to the statement immediately following the .Show() command. Sounds too easy for it to be correct...
Ideally, I would like to be able to do something similar to
<br />
...<br />
DialogResult response = MessageBox.Show(...);<br />
if (response == DialogResult.OK)<br />
...<br />
...but using a context menu (because I want to be able to select from a list of options and not just Yes or No but mainly so that users do not get upset if they were to see a Message Box rather than a context menu...).
Any ideas or help would be greatly appreciated!
cheers!
|
|
|
|
|
jozsurf wrote: 1. contextMenuStrip.Show(); by itself doesn't appear to be blocking. It does display the context menu but then goes ahead and executes all subsequent commands without waiting for user input.
that's because contextMenuStrip.Show(); doesn't work like ShowDialog.. it only presents you the menu..
if "...doSomethingElse" depends on what user does/selects in the menu you should put it in context menu items event handlers.. onClick for MenuItems for example..
life is study!!!
|
|
|
|
|
cheers! that makes sense. The code will need a little refactoring though...
|
|
|
|
|
Hi, i'm creating a C# program that measures date differences. for example i have 2 text boxes, one text box contains the date 4/12/2007, the other text box contains 5/23/2008. I need to count the number of days difference from 4/12/2007 to 5/23/2008.
Im sorta new to C# and i have no idea how to do this, since i cant just treat it as simple numerical values, given that it must reference the calendar for the measurements to be exact.
thanks in adavance..
|
|
|
|
|
See the documentation for the DateTime and TimeSpan classes
|
|
|
|
|
Colin Angus Mackay wrote: See the documentation for the DateTime and TimeSpan classes
tnx!
|
|
|
|
|
Please Can you explain me how to use existing .resx file for a new project. I attached the existing resource file correctly. When i do it i ll get a error saying
"Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Mockup.Mockup.resources" was correctly embedded or linked into assembly "OfficePlanSample" at compile time, or that all the satellite assemblies required are loadable and fully signed. "
Here "Mockup" is the new namespace name and the internal class name and "OfficePlanSample" is the new namespace name. please can anybody help me in here. Thanks.
Asith
|
|
|
|
|
just copy in ur project and do something like myresource.mykey, right click on the resource file and check it's properties change to "embeded"
|
|
|
|
|
Thanks for your reply mate, now its working properly.
Asit
|
|
|
|
|
Dear All,
Is there any method avl to export the images in a PDF document via Dotnet.
Thanks In Advance
Dana
|
|
|
|
|
No, there is no PDF support whatsoever, without third party libraries.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Dear Christian,
Thanks for your reply.Is there any free thrid party avaliable.I found one DLL .That is iTextsharp.But it doesnt have the image export method
Dana
|
|
|
|
|
There are free ones, but they generally just create a PDF from text or maybe images. I don't know, if I needed one, I would buy one. b/c if I was making money, I'd spend money to make sure it worked OK.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Can you mention some dll(paid one) which will extract the images from pdf pages
|
|
|
|
|
how to do this? i have this code written:
Dialog1::Dialog1(CWnd* pParent /*=NULL*/)
: CDialog(Dialog1::IDD, pParent)
{
dlg.Create( IDD_DIALOG2, pParent);
}
void Dialog1::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
CRect rectClient;
CRect rectWnd;
GetWindowRect( rectWnd );
GetClientRect( rectClient );
rectClient.OffsetRect( rectWnd.left, rectWnd.top);
dlg.SetWindowPos(&wndTop, rectClient.left, rectClient.top, rectClient.Width(), rectClient.Height(), SWP_SHOWWINDOW);
dlg.ShowWindow(SW_SHOW);
}
but dialog2 shows behind dialog1 and doesn't move follow dialog1
i want make dialog2 as a part in dialog1
Thanks!
|
|
|
|
|
|
i need help for converting c# code to c++.
Is there any kind of coverter for this please send it to me.
please do help me .
MISHAQ
|
|
|
|
|
No, there is not. To convert C# to C++/CLI is trivial, and you can buy converters. To convert it to straight C++ is not really possible via an automated process.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
ok thanx for replying
but sir you can tell me how function ToInt16()or ToInt32()will be converted.
MIshaq
|
|
|
|
|
That depends. You may use a cast, or you may have to use atoi
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Sir,
I Want to fill tree view from a self joined SqlServer Table. The data in this table is filled up by the user at the run-time. So I want code which can fill tree view at the run-time.
Regards.
Prashant Mathur
Viva Creations
|
|
|
|
|
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
|
|
|
|
|
a very comprehensive answer:->
|
|
|
|
|
Hi
Im calling batch file from C# application as like below
Process.Start (@"c:\\test.bat", "param1 param2");
and my Batch file recongnizes that it has two paramter, if param1 has some space it will consider that as one more parameter, how can have space in the paramters?
Thanks.
|
|
|
|
|