|
hi friends...this is my code
please tell me + -
DAL
public static OleDbDataReader GetAll(OleDbConnection conn, bool status)
{
try
{
string query =
"SELECT [Id], [Name], [CreatedDate], [CreatedBy], " +
" [UpdatedDate], [UpdatedBy] " +
"FROM [Role] " +
"WHERE [Status] = @pStatus " +
"ORDER BY [Name] ASC";
OleDbCommand cmd = new OleDbCommand(query, conn);
OleDbParameter pStatus = cmd.Parameters.Add("@pStatus",
OleDbType.Boolean);
pStatus.Value = status;
OleDbDataReader dr = cmd.ExecuteReader();
return dr;
}
catch (OleDbException ex)
{
throw new Exception("OleDb Error: " + ex.Message);
}
catch (Exception ex)
{
throw ex;
}
}
BLL
public List<Role> GetAll(bool status)
{
List<Role> listRole = new List<Role>();
try
{
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
OleDbDataReader dr = RoleData.GetAll(conn, status);
if (dr.HasRows)
{
while (dr.Read())
{
Role role = new Role();
role.Id = int.Parse(dr["Id"].ToString());
role.Name = dr["Name"].ToString();
role.CreatedBy = dr["CreatedBy"].ToString();
role.CreatedDate = (string.Empty.Equals(dr["CreatedDate"].ToString()) ?
DateTime.MinValue :
DateTime.Parse(dr["CreatedDate"].ToString()));
role.UpdatedBy = dr["UpdatedBy"].ToString();
role.UpdatedDate = (string.Empty.Equals(dr["UpdatedDate"].ToString()) ?
DateTime.MinValue :
DateTime.Parse(dr["UpdatedDate"].ToString()));
listRole.Add(role);
}
}
return listRole;
}
catch (OleDbException ex)
{
throw new Exception("OleDb Error: " + "\n" + ex.Message);
}
catch (Exception e)
{
throw new Exception(e.Message);
}
finally
{
conn.Close();
}
}
|
|
|
|
|
Can anyone help me in detecting vehicles form still images or from video.
what I want to do is, detect the vehicles and get the vehicle count.
This system is developed for my college project.
I'm really appreciated if someone can give me any sample code or any similar source code for reference.
Thank you..
|
|
|
|
|
Repost
modified on Saturday, May 8, 2010 3:23 AM
|
|
|
|
|
I don't think it is possible to detect vehicle from image/video.
Because for detecting it we need to implement algorithm for
detection.
I do not found such algorithm anywhere. (However face recognition algorithm exists to do the same.)
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Cool answer, if others can't do it, then I surely can't!
I have no smart signature yet...
|
|
|
|
|
The worst bit is that judging by the quality of his other answers, he is serious...
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in.
Apathy Error: Don't bother striking any key.
|
|
|
|
|
It is possible to do. Law Enforcement uses software like that for license plate recognition. They could be driving down the road and run every license plate they pass instantly. Pretty impressive software but doubt it is open to C#.
|
|
|
|
|
Jinal Desai - LIVE wrote: I don't think it is possible to detect vehicle from image/video.
This may sound like a stupid question, but how do you think these things work:
1) Digital Speed Cameras.
2) Automatic number plate readers
3) Congestion charge cameras
4) etc., etc., etc.
So yes, it is possible. The algorithms are quite complex, and generally you may find that they are proprietary, and thus not normally posted on the net for everyone to read.
Just because your casual search cannot find something does not make it impossible.
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in.
Apathy Error: Don't bother striking any key.
|
|
|
|
|
If I think from your perspective then
detection of any object (complex/structural) is
possible by latest technologies.
However, they are not for public use (may be because of
they are in experimental stage or not perfect at all)...
I just answering from possibility perspective. However
perspective and thought processes are different from
man to man.
But in current scenario for "ruknil" it is equivalent to
impossible ( I M Possible).
Hope you understand!
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
ohh really??
so Jinal Desai, can't I use any image processing techniques for this?
|
|
|
|
|
Obviously you can...
But I am not sure whether it gives
you exact detection or not....
(nearly imperfect)
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
thanks for the helping dude..and if you fine any similar code just let me..it's great help to me..thank you again..
|
|
|
|
|
Jinal Desai - LIVE wrote: I don't think it is possible to detect vehicle from image/video.
Jinal Desai - LIVE wrote: Obviously you can.
Make your mind up?
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in.
Apathy Error: Don't bother striking any key.
|
|
|
|
|
Jinal Desai - LIVE wrote: But in current scenario for "ruknil" it is equivalent to
impossible ( I M Possible).
How do you suddenly know about the situation ruknil is in?
This was his first question, and his bio data is sparse - either you know him personally, or you are guessing that he is a complete beginner, and has insufficient experience.
If you mean "I don't think you can do it because I can't" then say that. But do not assume the experience or ability level of any poster based on his first question.
Just replying "it's not possible" as you did when it patently is possible (although complex) gives the wrong impression about this site, and a certain impression about you.
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in.
Apathy Error: Don't bother striking any key.
|
|
|
|
|
I'll give you the answer I gave somebody else when they asked about automatic numperplate recognition (ANPR):
"Unfortunately, you aren't going to be given the code to do this as this is a hugely complicated area, with commercial systems going for huge amounts of money. Typically ANPR systems make use of several stages to identify the number plate, these stages being:
1. Plate location. This step is responsible for identifying where the plate is in a picture.
2. Plate translation. Orienting and sizing the image, compensating for skew.
3. Image normalisation. Adjusting the brightness/contrast of the image.
4. Segmentation. Finding the characters themselves (i.e. removing items such as flags).
5. Optical Character Recognition.
Now, ANPR requires cameras to take pictures at very high speeds, and requires the processing to take place very quickly, which means that .NET is probably not going to be the most appropriate choice for processing the image (which typically requires sub-second processing). Typically these systems are written in C++ or C, are highly optimised and make use of image processing techniques such as edge detection and sharpening filters."
Now, just because you aren't going to be given the code doesn't mean that it's experimental. Police forces around the world are using this successfully right now - and courts accept this as evidence; something that wouldn't happen if they judged it experimental. More importantly, you can't judge successfully whether or not it's beyond the OPs experience - he may be a genius just looking for a little nudge.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Ummmm[^][^]
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Hi all,
I have a question as to where to begin with what I'd like to to in a datagridview. The datagridview is bound to a dataset data table. One of the columns is a combobox. I want another column that is also a combobox too, but filtered based upon the selection of the first combobox.
Ex.
Column 1
Force
Column 2
lb
N
ton
or
Column 1
Torque
Column 2
in-lb
N-m
etc, etc.
My initial thought is to have an if loop that build the collection in the second combobox based upon the selection of the first. However, I don't know where this would go (even if that were to be the most efficient way to do it). Any help would be greatly appreciated.
Thanks.
|
|
|
|
|
You might want to start from here.
|
|
|
|
|
You should try ItemDatabound event to populate the second DropDownList
protected void dgEmpleados_ItemDataBound(object sender, DataGridItemEventArgs e)
{
DataTable dt = (DataTable)((DataGrid)sender).DataSource;
if (dt.Rows.Count > 0 && e.Item.ItemIndex > -1)
{
((CheckBox)e.Item.Cells[0].FindControl("chkSeleccionar")).Checked =
Convert.ToBoolean( dt.Rows[e.Item.ItemIndex][_COL_SELECCIONAR].ToString());
((TextBox)e.Item.Cells[0].FindControl("txtGridObservaciones")).Text =
dt.Rows[e.Item.ItemIndex][_COL_OBSERVACIONES].ToString();
}
}
|
|
|
|
|
1)create a dataTable to store all the posibilities, something like this:
Option1 - Option2
Force lb
Force N
Force ton
Torque in-lb
... ...
2)Bind this table to your second comboBox via a bindingSource.
3)On selectedIndexChanged at your first comboBox, apply a filter to your second comboBox (something like "Option1 = " + comboBox1.Text, but adapt it to a dataGridView).
The good points to thins method is that you can store the filtering posibilities in the database (like this, or based on primary keys).
I have no smart signature yet...
|
|
|
|
|
Stanciu Vlad wrote: apply a filter to your second comboBox (something like "Option1 = " + comboBox1.Text, but adapt it to a dataGridView).
I have the following filtering method:
private void GetRowsByFilter()
{
string expression;
expression = "MeasureType = 'Force'";
DataRow[] foundRows;
foundRows = table.Select(expression);
for (int i = 0; i < foundRows.Length; i++)
{
Debug.WriteLine(foundRows[i][0] + "test");
}
}
I am calling this method in my comboBox SelectedIndexChanged.
With that I do get the number of rows returned that matches Force in Debug.Writeline, but not sure how to filter the 2nd ComboBox display member. Do you have any thoughts on this?
|
|
|
|
|
You can use BindingSource to bind a dataTable to almost any control.
BindingSource bsOrders = new BindingSource();
bsOrders.DataSource = Dataset1;
bsOrders.DataMember = "Orders"
Bind the comboBoxColumn in the gridview to this binding source (if you don't know how check google, it's full of this stuff)
Then in the comboBox SelectedIndexChanged event you can directly filter the data using
if(filterText == string.Empty)
bsOrders.Filter = string.Empty;
else
bsOrders.Filter = "Option1 = " + filterText;
I have no smart signature yet...
|
|
|
|
|
I have the following and I'm having a hard time getting the second comboBox column to hook up to the filtered datasource. As you can see, there are two comboBoxColumns in the dataGridView. Am I missing something obvious here? Thanks. (Also, I have tried linking it up in primaryCB_SelectedIndexChanged, without success, which is why there isn't any code there for that)
public void Form1_Load(object sender, EventArgs e)
{
DataTable tblPrimary = dataSet1.Tables.Add("Primary");
tblPrimary.Columns.Add("Type");
tblPrimary.Rows.Add("Force");
tblPrimary.Rows.Add("Torque");
tblPrimary.Rows.Add("Pressure");
DataTable tblSecondary = dataSet1.Tables.Add("Secondary");
tblSecondary.Columns.Add("Primary_Type");
tblSecondary.Columns.Add("Unit");
tblSecondary.Rows.Add("Force", "lb");
tblSecondary.Rows.Add("Force", "N");
tblSecondary.Rows.Add("Force", "oz");
tblSecondary.Rows.Add("Torque", "in-lb");
tblSecondary.Rows.Add("Torque", "oz-in");
tblSecondary.Rows.Add("Torque", "N-m");
dataGridView1.DataSource = tblSecondary;
DataGridViewComboBoxColumn col = new DataGridViewComboBoxColumn();
col.DataSource = tblPrimary;
col.ValueMember = "Type";
dataGridView1.Columns.Add(col);
DataGridViewComboBoxColumn col2 = new DataGridViewComboBoxColumn();
col2.DataSource = tblSecondary;
col2.ValueMember = "Unit";
dataGridView1.Columns.Add(col2);
}
private void primaryCB_SelectedIndexChanged(object sender, EventArgs e)
{
if (dataGridView1.CurrentCell.ColumnIndex == 0)
{
ComboBox cb = sender as ComboBox;
if (cb != null)
{
Debug.WriteLine(cb.SelectedValue + "TEST");
BindingSource bsSecondary = new BindingSource();
bsSecondary.DataSource = dataSet1.Tables["tblSecondary"];
string filter = string.Format("Primary_Type = {0}", cb.SelectedValue);
bsSecondary.Filter = filter;
Debug.WriteLine(filter);
}
}
}
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (dataGridView1.CurrentCell.ColumnIndex == 0)
{
ComboBox cb = e.Control as ComboBox;
if (cb != null)
{
cb.SelectedIndexChanged -= primaryCB_SelectedIndexChanged;
cb.SelectedIndexChanged += primaryCB_SelectedIndexChanged;
}
}
}
modified on Monday, May 24, 2010 2:46 PM
|
|
|
|
|
BindingSource secondTableBindingSource = new BindingSource();
public void Form1_Load(object sender, EventArgs e) {
DataGridViewComboBoxColumn col = new DataGridViewComboBoxColumn();
col.DataSource = tblPrimary;
col.ValueMember = "Type";
dataGridView1.Columns.Add(col);
secondTableBindingSource.DataSource = tblSecondary;
DataGridViewComboBoxColumn col2 = new DataGridViewComboBoxColumn();
col2.DataSource = secondTableBindingSource;
col2.ValueMember = "Unit";
dataGridView1.Columns.Add(col2);
}
private void primaryCB_SelectedIndexChanged(object sender, EventArgs e)
{
if (dataGridView1.CurrentCell.ColumnIndex == 0)
{
ComboBox cb = sender as ComboBox;
if (cb != null)
{
if(cb.SelectedValue != null)
secondTableBindingSource.Filter = string.Format("Primary_Type = '{0}'", cb.SelectedValue);
else
secondTableBindingSource.Filter = string.Empty;
}
}
}
I have no smart signature yet...
|
|
|
|
|
Stanciu Vlad wrote: secondTableBindingSource.DataSource = tblSecondary;
This results in creating a table in the dataGridView that has i Rows + 1 (the +1 is the default row for the next entry), which are all blank. In this case it adds the 6 rows that correspond to 'tblSecondary.Rows.Add', but the rows added are blank. The first comboBox does allow you to drop down the three selections, but the row will remain blank. However, the filter will eliminate all rows except for a number of rows pertaining to the number of items in the filtered 'Units' column. But again they are blank, but you can at least select one and have it write to the cell. And last, but not least, selecting on the next row, 1st column comboBox throws an "Object reference not set to an instance of an object".
Unless you see something obvious here and can prod me in that direction, I have spent way too much time on trying to get this to work and it probably makes sense to throw out what I've tried and start from scratch. I thought this was going to be a bit more straightforward, but alas......
|
|
|
|