|
Good idea, thank you I will let you know how it goes
|
|
|
|
|
I have a WPF app and I'm attempting to switch from my MSSQL dev database to a DB2 database the app will actually run against.
I have the DB2 drivers installed on my computer and I can connect to the server via WinSQL.
I can't figure out how to set up the provider in my app.config to work though.
I'd appreciate some info on the steps required or exactly what I need to configure to get this thing moving.
|
|
|
|
|
|
So, I recently started working with c# without prior coding backround. I am now trying to write a program wich compiles a pdf of different textboxes that the user provides.
I have managed to code the program to check if the boxes are empty, but I am having a hard time trying to make a "ErrorState" if the box is empty.
So here is how it is supposed to go:
User enters text to fields -> Presses btnSave -> Program calls for a method that checks if textboxes are empty, If empty then put program to a "errorstate" and don't call for the next method that saves the pdf. Reset "errorstate" next time btnSave is pressed and check the textboxes again, if all is ok then continue with program.
My problem is getting the "errorstate" out of the method, I get a error: Use of unassigned local variable errorState with my current code. What am I missing, and how wrong Am I using methods?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Win32;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
using System.Text.RegularExpressions;
namespace CV_maker
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private bool ErrorCheck(bool errorState)
{
bool isError;
if(txtboxName.Text.Trim().Length == 0)
{ MessageBox.Show("Anna nimesi!", "Seis!", MessageBoxButton.OK, MessageBoxImage.Error);
isError = true;
}
if (txtboxBday.Text.Trim().Length == 0)
{ MessageBox.Show("Anna Syntymäaikasi", "Seis!", MessageBoxButton.OK, MessageBoxImage.Error);
isError = true;
}
if (txtboxPhone.Text.Trim().Length == 0)
{ MessageBox.Show("Anna Puhelinnumerosi!", "Seis!", MessageBoxButton.OK, MessageBoxImage.Error);
isError = true;
}
if (txtboxAddress.Text.Trim().Length == 0)
{ MessageBox.Show("Anna Osoitteesi", "Seis!", MessageBoxButton.OK, MessageBoxImage.Error);
isError = true;
}
if (txtboxEmail.Text.Trim().Length == 0)
{ MessageBox.Show("Anna S-postisi!", "Seis!", MessageBoxButton.OK, MessageBoxImage.Error);
isError = true;
}
else
{
isError = false;
}
return isError;
}
private void btnAddimage_Click(object sender, RoutedEventArgs e)
{
addImage();
}
private void btnSave_Click(object sender, RoutedEventArgs e)
{
bool ISOK;
bool errorState;
ISOK = ErrorCheck(errorState);
if (ISOK == true)
{
MessageBox.Show("ERROR I WILL SHOW YOU THIS MESSAGE BEFORE REAL CODE");
}
}
void addImage()
{
OpenFileDialog op = new OpenFileDialog();
op.Title = "Select a picture";
op.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" +
"JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" +
"Portable Network Graphic (*.png)|*.png";
if (op.ShowDialog() == true)
{
PictureOmakuva.Source = new BitmapImage(new Uri(op.FileName));
}
return;
}
void savepdf()
{
string OwnName;
OwnName = txtboxName.Text;
FileStream fs = new FileStream(OwnName + " Curriculum Vitae.pdf", FileMode.Create, FileAccess.Write, FileShare.None);
Document doc = new Document();
PdfWriter writer = PdfWriter.GetInstance(doc, fs);
doc.Open();
doc.Add(new iTextSharp.text.Paragraph("Tämä on testi"));
doc.Close();
}
}
}
|
|
|
|
|
That's like starting to translate a text, without knowing the language you are translating to; it is possible, but rather frustrating to do.
I'd recommend to learn at least the basics before attempting a real task.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
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.
|
|
|
|