Click here to Skip to main content
15,896,063 members
Home / Discussions / C#
   

C#

 
QuestionRe: Multiple sliders or trackbars Pin
Maciej Los9-Feb-18 9:03
mveMaciej Los9-Feb-18 9:03 
AnswerRe: Multiple sliders or trackbars Pin
ZurdoDev9-Feb-18 9:10
professionalZurdoDev9-Feb-18 9:10 
AnswerRe: Multiple sliders or trackbars Pin
BillWoodruff10-Feb-18 23:23
professionalBillWoodruff10-Feb-18 23:23 
GeneralRe: Multiple sliders or trackbars Pin
Member 1367044211-Feb-18 12:59
Member 1367044211-Feb-18 12:59 
GeneralRe: Multiple sliders or trackbars Pin
BillWoodruff11-Feb-18 16:56
professionalBillWoodruff11-Feb-18 16:56 
GeneralRe: Multiple sliders or trackbars Pin
Member 1367028512-Feb-18 0:54
Member 1367028512-Feb-18 0:54 
QuestionHow to add a discrete transfer function in C# code? Pin
Member 136703089-Feb-18 5:21
Member 136703089-Feb-18 5:21 
AnswerRe: How to add a discrete transfer function in C# code? Pin
OriginalGriff9-Feb-18 5:27
mveOriginalGriff9-Feb-18 5:27 
Questiongetting same numbers when executing a random number generation method? Pin
auting828-Feb-18 6:47
auting828-Feb-18 6:47 
AnswerRe: getting same numbers when executing a random number generation method? Pin
Richard Deeming8-Feb-18 7:41
mveRichard Deeming8-Feb-18 7:41 
AnswerRe: getting same numbers when executing a random number generation method? Pin
OriginalGriff8-Feb-18 8:03
mveOriginalGriff8-Feb-18 8:03 
GeneralRe: getting same numbers when executing a random number generation method? Pin
Richard Deeming8-Feb-18 9:23
mveRichard Deeming8-Feb-18 9:23 
QuestionGridview C# Windows Application - Function in each cell column can automatically write words PASS and FAIL Pin
Deden Suansyah7-Feb-18 21:41
Deden Suansyah7-Feb-18 21:41 
AnswerRe: Gridview C# Windows Application - Function in each cell column can automatically write words PASS and FAIL Pin
Deden Suansyah7-Feb-18 21:49
Deden Suansyah7-Feb-18 21:49 
AnswerRe: Gridview C# Windows Application - Function in each cell column can automatically write words PASS and FAIL Pin
Richard MacCutchan7-Feb-18 22:13
mveRichard MacCutchan7-Feb-18 22:13 
GeneralRe: Gridview C# Windows Application - Function in each cell column can automatically write words PASS and FAIL Pin
Deden Suansyah7-Feb-18 23:04
Deden Suansyah7-Feb-18 23:04 
GeneralRe: Gridview C# Windows Application - Function in each cell column can automatically write words PASS and FAIL Pin
Richard MacCutchan7-Feb-18 23:13
mveRichard MacCutchan7-Feb-18 23:13 
AnswerRe: Gridview C# Windows Application - Function in each cell column can automatically write words PASS and FAIL Pin
Eddy Vluggen8-Feb-18 1:18
professionalEddy Vluggen8-Feb-18 1:18 
QuestionHow can I enumerate through OU's for nodes and add them to an existing treeview root node? Pin
turbosupramk37-Feb-18 10:35
turbosupramk37-Feb-18 10:35 
AnswerRe: How can I enumerate through OU's for nodes and add them to an existing treeview root node? Pin
BillWoodruff7-Feb-18 16:53
professionalBillWoodruff7-Feb-18 16:53 
Question(beginner question) help with code for a project Pin
Member 136645666-Feb-18 11:14
Member 136645666-Feb-18 11:14 
AnswerRe: (beginner question) help with code for a project Pin
Eddy Vluggen6-Feb-18 14:34
professionalEddy Vluggen6-Feb-18 14:34 
AnswerRe: (beginner question) help with code for a project Pin
Richard MacCutchan6-Feb-18 23:18
mveRichard MacCutchan6-Feb-18 23:18 
GeneralRe: (beginner question) help with code for a project Pin
Member 136645667-Feb-18 3:21
Member 136645667-Feb-18 3:21 
GeneralRe: (beginner question) help with code for a project Pin
Richard MacCutchan7-Feb-18 3:31
mveRichard MacCutchan7-Feb-18 3:31 
As it is working I suggest you keep it in a safe place . However as I suggested earlier you can simplify your if/else blocks by removing the common code and putting it at the end. Also, why set the discountrate to a hard coded value when you previously declared constants for the various rates? So it could be something like:
C#
    if (purchased >= 100)
    {
        discountrate = FIFTY_PCT_double;
    }
    //if the purchased units are greater than or equal to 50,               
    //but less than or equal to 99, put 40% in the first label
    else if (purchased >= 50)
    {
        discountrate = FORTY_PCT_double;

    }
    //if the purchased units are greater than or equal to 20, 
    //or less than or equal to 49, use 30% in the first label
    else if (purchased >= 20)
    {
        discountrate = THIRTY_PCT_double;

    }
    //if the purchased amount is less than or equal to 19 
    //or greater than or equal to 10, use %20 in the first label
    else if (purchased >= 10)
    {
        discountrate = TWENTY_PCT_double;
    }
    //if the purchased amount is between 0 and 10 or equal, the discount is 0%
    else
    {
        discountrate = ZERO_PCT_double;

    }
    saved = (purchased * PACKAGE_COST_double) * discountrate;
    retail = purchased * PACKAGE_COST_double;
    total = retail - saved;

    discountLabel.Text = string.Format("{0}%", discountrate * 100);
    totalLabel.Text = total.ToString("c"); 
    total = retail - saved;
    retail = purchased * PACKAGE_COST_double;
    savedLabel.Text = saved.ToString("c");
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}

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.