.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!



Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

Set Focus Input Textbox

Posted By: kamlesh     Posted Date: March 09, 2011    Points:5   Category :Windows Application
hi

i have taken one input box

and on OK click write code
but if without giving the input when i click ok
it will work for next step so i write there

if (strFolderName == "")
{
MessageBox.Show("Enter Input");
}
else
{
// done something
}

so i want when messagebox will popup then it goes to inputbox means again it shows me input box how it is possible in c#

Responses
Author: Sunil Yadav       [Moderator]      
Posted Date: March 09, 2011     Points: 20   

Hi,

As per my understanding you are trying to set focus back to the input box.

If this is the case then you can use below code logic.

if (strFolderName == "")
{
MessageBox.Show("Enter Input");

//Set focus to inputbox. Let's consider your inputbox is textbox.

TextBox1.Focus();
}
else
{
// do something
}


Let me know if you need any help.

Author: Maverick             
Posted Date: March 09, 2011     Points: 20   

Hello,
This would do it

if (strFolderName == ""0
{
messagebox.show("Your Input");
//Set the focus
txtTexbox.focus()
}
else
{
}

Hope it helps
Thanks,
Maverick

Thanks,
Maverick
Author: kamlesh             
Posted Date: March 10, 2011     Points: 20   

thanks but for taking inputbox i have used this code in one class

public static DialogResult InputBox(string title, string promptText, ref string value)
{
Form form = new Form();
Label label = new Label();
TextBox textBox = new TextBox();
Button buttonOk = new Button();
Button buttonCancel = new Button();

form.Text = title;
label.Text = promptText;
textBox.Text = value;

buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;

label.SetBounds(9, 20, 372, 13);
textBox.SetBounds(12, 36, 372, 20);
buttonOk.SetBounds(228, 72, 75, 23);
buttonCancel.SetBounds(309, 72, 75, 23);

label.AutoSize = true;
textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

form.ClientSize = new Size(396, 107);
form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel});
form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
form.AcceptButton = buttonOk;
form.CancelButton = buttonCancel;

DialogResult dialogResult = form.ShowDialog();
value = textBox.Text;
return dialogResult;
}


and i am using that input box here like

if (MailService.InputBox("Folder Name", "Enter Folder Name : ", ref strFolderName) == DialogResult.OK)
{
if (strFolderName == "")
{
MessageBox.Show("Please input Folder Name");
}
else
{
CLICaller.RestoreDataToUser(cmbServer.Text.Trim(), cmbuserlist.Text.Trim(), strXMLPath, strFolderName);
}
}
else
{
CLICaller.RestoreDataToUser(cmbServer.Text.Trim(), cmbuserlist.Text.Trim(), strXMLPath, "");
}


so please in this how it is done please let me know....



Thanks And Regards.
Kamlesh Nikam
Author: Sunil Yadav       [Moderator]      
Posted Date: March 10, 2011     Points: 20   

Hi
You can declare the textBox as global vaiable for the class as shown below. Using this you can access textbox in you InputBox method.
private static TextBox textBox = new TextBox();


Hope this makes sense.

Author: kamlesh             
Posted Date: March 17, 2011     Points: 20   

private void BtnSubmit_Click(object sender, EventArgs e)
{
if (TreeMailNodes.SelectedNode == null)
{
MessageBox.Show("Please Import PST or EDB File");
this.Close();
}
else
{

/// <summary>
/// Restore to Live Exchange Server
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

if (TreeMailNodes.SelectedNode.Checked)
{

if (RdoButnLiveExchangeServer.Checked == true)
{
// Exoprt Live Exchange Server
try
{


if (TreeMailNodes.SelectedNode != null)
{
string NodeName = "";
string strNodes = TreeMailNodes.SelectedNode.FullPath;
String[] Nodes = strNodes.Split('\\');
//Nodes.Remove(0);

for (int i = 1; i < Nodes.Length; i++)
{

NodeName = NodeName + Nodes[i];
if (i != Nodes.Length - 1)
NodeName = NodeName + "\\";

}
if (TreeMailNodes.SelectedNode.Level > 0)
{

List<ClsExportUserMetaData> userList = new List<ClsExportUserMetaData>();

List<clsExportFolder> folderList = new List<clsExportFolder>();
int userCount = 0;
clsExport Export = new clsExport();
foreach (TreeNode oTree in TreeMailNodes.Nodes)
{
ClsExportUserMetaData user = new ClsExportUserMetaData();
//user.UserName = "";
IterateFolders(oTree, ref folderList);

if (folderList.Count > 0)
{

string RouteFolderName = MailService.GetRouteFolderName(Convert.ToInt64(oTree.Tag/*TreeMailNodes.SelectedNode.Tag*/));
//userCount++;
user.ExportType = ExportTypeEnum.Selected;
user.UserName = RouteFolderName;
user.FolderList.AddRange(folderList);
user.FolderCount = folderList.Count;
userList.Add(user);
userCount++;
}
folderList.Clear();


}
if (userCount != 0)
{
Export.UserCount = userCount;

Export.UserList = userList;
ClsExportCreateXML XMLCreater = new ClsExportCreateXML();
XMLCreater.CreateXML(Export);
}
//End
///////////////////////////////////////////////////////////


}

else
{

// Route Folder
List<ClsExportUserMetaData> userList = new List<ClsExportUserMetaData>();
//ClsExportUserMetaData user = new ClsExportUserMetaData();
clsExport Export = new clsExport();
int userCount = 0;
foreach (TreeNode oTree in TreeMailNodes.Nodes)
{
ClsExportUserMetaData user = new ClsExportUserMetaData();
//user.UserName = "";
if (oTree.Checked == true)
{
string RouteFolderName = MailService.GetRootFolderName(Convert.ToInt64(oTree.Tag));



user.ExportType = ExportTypeEnum.Full;
user.UserName = RouteFolderName;
userList.Add(user);
userCount++;
}
}

if (userCount != 0)
{
Export.UserCount = Export.UserList.Count;
Export.UserList = userList;
ClsExportCreateXML XMLCreater = new ClsExportCreateXML();
XMLCreater.CreateXML(Export);
}
}

//MessageBox.Show("Live Exchange Server");

CLICaller.bIsPublicFolderRestore = false;
FrmRestore frmres = new FrmRestore();
frmres.ShowDialog();
this.Close();
}



}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
clsError.LogError(ex);
}
// MessageBox.Show("Live Exchange Server");
}

/// <summary>
/// Restore to MSG
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

else if (RdoButnMSG.Checked == true)
{

if (TreeMailNodes.SelectedNode != null)
{
string NodeName = "";
string strNodes = TreeMailNodes.SelectedNode.FullPath;
String[] Nodes = strNodes.Split('\\');
//Nodes.Remove(0);

for (int i = 1; i < Nodes.Length; i++)
{

NodeName = NodeName + Nodes[i];
if (i != Nodes.Length - 1)
NodeName = NodeName + "\\";

}
if (TreeMailNodes.SelectedNode.Level > 0)
{

List<ClsExportUserMetaData> userList = new List<ClsExportUserMetaData>();

List<clsExportFolder> folderList = new List<clsExportFolder>();
int userCount = 0;
clsExport Export = new clsExport();
foreach (TreeNode oTree in TreeMailNodes.Nodes)
{
ClsExportUserMetaData user = new ClsExportUserMetaData();
//user.UserName = "";
IterateFolders(oTree, ref folderList);

if (folderList.Count > 0)
{

string RouteFolderName = MailService.GetRouteFolderName(Convert.ToInt64(oTree.Tag/*TreeMailNodes.SelectedNode.Tag*/));
//userCount++;
user.ExportType = ExportTypeEnum.Selected;
user.UserName = RouteFolderName;
user.FolderList.AddRange(folderList);
user.FolderCount = folderList.Count;
userList.Add(user);
userCount++;
}
folderList.Clear();


}
if (userCount != 0)
{
Export.UserCount = userCount;

Export.UserList = userList;
ClsExportCreateXML XMLCreater = new ClsExportCreateXML();
XMLCreater.CreateXML(Export);
}
//End
///////////////////////////////////////////////////////////


}

else
{

// Route Folder
List<ClsExportUserMetaData> userList = new List<ClsExportUserMetaData>();
//ClsExportUserMetaData user = new ClsExportUserMetaData();
clsExport Export = new clsExport();
int userCount = 0;
foreach (TreeNode oTree in TreeMailNodes.Nodes)
{
ClsExportUserMetaData user = new ClsExportUserMetaData();
//user.UserName = "";
if (oTree.Checked == true)
{
string RouteFolderName = MailService.GetRootFolderName(Convert.ToInt64(oTree.Tag));



user.ExportType = ExportTypeEnum.Full;
user.UserName = RouteFolderName;
userList.Add(user);
userCount++;
}
}

if (userCount != 0)
{
Export.UserCount = Export.UserList.Count;
Export.UserList = userList;
ClsExportCreateXML XMLCreater = new ClsExportCreateXML();
XMLCreater.CreateXML(Export);
}
}

FolderBrowserDialog browsefolder = new FolderBrowserDialog();


if (browsefolder.ShowDialog() == DialogResult.OK)
{

browsefolder.Dispose();

Thread.Sleep(500);

frmLoading frmload = new frmLoading();
frmload.Show();

try
{

String pstFilePath = null;
List<ExportToMsg.UserInfo> lsUserInfoList = new List<ExportToMsg.UserInfo>();


ExportToMsg.ReadXMLFile(System.Environment.CurrentDirectory + "\\ExportMail.xml", ref lsUserInfoList);
for (int iUserCount = 0; iUserCount < lsUserInfoList.Count; iUserCount++)
{
ExportToMsg.strFullFolderPath = "";
ExportToMsg.strRootFolder = null;

pstFilePath = lsUserInfoList[iUserCount].strUserName;

string pstName = null;
String strSaveFolderPath = browsefolder.SelectedPath;
Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.NameSpace outlookNs = app.GetNamespace("MAPI");

String strGUID = Guid.NewGuid().ToString();
//CLICaller.ProfileHandling(strGUID, 1,pstFilePath );

//outlookNs.Logon(strGUID, null, null, true);
outlookNs.AddStore(pstFilePath);

Microsoft.Office.Interop.Outlook.MAPIFolder rootFolder = null;
Microsoft.Office.Interop.Outlook.Stores Store1 = outlookNs.Stores;
foreach (Microsoft.Office.Interop.Outlook.Store item_Store in Store1)
{
string StoreName = item_Store.DisplayName;

if (StoreName == "Personal Folders")
pstName = "Personal Folders";
if (StoreName == "Source Folder")
pstName = "Source Folder";
if (StoreName == "Destination Folder")
pstName = "Destination Folder";
}
rootFolder = outlookNs.Stores[pstName].GetRootFolder();
Microsoft.Office.Interop.Outlook.Folders subFolders = rootFolder.Folders;

if (lsUserInfoList[iUserCount].strType1 == "Full")
{
foreach (Microsoft.Office.Interop.Outlook.Folder folder in subFolders)
{
ExportToMsg.GetSubFolders(folder, strSaveFolderPath, "", lsUserInfoList[iUserCount], 0);
}
}
else
if (lsUserInfoList[iUserCount].strType1 == "Selected")
{
for (int iFolderCount = 0; iFolderCount < lsUserInfoList[iUserCount].lsItemInfo.Count; iFolderCount++)
{
ExportToMsg.strRootFolder = lsUserInfoList[iUserCount].lsItemInfo[iFolderCount].strFolderName.Split('\\');
if (lsUserInfoList[iUserCount].strType2 == "Full")
{
foreach (Microsoft.Office.Interop.Outlook.Folder folder in subFolders)
{
if (ExportToMsg.strRootFolder[0] == folder.Name)
{
ExportToMsg.strFullFolderPath = folder.Name;
ExportToMsg.GetSubFolders(folder, strSaveFolderPath, lsUserInfoList[iUserCount].lsItemInfo[iFolderCount].strFolderName, lsUserInfoList[iUserCount], iFolderCount);
}
}
}
else if (lsUserInfoList[iUserCount].strType2 == "Selected")
{
foreach (Microsoft.Office.Interop.Outlook.Folder folder in subFolders)
{
if (ExportToMsg.strRootFolder[0] == folder.Name)
{
ExportToMsg.strFullFolderPath = folder.Name;
ExportToMsg.GetSubFolders(folder, strSaveFolderPath, lsUserInfoList[iUserCount].lsItemInfo[iFolderCount].strFolderName, lsUserInfoList[iUserCount], iFolderCount);
}
}
}

}
}
outlookNs.RemoveStore(rootFolder);
//outlookNs.Logoff();
//CLICaller.ProfileHandling(strGUID, 2,"");
}

frmload.Close();

MessageBox.Show("Export to MSG is Completed", "Export", MessageBoxButtons.OK, MessageBoxIcon.None);

Process[] GetAllProcesses = Process.GetProcessesByName("OUTLOOK");
for (int i = 0; i < GetAllProcesses.Length; i++)
{
GetAllProcesses[i].Kill();
}

Thread.Sleep(200);
File.Delete(Path.GetDirectoryName(pstFilePath) + @"\~" + Path.GetFileName(pstFilePath) + ".tmp");
this.Close();

}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
Process[] GetAllProcesses = Process.GetProcessesByName("OUTLOOK");
for (int i = 0; i < GetAllProcesses.Length; i++)
{
GetAllProcesses[i].Kill();
}
}


}
else
{
browsefolder.Dispose();
}
browsefolder.Dispose();
browsefolder = null;
}
}

/// <summary>
/// Restore to PST Files
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

else if (RdoButnPST.Checked == true)
{

if (TreeMailNodes.SelectedNode != null)
{
string NodeName = "";
string strNodes = TreeMailNodes.SelectedNode.FullPath;
String[] Nodes = strNodes.Split('\\');
//Nodes.Remove(0);

for (int i = 1; i < Nodes.Length; i++)
{

NodeName = NodeName + Nodes[i];
if (i != Nodes.Length - 1)
NodeName = NodeName + "\\";

}
if (TreeMailNodes.SelectedNode.Level > 0)
{

List<ClsExportUserMetaData> userList = new List<ClsExportUserMetaData>();

List<clsExportFolder> folderList = new List<clsExportFolder>();
int userCount = 0;
clsExport Export = new clsExport();
foreach (TreeNode oTree in TreeMailNodes.Nodes)
{
ClsExportUserMetaData user = new ClsExportUserMetaData();
//user.UserName = "";
IterateFolders(oTree, ref folderList);

if (folderList.Count > 0)
{

string RouteFolderName = MailService.GetRouteFolderName(Convert.ToInt64(oTree.Tag/*TreeMailNodes.SelectedNode.Tag*/));
//userCount++;
user.ExportType = ExportTypeEnum.Selected;
user.UserName = RouteFolderName;
user.FolderList.AddRange(folderList);
user.FolderCount = folderList.Count;
userList.Add(user);
userCount++;
}
folderList.Clear();


}
if (userCount != 0)
{
Export.UserCount = userCount;

Export.UserList = userList;
ClsExportCreateXML XMLCreater = new ClsExportCreateXML();
XMLCreater.CreateXML(Export);
}
//End
///////////////////////////////////////////////////////////


}

else
{

// Route Folder
List<ClsExportUserMetaData> userList = new List<ClsExportUserMetaData>();
//ClsExportUserMetaData user = new ClsExportUserMetaData();
clsExport Export = new clsExport();
int userCount = 0;
foreach (TreeNode oTree in TreeMailNodes.Nodes)
{
ClsExportUserMetaData user = new ClsExportUserMetaData();
//user.UserName = "";
if (oTree.Checked == true)
{
string RouteFolderName = MailService.GetRootFolderName(Convert.ToInt64(oTree.Tag));



user.ExportType = ExportTypeEnum.Full;
user.UserName = RouteFolderName;
userList.Add(user);
userCount++;
}
}

if (userCount != 0)
{
Export.UserCount = Export.UserList.Count;
Export.UserList = userList;
ClsExportCreateXML XMLCreater = new ClsExportCreateXML();
XMLCreater.CreateXML(Export);
}
} //MessageBox.Show("Live Exchange Server");

CLICaller.bIsPublicFolderRestore = false;
// Create new SaveFileDialog object
SaveFileDialog DialogSave = new SaveFileDialog();




DialogSave.DefaultExt = "pst";
DialogSave.Filter = "Personal Folder (*.pst)|*.pst";
// Adds a extension if the user does not
DialogSave.AddExtension = true;
// Restores the selected directory, next time
DialogSave.RestoreDirectory = true;
// Dialog title
DialogSave.Title = "Where do you want to save the file?";
// Startup directory
DialogSave.InitialDirectory = @"C:/";
// Show the dialog and process the result
if (DialogSave.ShowDialog() == DialogResult.OK)
{
CLICaller.RestoreDataToUser("", DialogSave.FileName, System.Environment.CurrentDirectory + "\\ExportMail.xml", "");
MessageBox.Show("Restore Completed Successfully", "Restore", MessageBoxButtons.OK, MessageBoxIcon.None);
this.Close();
}
else
{
DialogSave.Dispose();
}

DialogSave.Dispose();
DialogSave = null;
}
}
/// <summary>
/// Restore to Public Folder
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

else if (RdoButnPublicFolder.Checked == true)
{
//MessageBox.Show("Public Folder");
if (TreeMailNodes.SelectedNode != null)
{
string NodeName = "";
string strNodes = TreeMailNodes.SelectedNode.FullPath;
String[] Nodes = strNodes.Split('\\');
//Nodes.Remove(0);

for (int i = 1; i < Nodes.Length; i++)
{

NodeName = NodeName + Nodes[i];
if (i != Nodes.Length - 1)
NodeName = NodeName + "\\";

}
if (TreeMailNodes.SelectedNode.Level > 0)
{

List<ClsExportUserMetaData> userList = new List<ClsExportUserMetaData>();

List<clsExportFolder> folderList = new List<clsExportFolder>();
int userCount = 0;
clsExport Export = new clsExport();
foreach (TreeNode oTree in TreeMailNodes.Nodes)
{
ClsExportUserMetaData user = new ClsExportUserMetaData();
//user.UserName = "";
IterateFolders(oTree, ref folderList);

if (folderList.Count > 0)
{

string RouteFolderName = MailService.GetRouteFolderName(Convert.ToInt64(oTree.Tag/*TreeMailNodes.SelectedNode.Tag*/));
//userCount++;
user.ExportType = ExportTypeEnum.Selected;
user.UserName = RouteFolderName;
user.FolderList.AddRange(folderList);
user.FolderCount = folderList.Count;
userList.Add(user);
userCount++;
}
folderList.Clear();


}
if (userCount != 0)
{
Export.UserCount = userCount;

Export.UserList = userList;
ClsExportCreateXML XMLCreater = new ClsExportCreateXML();
XMLCreater.CreateXML(Export);
}
//End
///////////////////////////////////////////////////////////


}

else
{

// Route Folder
List<ClsExportUserMetaData> userList = new List<ClsExportUserMetaData>();
//ClsExportUserMetaData user = new ClsExportUserMetaData();
clsExport Export = new clsExport();
int userCount = 0;
foreach (TreeNode oTree in TreeMailNodes.Nodes)
{
ClsExportUserMetaData user = new ClsExportUserMetaData();
//user.UserName = "";
if (oTree.Checked == true)
{
string RouteFolderName = MailService.GetRootFolderName(Convert.ToInt64(oTree.Tag));



user.ExportType = ExportTypeEnum.Full;
user.UserName = RouteFolderName;
userList.Add(user);
userCount++;
}
}

if (userCount != 0)
{
Export.UserCount = Export.UserList.Count;
Export.UserList = userList;
ClsExportCreateXML XMLCreater = new ClsExportCreateXML();
XMLCreater.CreateXML(Export);
}
}

CLICaller.bIsPublicFolderRestore = true;

FrmRestore frmrest = new FrmRestore();
frmrest.ShowDialog(this);

this.Close();
}

}

/// <summary>
/// Restore to XML
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
///
else if (RdoButnXML.Checked == true)
{


//////////////////////////////////////////////////
string NodeName = "";
string strNodes = TreeMailNodes.SelectedNode.FullPath;
String[] Nodes = strNodes.Split('\\');
//Nodes.Remove(0);

for (int i = 1; i < Nodes.Length; i++)
{

NodeName = NodeName + Nodes[i];
if (i != Nodes.Length - 1)
NodeName = NodeName + "\\";

}

FolderBrowserDialog browsefolder = new FolderBrowserDialog();


if (browsefolder.ShowDialog() == DialogResult.OK)
{

browsefolder.Dispose();

Thread.Sleep(500);

frmLoading frmload = new frmLoading();
frmload.Show();

string RouteFolderName = MailService.GetRouteFolderName(Convert.ToInt64(TreeMailNodes.SelectedNode.Tag));
ClsExportXML ExportXML = new ClsExportXML();
//ExportXML.UserCountXML = 1;
List<ClsExportUserMetaDataForXML> UserListXML = new List<ClsExportUserMetaDataForXML>();
ClsExportUserMetaDataForXML UserXML = new ClsExportUserMetaDataForXML();
UserXML.ExportTypeXML = ExportTypeEnumXML.Selected;
UserXML.UserNameXML = RouteFolderName;
List<ClsExportFolderXML> folderListXML = new List<ClsExportFolderXML>();
ClsExportFolderXML folderXML1 = new ClsExportFolderXML();
folderXML1.ExportTypeXML = ExportTypeEnumXML.Selected;
folderXML1.FolderNameXML = NodeName;
List<ClsExportMailXML> MailXMLList = new List<ClsExportMailXML>();
List<ClsExportTaskXML> TaskXMLList = new List<ClsExportTaskXML>();
List<ClsExportContactXML> ContactXMLList = new List<ClsExportContactXML>();
List<ClsExportJournalXML> JournalXMLList = new List<ClsExportJournalXML>();
List<ClsExportCalendarXML> CalendarXMLList = new List<ClsExportCalendarXML>();
List<ClsExportNotesXML> NoteXMLList = new List<ClsExportNotesXML>();



/////////////////////////////////////////////////////


if (TreeMailNodes.SelectedNode.Level >= 0)
{
List<clsExportFolder> folderList = new List<clsExportFolder>();
foreach (TreeNode oTree in TreeMailNodes.Nodes)
{
if (oTree.Checked == false)
IterateFoldersXML(oTree, ref folderList, browsefolder.SelectedPath);
else if (oTree.Checked == true)
IterateFoldersXMLAll(oTree, ref folderList, browsefolder.SelectedPath);
}


}

frmload.Close();
MessageBox.Show("Export To XML is completed", "Exported", MessageBoxButtons.OK, MessageBoxIcon.None);
this.Close();
}
else
{
browsefolder.Dispose();
}

browsefolder.Dispose();
}
else
this.Close();
}
else
{
MessageBox.Show("No Folders Selected");
}

}
}


private void IterateFolders(TreeNode oTree, ref List<clsExportFolder> folderList)
{

foreach (TreeNode oSubtree in oTree.Nodes)
{

if (oSubtree.Checked == true)
{
clsExportFolder folder1 = new clsExportFolder();
folder1.ExportType = ExportTypeEnum.Full;
string NodeName = "";
string strNodes = oSubtree.FullPath;//TreeMailNodes.SelectedNode.FullPath;
String[] Nodes = strNodes.Split('\\');
//Nodes.Remove(0);


for (int i = 1; i < Nodes.Length; i++)
{

NodeName = NodeName + Nodes[i];
if (i != Nodes.Length - 1)
NodeName = NodeName + "\\";
}
folder1.FolderName = NodeName;
folderList.Add(folder1);
}
else
if (oSubtree.Nodes.Count > 0)
{
IterateFolders(oSubtree, ref folderList);
}

}

}



private void IterateFoldersXML(TreeNode oMainTree, ref List<clsExportFolder> folderList, String strBrowsePath)
{

foreach (TreeNode oSubtree in oMainTree.Nodes)
{

if (oSubtree.Checked == true)
{
clsExportFolder folder1 = new clsExportFolder();
folder1.ExportType = ExportTypeEnum.Full;
string NodeName = "";
string strNodes = oSubtree.FullPath;//TreeMailNodes.SelectedNode.FullPath;
String[] Nodes = strNodes.Split('\\');
//Nodes.Remove(0);


for (int i = 1; i < Nodes.Length; i++)
{

NodeName = NodeName + Nodes[i];
if (i != Nodes.Length - 1)
NodeName = NodeName + "\\";
}
folder1.FolderName = NodeName;
folderList.Add(folder1);

////////////////////////////////////
string RouteFolderName = MailService.GetRouteFolderName(Convert.ToInt64(TreeMailNodes.SelectedNode.Tag));
ClsExportXML ExportXML = new ClsExportXML();
//ExportXML.UserCountXML = 1;
List<ClsExportUserMetaDataForXML> UserListXML = new List<ClsExportUserMetaDataForXML>();
ClsExportUserMetaDataForXML UserXML = new ClsExportUserMetaDataForXML();
UserXML.ExportTypeXML = ExportTypeEnumXML.Selected;
UserXML.UserNameXML = RouteFolderName;
List<ClsExportFolderXML> folderListXML = new List<ClsExportFolderXML>();
ClsExportFolderXML folderXML1 = new ClsExportFolderXML();
folderXML1.ExportTypeXML = ExportTypeEnumXML.Selected;
folderXML1.FolderNameXML = NodeName;
List<ClsExportMailXML> MailXMLList = new List<ClsExportMailXML>();
List<ClsExportTaskXML> TaskXMLList = new List<ClsExportTaskXML>();
List<ClsExportContactXML> ContactXMLList = new List<ClsExportContactXML>();
List<ClsExportJournalXML> JournalXMLList = new List<ClsExportJournalXML>();
List<ClsExportCalendarXML> CalendarXMLList = new List<ClsExportCalendarXML>();
List<ClsExportNotesXML> NoteXMLList = new List<ClsExportNotesXML>();




////////////////////////////////////
String subQuery = "";
String SearchQuery = "";

if (oSubtree.Text == "Calendar")
{
subQuery = "dbo.AppointmentMaster";
List<AppointmentDetailDTO> AppList = new List<AppointmentDetailDTO>();

if (oSubtree.Level > 0)
//If ROute Folder has been selected
SearchQuery = "Select * from " + subQuery + " where SubFolderId=" + oSubtree.Tag;
else
//If Sub Folder has been selected
SearchQuery = "Select * from " + subQuery + " where RouteFolderId=" + oSubtree.Tag;

AppList.AddRange(MailService.GetAppointmentDetailByCondition(SearchQuery));

//(Temp);

foreach (TreeNode oTree in oSubtree.Nodes)
{
List<AppointmentDetailDTO> Temp;

if (oSubtree.Level > 0)
//If ROute Folder has been selected
SearchQuery = "Select * from " + subQuery + " where SubFolderId=" + oTree.Tag /* TreeMailNodes.SelectedNode.Tag*/;
else
//If Sub Folder has been selected
SearchQuery = "Select * from " + subQuery + " where RouteFolderId=" + oTree.Tag /*TreeMailNodes.SelectedNode.Tag*/;

Temp = MailService.GetAppointmentDetailByCondition(SearchQuery);

AppList.AddRange(Temp);
}

for (int i = 0; i < AppList.Count; i++)
{

ClsExportCalendarXML caleXML1 = new ClsExportCalendarXML();

caleXML1.SentDate = Convert.ToDateTime(AppList[i].CreationTime);
caleXML1.Subject = Convert.ToString(AppList[i].Subject);
caleXML1.Location = Convert.ToString(AppList[i].Location);
caleXML1.StartDate = Convert.ToDateTime(AppList[i].StartTimeUTC);
caleXML1.EndDate = Convert.ToDateTime(AppList[i].EndTimeUTC);
caleXML1.Body = Convert.ToString(AppList[i].Body);
caleXML1.RecuranceState = Convert.ToString(AppList[i].RecurrenceState);

CalendarXMLList.Add(caleXML1);

folderXML1.CalendarListXML = CalendarXMLList;
folderListXML.Add(folderXML1);
UserXML.FolderListXML = folderListXML;
UserListXML.Add(UserXML);
ExportXML.UserListXML = UserListXML;
ClsExportCreateXMLForXML XMLCreaterXML = new ClsExportCreateXMLForXML();
XMLCreaterXML.CreateXMLForXML(ExportXML, strBrowsePath);
CalendarXMLList.Clear();
folderListXML.Clear();
UserListXML.Clear();

}
AppList.Clear();

}
else if (oSubtree.Text == "Contacts")
{
subQuery = "dbo.ContactMaster";
List<ContactDetailDTO> ContactList = new List<ContactDetailDTO>();

if (oSubtree.Level > 0)
//If ROute Folder has been selected
SearchQuery = "Select * from " + subQuery + " where SubFolderId=" + oSubtree.Tag;
else
//If Sub Folder has been selected
SearchQuery = "Select * from " + subQuery + " where RouteFolderId=" + oSubtree.Tag;

ContactList.AddRange(MailService.GetContactDetailByCondition(SearchQuery));

//(Temp);

foreach (TreeNode oTree in oSubtree.Nodes)
{
List<ContactDetailDTO> Temp;

if (oSubtree.Level > 0)
//If ROute Folder has been selected
SearchQuery = "Select * from " + subQuery + " where SubFolderId=" + oTree.Tag /* oSubtree.Tag*/;
else
//If Sub Folder has been selected
SearchQuery = "Select * from " + subQuery + " where RouteFolderId=" + oTree.Tag /*oSubtree.Tag*/;

Temp = MailService.GetContactDetailByCondition(SearchQuery);

ContactList.AddRange(Temp);
}

for (int i = 0; i < ContactList.Count; i++)
{

ClsExportContactXML contXML1 = new ClsExportContactXML();
// contXML1.SentDate = Convert.ToDateTime(dtgContact.Rows[i].Cells["CreationTime"].Value);
contXML1.EmailID = Convert.ToString(ContactList[i].Email1Address);
contXML1.Name = Convert.ToString(ContactList[i].FullName);
contXML1.Companies = Convert.ToString(ContactList[i].Companies);
contXML1.BusinessAddress = Convert.ToString(ContactList[i].BusinessAddress);
contXML1.Mobile = Convert.ToString(ContactList[i].MobileTelephoneNumber);
ContactXMLList.Add(contXML1);


folderXML1.ContactListXML = ContactXMLList;
folderListXML.Add(folderXML1);
UserXML.FolderListXML = folderListXML;
UserListXML.Add(UserXML);
ExportXML.UserListXML = UserListXML;
ClsExportCreateXMLForXML XMLCreaterXML = new ClsExportCreateXMLForXML();
XMLCreaterXML.CreateXMLForXML(ExportXML, strBrowsePath);
ContactXMLList.Clear();
folderListXML.Clear();
UserListXML.Clear();

}
ContactList.Clear();
}
else if (oSubtree.Text == "Journal")
{
subQuery = "dbo.JournalMaster";
List<JournalDetailDTO> JournalList = new List<JournalDetailDTO>();

if (oSubtree.Level > 0)
//If ROute Folder has been selected
SearchQuery = "Select * from " + subQuery + " where SubFolderId=" + oSubtree.Tag;
else
//If Sub Folder has been selected
SearchQuery = "Select * from " + subQuery + " where RouteFolderId=" + oSubtree.Tag;

JournalList.AddRange(MailService.GetJournalDetailByCondition(SearchQuery));

//(Temp);

foreach (TreeNode oTree in oSubtree.Nodes)
{
List<JournalDetailDTO> Temp;

if (oSubtree.Level > 0)
//If ROute Folder has been selected
SearchQuery = "Select * from " + subQuery + " where SubFolderId=" + oTree.Tag /* oSubtree.Tag*/;
else
//If Sub Folder has been selected
SearchQuery = "Select * from " + subQuery + " where RouteFolderId=" + oTree.Tag /*oSubtree.Tag*/;

Temp = MailService.GetJournalDetailByCondition(SearchQuery);

JournalList.AddRange(Temp);
}

for (int i = 0; i < JournalList.Count; i++)
{


ClsExportJournalXML jourXML1 = new ClsExportJournalXML();
jourXML1.SentDate = Convert.ToDateTime(JournalList[i].CreationTime);
jourXML1.Subject = Convert.ToString(JournalList[i].Subject);
jourXML1.Companies = Convert.ToString(JournalList[i].Companies);
jourXML1.StartDate = Convert.ToDateTime(JournalList[i].Start);
jourXML1.Body = Convert.ToString(JournalList[i].Body);
jourXML1.Duration = Convert.ToInt32(JournalList[i].Duration);

JournalXMLList.Add(jourXML1);

folderXML1.JournalListXML = JournalXMLList;
folderListXML.Add(folderXML1);
UserXML.FolderListXML = folderListXML;
UserListXML.Add(UserXML);
ExportXML.UserListXML = UserListXML;
ClsExportCreateXMLForXML XMLCreaterXML = new ClsExportCreateXMLForXML();
XMLCreaterXML.CreateXMLForXML(ExportXML, strBrowsePath);
JournalXMLList.Clear();
folderListXML.Clear();
UserListXML.Clear();

}
JournalList.Clear();
}
else if (oSubtree.Text == "Notes")
{
subQuery = "dbo.NoteMaster";
List<NoteDetailDTO> NoteList = new List<NoteDetailDTO>();

if (oSubtree.Level > 0)
//If ROute Folder has been selected
SearchQuery = "Select * from " + subQuery + " where SubFolderId=" + oSubtree.Tag;
else
//If Sub Folder has been selected
SearchQuery = "Select * from " + subQuery + " where RouteFolderId=" + oSubtree.Tag;

NoteList.AddRange(MailService.GetNotesDetailByCondition(SearchQuery));

//(Temp);

foreach (TreeNode oTree in oSubtree.Nodes)
{
List<NoteDetailDTO> Temp;

if (oSubtree.Level > 0)
//If ROute Folder has been selected
SearchQuery = "Select * from " + subQuery + " where SubFolderId=" + oTree.Tag /* oSubtree.Tag*/;
else
//If Sub Folder has been selected
SearchQuery = "Select * from " + subQuery + " where RouteFolderId=" + oTree.Tag /*oSubtree.Tag*/;

Temp = MailService.GetNotesDetailByCondition(SearchQuery);

NoteList.AddRange(Temp);
}

for (int i = 0; i < NoteList.Count; i++)
{


ClsExportNotesXML notXML1 = new ClsExportNotesXML();
notXML1.SentDate = Convert.ToDateTime(NoteList[i].CreationTime);
notXML1.Subject = Convert.ToString(NoteList[i].Subject);
notXML1.Body = Convert.ToString(NoteList[i].Body);

NoteXMLList.Add(notXML1);

folderXML1.NoteListXML = NoteXMLList;
folderListXML.Add(folderXML1);
UserXML.FolderListXML = folderListXML;
UserListXML.Add(UserXML);
ExportXML.UserListXML = UserListXML;
ClsExportCreateXMLForXML XMLCreaterXML = new ClsExportCreateXMLForXML();
XMLCreaterXML.CreateXMLForXML(ExportXML, strBrowsePath);
NoteXMLList.Clear();
folderListXML.Clear();
UserListXML.Clear();

}
NoteList.Clear();
}
else if (oSubtree.Text == "Tasks")
{
subQuery = "dbo.TaskMaster";
List<TaskDetailDTO> TaskList = new List<TaskDetailDTO>();

if (oSubtree.Level > 0)
//If ROute Folder has been selected
SearchQuery = "Select * from " + subQuery + " where SubFolderId=" + oSubtree.Tag;
else
//If Sub Folder has been selected
SearchQuery = "Select * from " + subQuery + " where RouteFolderId=" + oSubtree.Tag;

TaskList.AddRange(MailService.GetTasktDetailByCondition(SearchQuery));

//(Temp);

foreach (TreeNode oTree in oSubtree.Nodes)
{
List<TaskDetailDTO> Temp;

if (oSubtree.Level > 0)
//If ROute Folder has been selected
SearchQuery = "Select * from " + subQuery + " where SubFolderId=" + oTree.Tag /* oSubtree.Tag*/;
else
//If Sub Folder has been selected
SearchQuery = "Select * from " + subQuery + " where RouteFolderId=" + oTree.Tag /*oSubtree.Tag*/;

Temp = MailService.GetTasktDetailByCondition(SearchQuery);

TaskList.AddRange(Temp);
}

for (int i = 0; i < TaskList.Count; i++)
{

ClsExportTaskXML taskXML1 = new ClsExportTaskXML();
taskXML1.SentDate = Convert.ToDateTime(TaskList[i].CreationTime);
taskXML1.Subject = Convert.ToString(TaskList[i].Subject);
taskXML1.Status = Convert.ToString(TaskList[i].Status);
taskXML1.Body = Convert.ToString(TaskList[i].Body);
taskXML1.StartDate = Convert.ToDateTime(TaskList[i].StartDate);
taskXML1.DueDate = Convert.ToDateTime(TaskList[i].DueDate);
taskXML1.PercentComplete = Convert.ToInt32(TaskList[i].PercentComplete);

TaskXMLList.Add(taskXML1);

folderXML1.TaskListXML = TaskXMLList;
folderListXML.Add(folderXML1);
UserXML.FolderListXML = folderListXML;
UserListXML.Add(UserXML);
ExportXML.UserListXML = UserListXML;

ClsExportCreateXMLForXML XMLCreaterXML = new ClsExportCreateXMLForXML();
XMLCreaterXML.CreateXMLForXML(ExportXML, strBrowsePath);

TaskXMLList.Clear();
folderListXML.Clear();
UserListXML.Clear();

}
TaskList.Clear();
}
else
{
subQuery = "dbo.MailMaster";
List<MailDetailDTO> MailList = new List<MailDetailDTO>();

if (oSubtree.Level > 0)
//If ROute Folder has been selected
SearchQuery = "Select * from " + subQuery + " where SubFolderId=" + oSubtree.Tag;
else
//If Sub Folder has been selected
SearchQuery = "Select * from " + subQuery + " where RouteFolderId=" + oSubtree.Tag;

MailList.AddRange(MailService.GetMailDetailByCondition(SearchQuery));

//(Temp);

foreach (TreeNode oTree in oSubtree.Nodes)
{
List<MailDetailDTO> Temp = new List<MailDetailDTO>();


if (oSubtree.Level > 0)
//If ROute Folder has been selected
SearchQuery = "Select * from " + subQuery + " where SubFolderId=" + oTree.Tag /* oSubtree.Tag*/;
else
//If Sub Folder has been selected
SearchQuery = "Select * from " + subQuery + " where RouteFolderId=" + oTree.Tag /*oSubtree.Tag*/;

Temp = MailService.GetMailDetailByCondition(SearchQuery);

if (oTree.Nodes.Count > 0)
GetMailList(oTree, ref MailList, subQuery);


MailList.AddRange(Temp);
//GetMailList(oTree, ref MailList, subQuery);
// List<MailDetailDTO> Temp;

// if (oSubtree.Level > 0)
// //If ROute Folder has been selected
// SearchQuery = "Select * from " + subQuery + " where SubFolderId=" + oTree.Tag /* oSubtree.Tag*/;
// else
// //If Sub Folder has been selected
// SearchQuery = "Select * from " + subQuery + " where RouteFolderId=" + oTree.Tag /*oSubtree.Tag*/;

// Temp = MailService.GetMailDetailByCondition(SearchQuery);

// MailList.AddRange(Temp);
}



for (int i = 0; i < MailList.Count; i++)
{

ClsExportMailXML MailXML1 = new ClsExportMailXML();
MailXML1.SentDate = Convert.ToDateTime(MailList[i].MailDate);
MailXML1.Subject = Convert.ToString(MailList[i].MailSubject);
MailXML1.From = Convert.ToString(MailList[i].MailFrom);
MailXML1.To = Convert.ToString(MailList[i].MailTo);
MailXML1.Cc = Convert.ToString(MailList[i].MailCc);
MailXML1.Bcc = Convert.ToString(MailList[i].MailBcc);
MailXML1.MailBodyNew = Convert.ToString(MailList[i].MailBodyNew);
MailXMLList.Add(MailXML1);
/////////////////////////
folderXML1.MailListXML = MailXMLList;
folderListXML.Add(folderXML1);
UserXML.FolderListXML = folderListXML;
UserListXML.Add(UserXML);
ExportXML.UserListXML = UserListXML;

ClsExportCreateXMLForXML XMLCreaterXML = new ClsExportCreateXMLForXML();
XMLCreaterXML.CreateXMLForXML(ExportXML, strBrowsePath);

MailXMLList.Clear();
folderListXML.Clear();
UserListXML.Clear();



}
MailList.Clear();

}

}
else
if (oSubtree.Nodes.Count > 0)
{
IterateFoldersXML(oSubtree, ref folderList, strBrowsePath);
}

}

}


private void IterateFoldersXMLAll(TreeNode oMainTree, ref List<clsExportFolder> folderList, String strBrowsePath)
{

foreach (TreeNode oSubtree in oMainTree.Nodes)
{


clsExportFolder folder1 = new clsExportFolder();
folder1.ExportType = ExportTypeEnum.Full;
string NodeName = "";
string strNodes = oSubtree.FullPath;//TreeMailNodes.SelectedNode.FullPath;
String[] Nodes = strNodes.Split('\\');
//Nodes.Remove(0);


for (int i = 1; i < Nodes.Length; i++)
{

NodeName = NodeName + Nodes[i];
if (i != Nodes.Length - 1)
NodeName = NodeName + "\\";
}
folder1.FolderName = NodeName;
folderList.Add(folder1);

////////////////////////////////////
string RouteFolderName = MailService.GetRouteFolderName(Convert.ToInt64(TreeMailNodes.SelectedNode.Tag));
ClsExportXML ExportXML = new ClsExportXML();
//ExportXML.UserCountXML = 1;
List<ClsExportUserMetaDataForXML> UserListXML = new List<ClsExportUserMetaDataForXML>();
ClsExportUserMetaDataForXML UserXML = new ClsExportUserMetaDataForXML();
UserXML.ExportTypeXML = ExportTypeEnumXML.Selected;
UserXML.UserNameXML = RouteFolderName;
List<ClsExportFolderXML> folderListXML = new List<ClsExportFolderXML>();
ClsExportFolderXML folderXML1 = new ClsExportFolderXML();
folderXML1.ExportTypeXML = ExportTypeEnumXML.Selected;
folderXML1.FolderNameXML = NodeName;
List<ClsExportMailXML> MailXMLList = new List<ClsExportMailXML>();
List<ClsExportTaskXML> TaskXMLList = new List<ClsExportTaskXML>();
List<ClsExportContactXML> ContactXMLList = new List<ClsExportContactXML>();
List<ClsExportJournalXML> JournalXMLList = new List<ClsExportJournalXML>();
List<ClsExportCalendarXML> CalendarXMLList = new List<ClsExportCalendarXML>();
List<ClsExportNotesXML> NoteXMLList = new List<ClsExportNotesXML>();




////////////////////////////////////
String subQuery = "";
String SearchQuery = "";

if (oSubtree.Text == "Calendar")
{
subQuery = "dbo.AppointmentMaster";
List<AppointmentDetailDTO> AppList = new List<AppointmentDetailDTO>();

if (oSubtree.Level > 0)
//If ROute Folder has been selected
SearchQuery = "Select * from " + subQuery + " where SubFolderId=" + oSubtree.Tag;
else
//If Sub Folder has been selected
SearchQuery = "Select * from " + subQuery + " where RouteFolderId=" + oSubtree.Tag;

AppList.AddRange(MailService.GetAppointmentDetailByCondition(SearchQuery));

//(Temp);

foreach (TreeNode oTree in oSubtree.Nodes)
{
List<AppointmentDetailDTO> Temp;

if (oSubtree.Level > 0)
//If ROute Folder has been selected
SearchQuery = "Select * from " + subQuery + " where SubFolderId=" + oTree.Tag /* TreeMailNodes.SelectedNode.Tag*/;
else
//If Sub Folder has been selected
SearchQuery = "Select * from " + subQuery + " where RouteFolderId=" + oTree.Tag /*TreeMailNodes.SelectedNode.Tag*/;

Temp = MailService.GetAppointmentDetailByCondition(SearchQuery);

AppList.AddRange(Temp);
}

for (int i = 0; i < AppList.Count; i++)
{

ClsExportCalendarXML caleXML1 = new ClsExportCalendarXML();

caleXML1.SentDate = Convert.ToDateTime(AppList[i].CreationTime);
caleXML1.Subject = Convert.ToString(AppList[i].Subject);
caleXML1.Location = Convert.ToString(AppList[i].Location);
caleXML1.StartDate = Convert.ToDateTime(AppList[i].StartTimeUTC);
caleXML1.EndDate = Convert.ToDateTime(AppList[i].EndTimeUTC);
caleXML1.Body = Convert.ToString(AppList[i].Body);
caleXML1.RecuranceState = Convert.ToString(AppList

Thanks And Regards.
Kamlesh Nikam
Author: chandrakant             
Posted Date: March 19, 2011     Points: 20   

use

TextBox1.Focus();

Regards,

Chandrakant Kadu


Author: Sunil Yadav       [Moderator]      
Posted Date: March 19, 2011     Points: 20   

@Kamlesh Nikam : Posting 400 + line of code will be difficult to understand as people ignores reading many line of code.Hence it will not be helpful. Post only the code which encounters an error.


Author: Maverick             
Posted Date: March 29, 2011     Points: 20   

Hello,

Its simple
txttextbox.focus()

Thanks,
Maverick

Thanks,
Maverick
Author: Narayanan             
Posted Date: July 12, 2011     Points: 20   

Hi,
if (TextBox1.Text == "")
{
MessageBox.Show("No Empty Box in the Screen")
TextBox1.Focus();
}
else
{
// Do Something
}


Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend