|
Hi I have a problem i hgaave a table in data grid view and i am updating data from data using a button. what i need to do is once the user update the data and click on update button i want to convert all string values to lower case. i am not using data table to populate my grid and i am updating using stored procedure. so i dnt know how to convert changed values to Lowercase before updating. can any one help me please.
Thanks
|
|
|
|
|
Hi I have a problem i hgaave a table in data grid view and i am updating data from data using a button. what i need to do is once the user update the data and click on update button i want to convert all string values to lower case. i am not using data table to populate my grid, is their any way that i can do that here is my code i am using to upgrade my grid
private void cmd_update_record_Click(object sender, EventArgs e)
{
if (dgRepair.RowCount == 0)
{
MessageBox.Show("No data available for update");
}
else
{
DataSet ChangedRepDataSet = new DataSet();
ChangedRepDataSet = ds_rep.GetChanges();
if (ChangedRepDataSet != null)
{
// Intializing object of Connectionclass to open connection
conn_obj = new ConnectionClass();
store_connection = conn_obj.connect();
// Sqlcommand object
SqlCommand cmdupdate;
cmdupdate = new SqlCommand();
cmdupdate.CommandType = CommandType.StoredProcedure;
cmdupdate.CommandText = "Update_Status_Grid";
//opening connection
cmdupdate.Connection = store_connection;
store_connection.Open();
//Adding Parameters for Repair table
cmdupdate.Parameters.Add("@OrgDescription", SqlDbType.VarChar, 100, "Description");
cmdupdate.Parameters["@OrgDescription"].SourceVersion = DataRowVersion.Original;
cmdupdate.Parameters.Add("@Description", SqlDbType.VarChar, 100, "Description");
cmdupdate.Parameters.Add("@OrgStatus", SqlDbType.VarChar, 15, "Status");
cmdupdate.Parameters["@OrgStatus"].SourceVersion = DataRowVersion.Original;
cmdupdate.Parameters.Add("@Status", SqlDbType.VarChar, 15, "Status");
cmdupdate.Parameters.Add("@OrgPartDes", SqlDbType.VarChar, 50, "PartDes");
cmdupdate.Parameters["@OrgPartDes"].SourceVersion = DataRowVersion.Original;
cmdupdate.Parameters.Add("@PartDes", SqlDbType.VarChar, 50, "PartDes");
cmdupdate.Parameters.Add("@OrgRepAction", SqlDbType.VarChar, 50, "RepAction");
cmdupdate.Parameters["@OrgRepAction"].SourceVersion = DataRowVersion.Original;
cmdupdate.Parameters.Add("@RepAction", SqlDbType.VarChar, 50, "RepAction");
cmdupdate.Parameters.Add("@OrgId", SqlDbType.BigInt ,1000, "Id");
cmdupdate.Parameters["@OrgId"].SourceVersion = DataRowVersion.Original;
//Adding the Parameters for invoice table
cmdupdate.Parameters.Add("@OrgRepCost", SqlDbType.Money, 1000, "RepCost");
cmdupdate.Parameters["@OrgRepCost"].SourceVersion = DataRowVersion.Original;
cmdupdate.Parameters.Add("@RepCost", SqlDbType.Money, 1000, "RepCost");
cmdupdate.Parameters.Add("@OrgPaymentPaid", SqlDbType.Money, 1000, "PaymentPaid");
cmdupdate.Parameters["@OrgPaymentPaid"].SourceVersion = DataRowVersion.Original;
cmdupdate.Parameters.Add("@PaymentPaid", SqlDbType.Money, 1000, "PaymentPaid");
da_rep.UpdateCommand = cmdupdate;
if (check == true)
{
try
{
da_rep.Update(ds_rep, "Repair");
ds_rep.AcceptChanges();
}
catch (Exception ex)
{
MessageBox.Show("Their is some problem in updating make sure you are entering right values " +
ex);
}
}
//}
//}
}
else
{
MessageBox.Show("no changes made");
}
//int modifiedRows = da_cus.Update(myChangedDataset);
//MessageBox.Show("Database has been updated successfully:" + no_of_rows_chang + " rows has been changed");
}
can any one help me
Thanks
|
|
|
|
|
First can you please use "CODE Block" tag from now-onwards, for your code. its really hard to read the code without that. If I understand correctly then,
Insterad of
cmdupdate.Parameters["@OrgStatus"].SourceVersion = DataRowVersion.Original;
You can use
cmdupdate.Parameters["@OrgStatus"].SourceVersion = DataRowVersion.Original.ToString().ToLower();
Whenever you are storing string values just use .ToString().ToLower() .
|
|
|
|
|
Thanks for the quick replay and thanks for the advice i will keep it in mind for next time. I tried what you suggest me but it is giving me error that can not convert from row version to string and also i am not using it pass parameter value.
I show you what i am trying
// passing value to the parameter
Parameter Type Column Name
cmdupdate.Parameters.Add("@OrgStatus", SqlDbType.VarChar, 15, "Status").ToString().
ToLower()
it does update the data base but do not convert the value into lower case.
|
|
|
|
|
I believe this can be done in numerous ways. One could be that you use ToLower-method on strings when you set the parameter values.
alwaysgull wrote: i am not using data table to populate my grid
But you seem to get the data to update from a dataset. Another option could be to either modify the data in the dataset or use computed columns. However, I didn't quite figure out why you use DataRowVersion.Original everywhere. Won't that lead to a situation where you update the same values back to the database.
|
|
|
|
|
|
If I remember correctly desktop.ini can help help.
|
|
|
|
|
Hi,
I have a TableLayoutPanel that has a couple of cells I filled with buttons, I can see there's a cell property for each button in that panel that I cant access from code, can you say, change it to change its location within the table??
Thanks guys!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
I am not sure about that but,
To change the location of your controls, you can use TableLayoutPanel.SetRow() And TableLayoutPanel.SetColumn() Method. Just pass your control and change the Row / Column.
|
|
|
|
|
I'm designing a small vector graphics app. Right now I'm writing code for painting a shape as it's being moved. For move operations, the shape is painted to a bitmap buffer so refreshes can be more effecient. Everything is working fine except when the drawing surface is scaled (zoomed).
The scaling factor is applied to the Graphics object when a paint message is called. That scaling factor is also used to generate a scaled "move bitmap" for the shape. For example, if the physical size of the shape is: 100 x 100 and the scaling factor is 50% then the move bitmap will be 50 x 50. The bitmap is then drawn as unscaled.
The problem is that the DrawImageUnscaled() method is not working! I get the same scaled results as if I were calling the DrawImage() method. This is rendering the scaled "move bitmap" to an additionaly scaled size!
Has anyone experienced this before?
//Code sample
private void initMoveBitmap()
{
//if the scaling factor is .50 the GetScaledBounds will produce a 50x50 on a 100x100 size
Rectangle r = shape.GetScaledBounds();
bmpMove = new Bitmap(r.Width, r.Height);
System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bmpMove);
gr.TranslateTransform(-r.X, -r.Y);
gr.ScaleTransform(scale, scale);
paint_move_bitmap(gr);
gr.Dispose();
gr = null;
}
public void PaintShape(Graphics g)
{
//scenario: the graphics object has a scaling factor of .50
if (bmpMove != null)
//produces no difference from the DrawImage() method
graphics.DrawImageUnscaled(bmpMove, pntBmpPos);
else
//paint the shape.. (code excluded)
}
My code this week has no errors. But it's Monday morning and I haven't got out of bed.
|
|
|
|
|
Hi Richard,
let me say for starters I never used DrawImageUnscaled; however this is how I understand the Graphics class: there are two different reasons why DrawImage may scale an image:
1. the transformation stuff (properties and methods relating to Matrix and ScaleTransform);
2. the parameters specifying a destination rectangle, and either the entire source image or a specified rectangular part of it.
AFAIK DrawImageUnscaled removes the second reason by ignoring the width and height if you specify one,
but I don't expect it to ignore the first reason. I expect the ScaleTransform/Matrix to rescale everything, like a Xerox copier could, supporting things such as putting several pages of a document on a single sheet of print.
Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:39 AM
|
|
|
|
|
Hi everyone,
Any idea why might the key_down_even of a form may be inactive?? I'm running a simple form with a tabControl and even when I set the focus back to the form, it doesnt capture the key strokes while it works fine on an empty form!
Please help
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Does the focus remain on the tab control?
My code this week has no errors. But it's Monday morning and I haven't got out of bed.
|
|
|
|
|
Ok, I found it, I just had to set the this.KeyPreview to true!
Thanks guys!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi guys, I have many controls inside a listbox and am displaying the listbox on the left side of the form. If a control is selected a corrospoding control is displayed on the right side of the form.
Simple.
The selected control from the listbox (right sided) control can be zoom like (75%,50%,25%). So for instance, if I zoom, 75% all the elements
inside the control are zoom as well (reflecting the 75%).
Hope it makes sense. Alright...
But how can I display controls inside the listbox not to be 75%. Because the right side pane hold a refece of the selected control from the listbox. so if right side Control is zoom to 75% all its elements reflect to 75% like(Size/Location). All controls inside the listbox should be zoom to 100%
Form.cs
|---------------------------------------------------
| |
| SplitContainer |
| |--------------------------------------------- |
| | | zoom(75%,50%,25%) | |
| | | |----------------------- | |
| | control1 | | | | |
| | | | | | |
| |-----------| | | | |
| | | | Control 2 | | |
| | control2 | | is being displayed | | |
| | | | and it is selected | | |
| |-----------| | | | |
| | | | | | |
| | control3 | | | | |
| | | ----------------------- | |
| --------------------------------------------- |
| |
|--------------------------------------------------
The way I solved this issue is that during the OnDrawItem event of the listbox I am making a copy of an individual
elements, resetting their Size and Location to the
zoom factor of 100% and then readding to new control.
I would apprecaite for your kind suggestions
Thanks
modified on Wednesday, February 25, 2009 1:57 PM
|
|
|
|
|
If you're applying the scaling to the form where all controls reside then it is obviously going to scale everything, including your listbox. A better option would be to make your controls on the "right-side" to be UserControls. Scaling can be applied to it alone without affecting any other control.
Hope this helps,
Richard
My code this week has no errors. But it's Monday morning and I haven't got out of bed.
|
|
|
|
|
Would splitting your zoom/nonzoomed controls into separate panels and only applying the zoom to the former's panel work?
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Good idea. I personally like user controls because it allows you create your layout in design mode. Either method should work.
There cannot be a crisis today; my schedule is already full.
|
|
|
|
|
How is creating a user control in design mode different from dragging controls onto a panel is design mode if you're only going to use the assemblage once? Obviously the control is better for something being used in many places.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Thanks guys for replying back. I have made some changes to my orginal post.
Basically, you guys are suggesting me to apply the zoom to the right side control only.
The problem is that the right side Control that is being displayed is a referenced object and if a change is made to it reflects back to the corrosponding control that is shown in the listbox.
I am carring on my previous example, let's say from the listbox control2 is selected has an element (a button with Size 100,100 and Location 0,200) and that is also shown. If zoom is applied to 75% the Size and Location are now reflected to 75%. So the control2 elements on the right side, its size becomes (75,75) and location (0,75).
Since we orignally had a reference to the Control2 object if a change is made through the right side it also reflect back in the listbox.
modified on Wednesday, February 25, 2009 2:11 PM
|
|
|
|
|
Hi,
I have a button on my webform that I need to access from my user control code behind, not the page on which the button resides, but I'm not sure how I find it.
I've thought it would be something like this, but this doesnt work:
Button button=(Button)FindControl("btn");
Thanks!
|
|
|
|
|
Have you tried Page.FindControl("..") ?
|
|
|
|
|
Yes have tried that:
Button button=(Button)Page.FindControl("btn");
The Page will return the correct page, but nothing gets assigned to button, so I am getting nullReferenceException error.
|
|
|
|
|
When I drill down into the error, into the Page property, the Page directs itself correctly and the button is listed under the [ASP.Page_aspx] base but there is no FindControl option listed. Any ideas as to why this is?
|
|
|
|
|
I hope that Button is not in the ContentPlaceHolder and you are not using MasterPages.
Try
Page.Parent.FindControl()
If that button is inside the ContentPlaceHolder then stack trace and find the actual value for that button. something like xxxxxctl001_btn.
then first find the content place holder (or any other container)
using
container c = Page.FindControl('container') and then c.FindControl('btn')
PS: container means any container i.e. Panel / ContentPlaceHolder etc...
|
|
|
|
|