|
Member 10750212 wrote: send a code to me
This is not a write an application to order service. If you want this functionality then you need to at least attempt to write it yourself. No one here is going to write the whole thing for you.
|
|
|
|
|
Hi ,
I need to change culture mainly between two languages ; italian and English using the Combobox in WPF MVVM.
I tried to databind the ViewModel with my Mainview but I didn't succeed.
I will be so thankful if someone could help.
Here is my Combobox declaration in xaml :
<ComboBox IsEditable="True" Text="Language" HorizontalAlignment="Right" VerticalAlignment="Top" Width="95" Margin="34,21,34,0" ItemsSource="{Binding Languages}" SelectedItem="{Binding SelectedLanguage, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Foreground="#FF434C64" removed="Green" Height="24.96" />
Here is View Model definition :
public void ChangeLanguage()
{
if (SelectedLanguage == "en")
{
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en");
}
else
if (SelectedLanguage == "it-IT")
{
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("it-IT");
}
}
Here the declaration within the construcor of my View Model
public ViewModel()
{
LoadData();
ChangeLanguage();
Login = new DelegateCommand(this.Logging, delegate()
{
return (!String.IsNullOrEmpty(Username) && !String.IsNullOrEmpty(Password) && !String.IsNullOrEmpty(Email));
});
Register = new DelegateCommand(this.Registering, delegate()
{
return (!String.IsNullOrEmpty(Username) && !String.IsNullOrEmpty(Password) && !String.IsNullOrEmpty(Email));
});
|
|
|
|
|
You have already posted this question[^] in the WPF forum, and again in QA[^].
DO NOT post the same question in multiple places across the site.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
How can I show particular user information in a page from database using c# AND SQL sErvr 2005 in vs 2008
|
|
|
|
|
A lot of that is going to depend on how you handle membership, and identify users.
But, the most basic way to do this is to use the Session to store the user info - his username perhaps.
Store teh username when he logs in:
Session["UserName"] = myUserName;
Then, you can display the username just by including it in your HTML:
Welcome <%=Session["UserName"]%>
Or, you can set it into a label in your C#:
Label1.Text = string.Format("Welcome {0}!", Session["UserName"]);
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
|
|
That is a typical homework question! Whose job is it to do your homework? How will you actually learn if you never write a line of code? And: your teacher might find out that you cheated...
|
|
|
|
|
Hi,
I have the simple code:
// calibrate 4 mA
double delta = 4.0 - multimeterValue; // double multimeterValue
delta = delta / 0.005; // output 5 uA x step
ushort outValue_4mA += (ushort)delta;
But using double (or floating) numbers, how can I get the results:
delta = 4.0 - 4.02 = -0.02 ? I get delta = 0.01999998 !
delta /= 0005 = 4.0 ? I get delta = -3.99999619 !!
outValue_4mA += delta; if outValue = 2000, here I get 1997 instead of 1996 !!!
My old pocket calculator is better: 4.0 - 4.02 = -0.02 and -0.02 / 0.005 = 4.0 and outValue_4mA = 2000 - 4 = 1996.
What can I do to get the correct results?
thanks
|
|
|
|
|
Use the decimal type, not double .
|
|
|
|
|
With decimal type the result is always the same.
|
|
|
|
|
Yes, it does work, IF and ONLY IF the original operands are of Decimal type.
From the code you posted, that's not the case. Those values have to be converted to Decimals first.
|
|
|
|
|
The ability to write down things like 4.02 is highly misleading. There is no double with the precise value of 0.02 (or 4.02), because doubles are really an integer multiplied by a power of two, and there is no power of two 2n such that x*2n = 0.02 for some integer x.
So when you write 4.02, that's immediately where the trouble starts - you don't get 4.02 because it doesn't exist.
But anyway, you're working with measurements here, and these numbers are clearly correct to many decimals, at least until you cast it to ushort. Casting to ushort is problematic - it will round down, and so the "slightly less than 4" that was still correct (though it looks incorrect) ends up as 3, which is suddenly far from correct.
I'm not really sure what you should do about that. You could trying rounding, but that also those cases where the answer you get differs from the desired answer by 1.
|
|
|
|
|
ok Harold, I will solve the problem using rounding.
I understand very well what is the problem and that doesn't exist a double number with the precise value of 0.02, but I wanted to see if there was some other system easier in C# to work around the problem.
|
|
|
|
|
Ah ok, sorry, I guess I'm too used to people not knowing that sort of thing
|
|
|
|
|
I can not add record to my table as this code as written in :
http://www.homeandlearn.co.uk/csharp/csharp_s12p10.html[^]
The code as followed :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace _46_creating_databse_01_sql_express_02
{
public partial class Form1 : Form
{
public Form1() { InitializeComponent(); }
DatabaseConnection objConnect;
string conString;
DataSet ds;
DataRow dRow;
int MaxRows;
int inc = 0;
private void Form1_Load_1(object sender, EventArgs e)
{
try
{
objConnect = new DatabaseConnection();
conString = Properties.Settings.Default.employeesConnectionString;
objConnect.connection_string = conString;
objConnect.Sql = Properties.Settings.Default.sql;
ds = objConnect.GetConnection;
MaxRows = ds.Tables[0].Rows.Count;
NavigateRecords();
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
private void NavigateRecords()
{
dRow = ds.Tables[0].Rows[inc];
txtFirstName.Text = dRow.ItemArray.GetValue(1).ToString();
txtSurname.Text = dRow.ItemArray.GetValue(2).ToString();
txtJobTitle.Text = dRow.ItemArray.GetValue(3).ToString();
txtDepartment.Text = dRow.ItemArray.GetValue(4).ToString();
labelUpdate();
}
private void labelUpdate()
{
label6.Text = "Record " + (inc + 1) + " of " + MaxRows;
}
private void button2_Click(object sender, EventArgs e)
{
if (inc != MaxRows - 1)
{
inc++;
NavigateRecords();
}
else
{
MessageBox.Show("No More Rows");
}
}
private void button3_Click(object sender, EventArgs e)
{
if (inc > 0)
{
inc--;
NavigateRecords();
}
else
{
MessageBox.Show("first Record");
}
}
private void button4_Click(object sender, EventArgs e)
{
if (inc != 0)
{
inc = 0;
NavigateRecords();
}
}
private void button1_Click(object sender, EventArgs e)
{
if (inc != MaxRows - 1)
{
inc = MaxRows - 1;
NavigateRecords();
}
}
private void button6_Click(object sender, EventArgs e)
{
txtFirstName.Clear();
txtSurname.Clear();
txtJobTitle.Clear();
txtDepartment.Clear();
btnAddNew.Enabled = false;
btnSave.Enabled = true;
btnCancel.Enabled = true;
}
private void btnCancel_Click(object sender, EventArgs e)
{
NavigateRecords();
btnCancel.Enabled = false;
btnSave.Enabled = false;
btnAddNew.Enabled = true;
}
private void button7_Click(object sender, EventArgs e)
{
DataRow row = ds.Tables[0].NewRow();
row[1] = txtFirstName.Text;
row[2] = txtSurname.Text;
row[3] = txtJobTitle.Text;
row[4] = txtDepartment.Text;
ds.Tables[0].Rows.Add(row);
try
{
objConnect.UpdateDatabase(ds);
MaxRows = MaxRows + 1;
inc = MaxRows - 1;
MessageBox.Show("database updated");
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
btnCancel.Enabled = false;
btnSave.Enabled = false;
btnAddNew.Enabled = true;
}
private void button9_Click(object sender, EventArgs e)
{
DataRow row = ds.Tables[0].Rows[inc];
row[1] = txtFirstName.Text;
row[2] = txtSurname.Text;
row[3] = txtJobTitle.Text;
row[4] = txtDepartment.Text;
try
{
objConnect.UpdateDatabase(ds);
MessageBox.Show("Record Updated");
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
}
}
|
|
|
|
|
You have already posted this question[^].
DO NOT post the same question multiple times.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Is there a way to see why my records are not added the table ?
|
|
|
|
|
How to reuse event
I am creating one c# project. In this project I have one mdi form and many child forms.
All the child forms contains one panel named as panel1.
Now when child form opens i use the following code in all child form
all child forms' load event contains the following line.
this.WindowState = FormWindowState.Maximized;
and all child forms' resize event contains the following line.
panel1.Left = (this.ClientSize.Width - panel1.Width) / 2;
panel1.Top = (this.ClientSize.Height - panel1.Height) / 2;
so my question is if possible that the above code i write only once so i donot write this code in all the child forms load and resize event.
|
|
|
|
|
Create a child form which contains only that code, and derive the other forms from that instead of Form.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
The first thing is why are you using MDI? It's an outdated concept and from the rest of your description, you're not making an application type that MDI was originally designed for.
What you're looking at doing is pretty easily done. Create a BaseForm class that inherits from Form (like your forms do now) and put the code that you want in it. Then all subsequent forms must inherit from this form. Done.
|
|
|
|
|
Dave Kreskowiak, you are telling me that MDI is outdated concept. so I just want to know which concept is used for developing software in c#. I am new in c#. So don't know what are the concepts for the software in current market ? so i am asking you that which concept is used instead of MDI form.
Actually i am beginner so if you have some time so please baseform class code and my form that calls that baseform class code give me.
|
|
|
|
|
MDI stands for "Multiple Document Interface". It was designed to support multiple instances of a document editor class, such as a Notepad that can edit multiple files at the same time.
If you think you need MDI to show multiple windows in an application, you're very mistaken.
You're a beginner? Don't even start thinking about "the market". Learn the basics first.
|
|
|
|
|
Multiple Documents sounds to me like multiple browser windows in tabs within the same browser window. I don't get why that concept should be outdated.
Ciao,
luker
|
|
|
|
|
That's one very specific use, but the concept and design of MDI predates tabbed browsers by a significant number of years.
Tabbed browsers doesn't don't even use the concept nor you don't see applications using the MDI concept any more. Not even the most visible example of it is using it, Microsoft Office.
MDI doesn't support "tearing off" tabs. What you see as separate tabs in a browser is actually separate processes, in IE anyway. That's very different from how MDI works.
|
|
|
|