Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to use web browser control to automate login to a site Pin
Christian Graus16-Jun-21 11:24
protectorChristian Graus16-Jun-21 11:24 
GeneralRe: How to use web browser control to automate login to a site Pin
Mou_kol16-Jun-21 21:05
Mou_kol16-Jun-21 21:05 
AnswerRe: How to use web browser control to automate login to a site Pin
Richard Deeming20-Jun-21 23:08
mveRichard Deeming20-Jun-21 23:08 
GeneralRe: How to use web browser control to automate login to a site Pin
Mou_kol21-Jun-21 4:19
Mou_kol21-Jun-21 4:19 
Questionimage processing Pin
elham mohammed16-Jun-21 5:53
elham mohammed16-Jun-21 5:53 
AnswerRe: image processing Pin
Dave Kreskowiak16-Jun-21 5:54
mveDave Kreskowiak16-Jun-21 5:54 
AnswerRe: image processing Pin
OriginalGriff16-Jun-21 9:34
mveOriginalGriff16-Jun-21 9:34 
QuestionVisual Basic Commission Switch Statement + Calc Pin
Member 1524886715-Jun-21 11:46
Member 1524886715-Jun-21 11:46 
Hey,

I'm new to C# and coding in general. I've done some reading and online "hands-on" tutorials but I'm truly stuck here. Can someone please help me out and review the code I have written? I'm willing to put the time in to learn, I just don't know where to go from here.

I'm having a problem with my switch statement that involves different levels of commission rates, as well as getting the calculation to work. Also, on my last line it is giving me an error -- saying that "dblCalculateCommission" is an unassigned variable. I haven't had this problem on similar exercises. Appreciate any help, ready to pull my hair out!

private void btnCalculateCommission_Click(object sender, EventArgs e)
{
// declare variables to be used in the calculation
double dblSalesPersonLevel;
double dblAmountSold;
double dblCalculateCommission;

// convert the values in the text boxes to numeric and place into variables
dblSalesPersonLevel = Convert.ToDouble(txtSalesPersonLevel.Text);
dblAmountSold = Convert.ToDouble(txtAmountSold.Text);

// check the sales level is between 1 and 4, if it is outside of these parameters display an error message
if (dblSalesPersonLevel < 1)
{
MessageBox.Show("Sales level cannot be less than 1", "Input Error");
txtSalesPersonLevel.SelectAll();
txtSalesPersonLevel.Select();
}
else if (dblSalesPersonLevel > 4)
{
MessageBox.Show("Sales level cannot be greater that 4", "Input Error");
txtSalesPersonLevel.SelectAll();
txtSalesPersonLevel.Select();
}


// Calculate commissions based on sales person level

{
string strSalesPersonLevel;
strSalesPersonLevel = txtSalesPersonLevel.Text;

switch (strSalesPersonLevel)
{
case "1":
{
dblCalculateCommission = 500 + (dblAmountSold * 0.02);
break;
}
case "2":
{
dblCalculateCommission = 750 + (dblAmountSold * 0.03);
break;
}
case "3":
{
dblCalculateCommission = 1000 + (dblAmountSold * 0.04);
break;
}
case "4":
{
dblCalculateCommission = 1250 + (dblAmountSold * 0.05);
break;
}

}
// Convert commission into a string and place into a label with currency
//formatting
lblCalculateCommission.Text = dblCalculateCommission.ToString("C2");

AnswerRe: Visual Basic Commission Switch Statement + Calc Pin
Dave Kreskowiak15-Jun-21 17:44
mveDave Kreskowiak15-Jun-21 17:44 
AnswerRe: Visual Basic Commission Switch Statement + Calc Pin
Richard Deeming15-Jun-21 22:07
mveRichard Deeming15-Jun-21 22:07 
GeneralRe: Visual Basic Commission Switch Statement + Calc Pin
Member 1524886716-Jun-21 9:36
Member 1524886716-Jun-21 9:36 
QuestionGet serial number from local printers connected to workstation by USB Pin
SzakiII15-Jun-21 2:28
SzakiII15-Jun-21 2:28 
AnswerRe: Get serial number from local printers connected to workstation by USB Pin
Gerry Schmitz15-Jun-21 9:21
mveGerry Schmitz15-Jun-21 9:21 
AnswerRe: Get serial number from local printers connected to workstation by USB Pin
Randor 15-Jun-21 11:41
professional Randor 15-Jun-21 11:41 
GeneralRe: Get serial number from local printers connected to workstation by USB Pin
Gerry Schmitz15-Jun-21 13:13
mveGerry Schmitz15-Jun-21 13:13 
GeneralRe: Get serial number from local printers connected to workstation by USB Pin
Randor 15-Jun-21 14:06
professional Randor 15-Jun-21 14:06 
Questionhow to convert Character codes HTML to arabic using c# Pin
michael nabil14-Jun-21 8:30
michael nabil14-Jun-21 8:30 
AnswerRe: how to convert Character codes HTML to arabic using c# Pin
Richard Deeming14-Jun-21 22:02
mveRichard Deeming14-Jun-21 22:02 
GeneralRe: how to convert Character codes HTML to arabic using c# Pin
michael nabil15-Jun-21 3:00
michael nabil15-Jun-21 3:00 
GeneralRe: how to convert Character codes HTML to arabic using c# Pin
Richard Deeming15-Jun-21 3:26
mveRichard Deeming15-Jun-21 3:26 
AnswerRe: how to convert Character codes HTML to arabic using c# Pin
Gerry Schmitz15-Jun-21 6:14
mveGerry Schmitz15-Jun-21 6:14 
QuestionHow to add row headers to DataGridView? Pin
Alex Dunlop9-Jun-21 19:16
Alex Dunlop9-Jun-21 19:16 
AnswerRe: How to add row headers to DataGridView? Pin
OriginalGriff9-Jun-21 20:13
mveOriginalGriff9-Jun-21 20:13 
GeneralRe: How to add row headers to DataGridView? Pin
Alex Dunlop9-Jun-21 21:53
Alex Dunlop9-Jun-21 21:53 
GeneralRe: How to add row headers to DataGridView? Pin
OriginalGriff9-Jun-21 22:07
mveOriginalGriff9-Jun-21 22:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.