|
This is absolutely better idea also it is also the best solution that comes to my mind. For your requirement the only solution is creating a base assebmly can be named as InfrastructureLayer that referenced by all other assemblies.
|
|
|
|
|
armkbdotcom wrote: a second assembly
Or would that be a third assembly? Yes, that sounds like a good idea.
|
|
|
|
|
yea, sorry. third assembly (second class library).
I already went that way and looks very nice so far.
|
|
|
|
|
Yes, your idea is 100% better ...i don't know what i was thinking telling you to add a circular reference.
I guess that just goes to show you, even if someone answers your question you still need to think about it.
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Hi
I have xml file format mentioned "code" section.
In my program, i know Failure_ID(it comes from some other binary file), based on "Failure_ID" i want to read "Name" value from XML.
i want to read "Name" thru "Failure_ID".
Please help me to write code for this.
I am using C# windows Applcation, .net 3.5 framework
Thanks
<Failure_Table>
<Failure_ID="1" Name = "Failure_1" Description = "TBD" />
<Failure_ID="2" Name = "Failure_2" Description = "TBD" />
<Failure_ID="3" Name = "Failure_3" Description = "TBD" />
</Failure_Table>
|
|
|
|
|
What have you tried ? What research have you done ? What books do you own ? The key words for your google search are XPath and XMLDocument.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I would have suggested that you use SelectSingleNode (member of XmlDocument ), but that won't work since this is not valid XML. The problem is this part <Failure_ID="1" , which as far as I can see quickly is never valid XML, and certainly not in this case. The problem is, there is either no element name or no attribute name (but it's impossible to tell which is missing). I suggest you change it to <Failure ID="3" Name="whatever" Description="Something">
Or if you're not in a position to change the format, use an other way to read the data - not as XML because that's not what it is.
If you go for the first option, the code to select the Name based on the ID could be something like
myDocument.SelectSingleNode("/Failure_Table/Failure[@ID=\"" + theID + "\"]/Name).Value
(warning: untested, and does not do any checking so will fail if Name is not present)
Hope that helps
|
|
|
|
|
Hi the child xml nodes are invalid. you need to add element name to the child element nodes.
Below format is be the correct one :
<Failure_Table>
<Failure Failure_ID="1" Name="Failure_1" Description="TBD" />
<Failure Failure_ID="2" Name="Failure_2" Description="TBD" />
<Failure Failure_ID="3" Name="Failure_3" Description="TBD" />
</Failure_Table>
And here is the C# code :
string _xmlData = "<Failure_Table>" +
"<Failure Failure_ID=\"1\" Name = \"Failure_1\" Description = \"TBD\" />" +
"<Failure Failure_ID=\"2\" Name = \"Failure_2\" Description = \"TBD\" />" +
"<Failure Failure_ID=\"3\" Name = \"Failure_3\" Description = \"TBD\" />" +
"</Failure_Table>";
int desiredFailure_ID = 2;
string name;
XmlDocument doc = new XmlDocument();
doc.LoadXml(_xmlData);
XmlNodeList list = doc.SelectNodes(@"//Failure");
foreach (XmlNode pNode in list)
{
int failure_ID =int.Parse(pNode.Attributes["Failure_ID"].Value);
if (failure_ID == desiredFailure_ID)
name = pNode.Attributes["Name"].Value;
}
|
|
|
|
|
I have fields in my report that are picklists, how can I set the the value of the field to display the string value?
|
|
|
|
|
Try Here[^]
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Good afternoon.
I have a form (ucTabs) with two labels (tslProgress: "Progress" tslStatus: "Status") and a progressbar (tsProgBar).
When a series of methods in the DAL layer are executed, I want to increment the progress bar and change the tslStatus to "Processing xxxx method " + "25%", "Processing yyyy method " + "50%", "Processing zzzz method " + "75%", etc.
Any suggestions?
Thank you, WHEELS
|
|
|
|
|
|
|
I have my DAL raise events for logging progress, but a consumer could attach a handler that updates a ProgressBar if it wanted.
|
|
|
|
|
Good afternoon.
I have the following code in my DAL.cs:
private ucTabs ucT = new ucTabs();
private Timer time = new Timer();
private void InitializeMyTimer()
{
time.Interval = 250;
time.Tick += new EventHandler(IncreaseProgressBar);
time.Start();
}
private void IncreaseProgressBar(object sender, EventArgs e)
{
ucT.tsProgBar.Increment(25);
ucT.tslStatus.Text = ucT.tsProgBar.Value.ToString() + "% Completed";
if (ucT.tsProgBar.Value == ucT.tsProgBar.Maximum)
time.Stop();
}
public void importStuff()
{
InitializeMyTimer();
}
Can't seem to get the Progress bar to move at all. Any suggestions? WHEELS
|
|
|
|
|
I have one doubt regarding this? Why are you doing all those stuff in Data Adapter Layer ? You should display the progress only On UI layer itself. User background wroker thread to call the DAL method. which will show the progress of execution. If you are doing all these stuff in DAL, where are you retruning the value to UI?
cheers,
Abhijit
CodeProject MVP
Web Site:abhijitjana.net
When you ask a question, remember to click "Good Answer", If the Answer is helps you.
|
|
|
|
|
Good morning Abhijit.
I am calling an import method (which call several other import methods) from the form class.
I am also referncing the form's progres bar and label in the DAL.
I had some difficultly getting the background worker thread to work.
You would think there was a simple way to accomplist what I am trying to do.
WHEELS
|
|
|
|
|
Wheels012 wrote: time.Tick += new EventHandler(IncreaseProgressBar);
Instead I would do something like:
dal.OnProgress += IncreaseProgressBar ;
Bear in mind that when using a thread to do the work, IncreaseProgressBar will need to check InvokeRequired and call Invoke if needed.
This way, when the dal has an update, it will execute IncreaseProgressBar itself without having to know what it does or why.
If you haven't learned events[^] yet, this would be a good time.
|
|
|
|
|
I have created a class object to diplay information.
It is a Panel with a Button on it.
When the Button is pressed it process some data and displays the data on the Panel on Labels, etc.
The end result (After clicking a Button on my DisplayClass)is a value that I want passed back to the Form that has my DisplayClass on.
I had though that I could pass a pointer to a function to my Display class and have it call it that would drive code on my main form, but I can't figure it out.
TestDisplay = new UsageDisplayPanelClass();
TestDisplay.Location = new System....
TestDisplay.Size = new Syste....
TestDisplay.Click += new System.EventHandler(TestDisplayClick);
The Click event never gets back to my main program because it is captured through a Button.Click in my TestDisplay Class
Is there a way to have both my Class handle the button click then have the event resent to my main program?
Thank you in Advance
Douglas
|
|
|
|
|
Hi,
in .NET the producer typically offers a public event, to which consumers can subscribe using a event+=delegate like syntax. A delegate basically is a function pointer, so the producer when meeting some conditions will call all the delegates added to the corresponding event.
I would suggest you read up on both keywords. The key factor is you add your own event which fits the application domain (e.g. CalculationsDone).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
If you have already declared a Click event in your custom class like your code suggests, all you need to do is forward the event from the button to the event you created.
In UsageDisplayPanelClass, you will have something like this where Click is the custom event you defined:
private void ButtonClickHandler(object sender, EventArgs e)
{
if (Click != null)
{
Click(this, e);
}
}
|
|
|
|
|
<pre>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using Dotnet67.Sales.DAL;
using Dotnet67.Sales.Items;
using Dotnet67.Sales.Persons;
using System.Data.SqlClient;
namespace Dotnet67.Sales.DAL
{
public class DALHelper
{
private readonly string CONSTRING3 = "CASHIER1";
public void InsertIntoCashier(string[] str,int[] val)
{
SqlConnection con = new SqlConnection("server=.; Database=Dotnet67;uid=sa;pwd=123;");
SqlCommand com = new SqlCommand(this.CONSTRING3, con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@CashierID", val[0]);
com.Parameters.AddWithValue("@CashierName", str[0]);
con.Open();
try
{
com.ExecuteNonQuery();
}
finally
{
con.Close();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Dotnet67.Sales.DAL;
using Dotnet67.CommonTypes;
using Dotnet67.WinControls;
using System.Data.Sql;
using System.Data.SqlClient;
namespace Dotnet67.Sales.WinUI
{
public partial class ManageCashier : Form
{
public ManageCashier()
{
InitializeComponent();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void ManageCashier_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'dotnet67DataSet8.Cashier_2' table. You can move, or remove it, as needed.
this.cashier_2TableAdapter.Fill(this.dotnet67DataSet8.Cashier_2);
}
//This is the button for inserting values into grid view which is running perfect.
private void btnInsertIntoDataBase_Click(object sender, EventArgs e)
{
DALHelper dH = new DALHelper();
ManageCashier mc = new ManageCashier();
string[] str = new string[3];
int[] values = new int[3];
str[0] = txtName.Text;
dH.InsertIntoCashier(str,values);
dataGridView1.Refresh();
dataGridView1.RefreshEdit();
this.cashier_2TableAdapter.Fill(this.dotnet67DataSet8.Cashier_2);
//dataGridView1.AllowUserToDeleteRows.ToString();
}
//WHAT SHOULD I WRITE HERE IN THE BODY OF THE FOLLOWING BUTTON TO DELETE SUCCESSFULLY
private void btnDeleteFromGridViewAndDatabase_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("server=.; Database=Dotnet67;uid=sa;pwd=123;");
string stro ="DELETE FROM Cashier_2 WHERE CashierID='0'" ;
SqlCommand sqlDelete = conn.CreateCommand();
//sqlDelete.CommandText = "DELETE FROM Cashier_2 WHERE CashierID= '@cashierIDDataGridViewTextBoxColumn'";
sqlDelete.CommandText = "DELETE FROM Cashier_2 WHERE CashierID= '@CashierID'";
conn.Open();
sqlDelete.ExecuteNonQuery();
conn.Close();
}
THE FOLLOWING IS THE STORED PROCEDURE I WROTE FOR DELETING PURPOSE.
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[UET]
@CashierID nvarchar(50)
AS
BEGIN
DELETE FROM [dbo].[Cashiers] // DELETE from Table_Name where Coloumn=''
WHERE CashierID='@CashierID'
END
return
</pre>
Kindly if anyone could send me the code for this scenario.
I am using a data grid view which loads the data from the database table. My database table has only two attributes i.e, CashierID and CashierName. Now in my grid view placed on the form has an extra column i.e., the check box column. Now I want the user to check the rows he wants to delete and after checking the check boxes when he clicks the Delete button on the form then not only the selected values be deleted from the grid but also from the database table as well.<b></b>
|
|
|
|
|
Check this google result.[^]
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
modified on Wednesday, July 22, 2009 2:58 PM
|
|
|
|
|
Hello All,
any idea why SendKeys.SendWait("{ENTER}") would restore a textbox to a previous state instead of submitting it? The problem cannot be reproduced manually, it submits every time. I do not have source control of the textbox or it's form, but should be able to submit it this way.
Thanks in advance.
|
|
|
|
|
I am not quite clear what you are saying, but I have one experience with SendKeys. I was trying to built a Bluetooth remote control and was using SendKeys to pass shortcut keys to Media Player. During testing I put this code behind a windows form button event and it works only first time then do nothing. But when I interfaced it to application and there were no UI event to trigger it it worked great. May be it helps you.
|
|
|
|