|
You are calling the ErrorCheck method with a variable which has not been initialised, but more importantly is never used. Try changing your code to:
public partial class MainWindow : Window
{
bool errorState = false;
private bool ErrorCheck()
{
return isError;
}
private void btnSave_Click(object sender, RoutedEventArgs e)
{
errorState = ErrorCheck();
if (errorState)
{
}
else
{
}
Also your tests look to be the wrong way round. The ErrorCheck method returns true if the information in the text boxes is not valid. But the btnSave_Click method calls the return value ISOK . But if ISOK is true then that indicates an error, which means you have to go back and try again. You could also use the String.IsNullOrEmpty Method[^] on your textboxes to check if they contain any valid data.
|
|
|
|
|
Thank you Richard, Such a stupid mistake to make.
Now the compiled file executes properly, But I am pretty sure that it do not retrieve anything from the Errorcheck method.
I coded this in the savePDF button (and making your changes from above). It do not matter if i leave a textbox empty, the program will always display the "All COOL" message.
Is there somthing wrong with the way errorstate = ErrorCheck(); tries to retrieve the bool false or true from the method?
private void btnSave_Click(object sender, RoutedEventArgs e)
{
errorstate = ErrorCheck();
if (errorstate)
{
MessageBox.Show("ERROR I WILL SHOW YOU THIS MESSAGE BEFORE REAL CODE");
}
else
{
MessageBox.Show("ALL COOL");
}
|
|
|
|
|
No, nothing wrong with that, the error is in the ErrorCheck method, which I missed before. Your tests will set isError to true if any of the text boxes are not valid. However, the last test is a problem, if txtboxEmail contains some text then it goes to the else clause and sets isError to false , thus negating any previous test which set it to true . You should either change it to use else if clauses like this:
bool isError;
if(txtboxName.Text.Trim().Length == 0)
{
MessageBox.Show("Anna nimesi!", "Seis!", MessageBoxButton.OK, MessageBoxImage.Error);
isError = true;
}
else if (txtboxBday.Text.Trim().Length == 0)
{
MessageBox.Show("Anna Syntymäaikasi", "Seis!", MessageBoxButton.OK, MessageBoxImage.Error);
isError = true;
}
else if (txtboxPhone.Text.Trim().Length == 0)
{
MessageBox.Show("Anna Puhelinnumerosi!", "Seis!", MessageBoxButton.OK, MessageBoxImage.Error);
isError = true;
}
else if (txtboxAddress.Text.Trim().Length == 0)
{
MessageBox.Show("Anna Osoitteesi", "Seis!", MessageBoxButton.OK, MessageBoxImage.Error);
isError = true;
}
else if (txtboxEmail.Text.Trim().Length == 0)
{
MessageBox.Show("Anna S-postisi!", "Seis!", MessageBoxButton.OK, MessageBoxImage.Error);
isError = true;
}
else
{
isError = false;
}
return isError;
, or set isError to false at the beginning of the method, and remove the final else clause.
|
|
|
|
|
Thank you.
I Got it working!
Thank you a million times, I will look more into methods and if statments on my own now.
Clearly some crucial pieces of knowleadge lacking in those departments
I am just very bad at following tutorials, I like trying achieve somthing usefull and tackle problems as they come.
Have a great day!
|
|
|
|
|
|
Can someone provide me the step by step implementation of how to use pocketsphinx in a C# application(Console or Windows form).
|
|
|
|
|
|
YES i did but it has explanation about C++ not C#, And Sorry i am not an expert in programming.
|
|
|
|
|
I told you yesterday that it is unlikely anyone here would have the free time to provide you with this. If you want to implement some software then you need to go and learn it for yourself.
|
|
|
|
|
Google gave me this as the first link[^]
There are many links that google show for c# pocketsphinx[^]
I hope that this can get you started on your project.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
You're basically asking for someone to teach you how to write interop code, or to write the interop for you. Why don't you look at the C# port of this here[^]? See if that's any more help for you.
|
|
|
|
|
Hi, everyone i am beginner in asp.net(c#) and want to know what thing we should know for getting job in this field now day, please help me we want job.
|
|
|
|
|
|
As Richard has said, we can't really help you that much.
And a lot of it will depend on local conditions.
It might be worth asking othesr in the same country - at least they know what is "hot" locally and what helped them to get a job.
We do have a General Indian Topics[^] forum, which would at least address other Indian nationals directly?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
The first record is displaying, I only wanted to show rows with more 1.25 and less .075.
Doe John 176.0000 1.0000 165.0000 0.9400 04/01/2015
This first row is the culprit.
What is wrong with my code?
protected void gvCATW_RowDataBound(object sender, GridViewRowEventArgs e)
{
for (int i = 0; i <= gvCATW.Rows.Count - 1; i++)
{
Label last = (Label)gvCATW.Rows[i].FindControl("lblActualFTE");
if (Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ActualFTE")) > 1.25M)
{
e.Row.ForeColor = System.Drawing.Color.Red;
}
else if (Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ActualFTE")) < .75M)
{
e.Row.ForeColor = System.Drawing.Color.Orange;
}
else
{
e.Row.Visible = false;
}
|
|
|
|
|
If you are using a DataTable, you might want to try setting the RowFilter property of the DefaultView.
|
|
|
|
|
Can you Please explain what that means? I'm now getting all of the rows I want but the very first record is not Yellow which is less than .075. All o the remaining rows are correct.
|
|
|
|
|
If that row is not required, then filter it while getting the data from your data source. So you can avoid all these at code level in C#.
|
|
|
|
|
I changed my sql but it now showing the first row which is < .075 as black not yellow. The rest of the rows are correct.
Bair James S 176.0000 1.0000 128.0000 0.7300 04/01/2015
|
|
|
|
|
Norris Chappell wrote: Doe John 176.0000 1.0000 165.0000 0.9400 04/01/2015 Which one's ActualFTE among these, and what's with the Label lst ?
You have just been Sharapova'd.
|
|
|
|
|
Sorry for the delayed reply, I don't check the inbox linked with this account too often. I think you might have resolved this issue already, but -
If the ActualFTE is 0.7300, as you have mentioned in the email, the row should have been highlighted in Orange color? If that's "not" the case, are you sure you still have the else if condition < .75M in place and it's really not < .075 by any chance (from what you have mentioned in your original post)?
Also, can you check what you are getting from Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ActualFTE")) using immediate window/quick watch and a debug point?
You have just been Sharapova'd.
|
|
|
|
|
protected void gvCATW_RowDataBound(object sender, GridViewRowEventArgs e)
{
for (int i = 0; i <= gvCATW.Rows.Count - 1; i++)
{
if (Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ActualFTE")) < .75M)
{
e.Row.ForeColor = System.Drawing.Color.Orange;
}
else if (Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ActualFTE")) > 1.25M)
{
e.Row.ForeColor = System.Drawing.Color.Red;
}
The conditions are working properly. It is the fact that the very first record is not changing to Orange even though it is < .075
|
|
|
|
|
There's no need to loop over all the rows - the RowDataBound event will fire for each row.
Try changing your code to:
protected void gvCATW_RowDataBound(object sender, GridViewRowEventArgs e)
{
decimal actualFTE = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ActualFTE"));
if (actualFTE < .75M)
{
e.Row.ForeColor = System.Drawing.Color.Orange;
}
else if (actualFTE > 1.25M)
{
e.Row.ForeColor = System.Drawing.Color.Red;
}
}
If it still doesn't work, check the HTML source to see what's rendered for the first row. You might want to add the ActualFTE to the row as a data- attribute, to make sure the value is what you're expecting:
decimal actualFTE = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ActualFTE"));
e.Row.Attributes.Add("data-actual-fte", actualFTE.ToString());
...
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks. That worked. Is now doing what they want.
|
|
|
|
|
I'm working on a WPF/C# app.
Background
First, all my user controls in WPF inherit from a base control:
public interface IControl
{
void Load();
void Cleanup();
}
and
public abstract class _UserControlBase : UserControl, INotifyPropertyChanged, IControl
{
public new abstract bool IsEnabled { get; set; }
public abstract void Load();
public abstract void Cleanup();
public event PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Next, I created a control called ConnectionView which inherits from both _UserControlBase and its own interface:
public interface IConnectionView
{
event EventHandler<ConnectedToDeviceEventArgs> ConnectedToDevice;
}
and
public partial class ConnectionView : _UserControlBase, IConnectionView
{
#region Event Declations
public event EventHandler<ConnectedToDeviceEventArgs> ConnectedToDevice;
#endregion
.
.
.
}
Finally, in my MainWindowView I have a content presenter bound to the property CurrentView and it's loaded like this:
public class MainWindowViewModel : _ViewModelBase
{
private IControl _CurrentView;
public IControl CurrentView
{
get { return _CurrentView; }
set
{
if (_CurrentView != value)
{
_CurrentView = value;
RaisePropertyChanged("CurrentView");
}
}
}
public MainWindowViewModel()
{
loadView(AppMode.Discover);
}
private void loadView(AppMode mode)
{
if (CurrentView != null)
{
CurrentView.Cleanup();
}
switch (mode)
{
case AppMode.Connected:
break;
case AppMode.Discover:
CurrentView = new ConnectionView();
CurrentView.Load();
break;
}
}
}
The Problem
Since the CurrentView is based off _UserControlBase, the ConnectedToDevice event isn't available.
How do I subscribe to the ConnectionView's ConnectedToDevice event in the main window?
If it's not broken, fix it until it is
|
|
|
|