|
thanks for ur replay and i understand u but what i miss is how to do it could u please make an example or to recommend any tutorial for me please??
|
|
|
|
|
Search google for a tutorial as JSchell suggested.
Select FieldList...
From SomeTable
Where datefield between @FromDate and @ToDate
That is a query to get data for a report, assuming you are using SQL Server! You have not even to;d us the database you are using, nor the reporting tool you have chosen.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Following in google gives examples of reports
C# example report
|
|
|
|
|
Incorrect syntax near the keyword 'update'. cmd1.CommandText = "select update"
|
|
|
|
|
"select update" is not a valid SQL-statement. You should look for some SQL-tutorial[^].
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
|
Hi,
I wanted to know how can I encrypt any number to a 6 unique alphanumeric digits using C#?
Thanks
Jassim[^]
Technology News @ www.JassimRahma.com
|
|
|
|
|
ANY number? Down to a UNIQUE 6 digit code?
Think about that. How are you going to represent any number UNIQUELY in a space that, by definition, can only hold 1,000,000 unique values?
By the way, that's not encryption. That's a hash.
You might want to go into what you're really trying to do with this.
|
|
|
|
|
Though Dave overlooked that you were talking about an alphanumeric representation, this doesn't change the fact that you can't represent any number in 6 digits UNIQUE alphanumeric.
1.) 2'175'005'370 would be the highest number you can represent that way ("ZYXWVU").
2.) Because the digits should be unique, not all numbers in that range can be represented. The lowest number that can be represented is 1'776'965 (= "012345") and there will be several "gaps" in between.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
modified 22-May-15 21:25pm.
|
|
|
|
|
Just to add to what the others say: Encryption implies that Decryption is possible - but what you are talking about is Basically Hashing (as Dave mentioned) which cannot be reversed, cannot be "de-hashed". Once you have generated your unique code, you can't get the original input back. Encryption does not have a fixed length output, only hashing does.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
modified 23-May-15 6:23am.
|
|
|
|
|
Getting an error: input string was not in a correct format
asp:
onrowdatabound="highlightrow"
protected void highlightrow(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int ActualFTE=Convert.ToInt32(e.Row.Cells[5].Text);
if (ActualFTE > 1.25)
{
e.Row.BackColor = Color.Red;
}
}
}
modified 22-May-15 14:31pm.
|
|
|
|
|
The error message says it clearly.
You are trying to covert a decimal to int.
Change your stament like below and try.
decimal ActualFTE=Convert.ToDecimal(e.Row.Cells[5].Text);
if (ActualFTE > 1.25)
|
|
|
|
|
|
Still getting the same error.
|
|
|
|
|
Can you post what value is coming in
e.Row.Cells[5].Text It will give a better idea on what we are dealing with.
|
|
|
|
|
|
decimal ActualFTE=Convert.ToDecimal(e.Row.Cells[5].Text);
if (ActualFTE > 1.25)
In the above code check whether e.Row.Cells[5].Text returns data that can be converted to decimal. Or add ToString() at the end and see if it helps.
decimal ActualFTE=Convert.ToDecimal(e.Row.Cells[5].Text.ToString());
|
|
|
|
|
Same error: Input string was not in a correct format.
|
|
|
|
|
Just to make sure everything is fine, try hardcoding the value and see if you still get the error.
decimal ActualFTE=Convert.ToDecimal("0.9500");
If this works without exception, then you can be sure, the problem is with the expression e.Row.Cells[5].Text . This expression you use should return some string (like your value 0.9500) that can be converted to decimal for the conversion to work without exception.
|
|
|
|
|
okay it didn't error this time but nothing changed.
|
|
|
|
|
May be the value ActualFTE is not greater than 1.25, as per your condition.
if (ActualFTE > 1.25)
{
e.Row.BackColor = Color.Red;
}
So the color will not be changed.
|
|
|
|
|
That is true for most of the 251 rows. I only see a couple that are over 1.25. So I should take out that code?
|
|
|
|
|
Do you think I should post all of my code to see if I have something missing?
|
|
|
|
|
When you want the row to be colored? Change the if condition based on that. It should work.
|
|
|
|
|
Not the whole row only that field. ActualFTE.
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;
using System.Drawing;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace StaffingWebParts.CatwComment
{
public partial class CatwCommentUserControl : UserControl
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLStaffingConn"].ConnectionString);
SqlCommand cmd = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
lblMsg.Text = "";
if (!Page.IsPostBack)
{
BindSubjectData();
}
}
protected void highlightrow(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
decimal ActualFTE = Convert.ToDecimal(e.Row.Cells[5].Text.ToString());
if (ActualFTE > 1.2500M)
{
e.Row.BackColor = Color.Red;
}
}
}
protected void BindSubjectData()
{
using (SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLStaffingConn"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = ("select a.id, b.StaffTrackingID, a.ResourceName, b. EstimateHours, EstimateFTE, b.ActualHours, b.ActualFTE,b.Comment, b.CommentBy, b.Period from StaffTracking a, StaffTrackingFTEData b where a.id = b.StaffTrackingid order by ResourceName");
cmd.Connection = sqlCon;
sqlCon.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
gvCATW.DataSource = dt;
gvCATW.DataBind();
}
else
{
DataRow dr = dt.NewRow();
dt.Rows.Add(dr);
gvCATW.DataSource = dt;
gvCATW.DataBind();
gvCATW.Rows[0].Visible = false;
}
sqlCon.Close();
}
}
}
protected void gvCATW_RowEditing(object sender, GridViewEditEventArgs e)
{
gvCATW.EditIndex = e.NewEditIndex;
BindSubjectData();
}
protected void gvCATW_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvCATW.EditIndex = -1;
BindSubjectData();
}
protected void gvCATW_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
bool IsUpdated = false;
int StaffTrackingID =
Convert.ToInt32(gvCATW.DataKeys[e.RowIndex].Value.ToString());
TextBox ResourceName =
(TextBox)gvCATW.Rows[e.RowIndex].FindControl("txtResourceName");
TextBox EstimateHours = (TextBox)gvCATW.Rows[e.RowIndex].FindControl("txtEstimateHours");
TextBox EstimateFTE = (TextBox)gvCATW.Rows[e.RowIndex].FindControl("txtEstimateFTE");
TextBox ActualHours = (TextBox)gvCATW.Rows[e.RowIndex].FindControl("txtActualHours");
TextBox ActualFTE = (TextBox)gvCATW.Rows[e.RowIndex].FindControl("txtActualFTE");
TextBox Comment = (TextBox)gvCATW.Rows[e.RowIndex].FindControl("txtComment");
TextBox CommentBy = (TextBox)gvCATW.Rows[e.RowIndex].FindControl("txtCommentBy");
TextBox Period = (TextBox)gvCATW.Rows[e.RowIndex].FindControl("txtPeriod");
using (SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLStaffingConn"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = @"UPDATE StaffTrackingFTEData SET StaffTrackingID=@StaffTrackingID, EstimateHours=@EstimateHours, EstimateFTE=@EstimateFTE, ActualHours=@ActualHours, ActualFTE=@ActualFTE,Comment=@Comment, CommentBy=@CommentBy, period=@Period WHERE StaffTrackingID=@StaffTrackingID";
cmd.Parameters.AddWithValue("@StaffTrackingId", StaffTrackingID);
cmd.Parameters.AddWithValue("@EstimateHours", EstimateHours.Text);
cmd.Parameters.AddWithValue("@EstimateFTE", EstimateFTE.Text);
cmd.Parameters.AddWithValue("@ActualHours", ActualHours.Text);
cmd.Parameters.AddWithValue("@ActualFTE", ActualFTE.Text);
cmd.Parameters.AddWithValue("@Comment", Comment.Text);
cmd.Parameters.AddWithValue("@CommentBy", CommentBy.Text);
cmd.Parameters.AddWithValue("@Period", Period.Text);
cmd.Connection = sqlCon;
sqlCon.Open();
IsUpdated = cmd.ExecuteNonQuery() > 0;
sqlCon.Close();
}
}
if (IsUpdated)
{
lblMsg.Text = "'" + ResourceName.Text + "' CATW Comment updated successfully!";
lblMsg.ForeColor = System.Drawing.Color.Green;
}
else
{
lblMsg.Text = "Error while updating '" + ResourceName.Text + "' subject details";
lblMsg.ForeColor = System.Drawing.Color.Red;
}
gvCATW.EditIndex = -1;
BindSubjectData();
}
}
}
|
|
|
|