Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

josda1000

@josda1000
About
Posts
877
Topics
43
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How instantly free up the memory for List<T> & DataSet
    J josda1000

    true... at that point he should use unsafe code. possibly.

    Josh Davis
    This is what plays in my head when I finish projects.

    C# performance question announcement

  • Export from DataGridView to access _ c#
    J josda1000

    First off, as the discussion previous to this one states, you should never write a query like this without using SqlCommands and SqlParameters. PLEASE use that for production code. If this is not for production, then please take a look at your loop. You are looping on the number of Rows in the table, yet you are using the variable i to index on the table's Columns. I'm guessing you're trying to make the insert statement include all of the columns in the data table, and make a newly inserted row for each row in the data table. These would have to be two different for loops, concatenating to the same command string.

    Josh Davis
    This is what plays in my head when I finish projects.

    C# help csharp database com security

  • C#
    J josda1000

    I agree. This is C#.

    Josh Davis
    This is what plays in my head when I finish projects.

    C# csharp linq

  • A couple of entries from the Codex Vomitus
    J josda1000

    I think it meats and exceeds people's expectations.

    Josh Davis
    This is what plays in my head when I finish projects.

    The Weird and The Wonderful help

  • What is good practice
    J josda1000

    just a quick correction: It's not WinForms that defines partial classes, but the languages of C# and VB do. You don't need a WinForms project to make use of the feature.

    Josh Davis
    This is what plays in my head when I finish projects.

    C# question

  • [Solved]How i deserialize a specific JSON with Newtonsoft
    J josda1000

    very odd. if you come up with the reason why, i'd be curious.

    Josh Davis
    This is what plays in my head when I finish projects.

    C# collaboration json

  • How can I make my code modular?
    J josda1000

    It was late last night when I was coding that up, but I noticed a lot that could be broken down into that subclass. I also agree with earlier responses... some of this calculation logic could really be in another project altogether, separating the algorithm from the UI wiring. However, the original question asked how to make it modular... I believe that question has to do with the repetition in control logic. I assume the controls look like they're in a grid, having three columns or rows, each of which containing StartTimes, EndTimes, and the like. That's what the subclass was for. I worked a lot more on the logic this morning, and this is what I have now:

    public class UIForm
    {
        public class TimeSet
        {
            private TextBox \_txtAllottedTime;
            private TextBox \_txtStartTime;
            private TextBox \_txtEndTime;
            private Label \_lblOverTime;
            private Label \_lblOverTimePercentage;
            private int \_overTime;
            private int \_completeTime;
    
            public TimeSpan AllottedTime =>
                TimeSpan.Parse(\_txtAllottedTime.Text);
            private DateTime StartTime =>
                DateTime.Parse(\_txtStartTime.Text);
            private DateTime EndTime =>
                DateTime.Parse(\_txtEndTime.Text);
    
            public TimeSet(
                TextBox txtAllottedTime,
                TextBox txtStartTime,
                TextBox txtEndTime,
                Label lblOverTime,
                Label lblOverTimePercentage,
                int overTime,
                int completeTime)
            {
                \_txtAllottedTime = txtAllottedTime;
                \_txtStartTime = txtStartTime;
                \_txtEndTime = txtEndTime;
                \_lblOverTime = lblOverTime;
                \_lblOverTimePercentage = lblOverTimePercentage;
                OverTime = overTime;
                \_completeTime = completeTime;
            }
    
            public int OverTime
            {
                get => \_overTime;
                private set
                {
                    \_overTime = value;
                    \_lblOverTime.Text = value.ToString();
                }
            }
    
            public bool TextWasEnteredByUser =>
                string.IsNullOrEmpty(AllottedTime.Text) ||
                string.IsNullOrEmpty(StartTime.Text) ||
                string.IsNullOrEmpty(EndTime.Text);
    
            public TimeSpan Duration
    
    C# question winforms algorithms help

  • How can I make my code modular?
    J josda1000

    I'm not sure how far you got with breaking this down into a single algorithm, but here's what I got so far.

    public class UIForm
    {
    public class TimeSet
    {
    private TextBox _txtAllottedTime;
    private TextBox _txtStartTime;
    private TextBox _txtEndTime;

        public TimeSet(TextBox txtAllottedTime, TextBox txtStartTime, TextBox txtEndTime)
        {
            \_txtAllottedTime = txtAllottedTime;
            \_txtStartTime = txtStartTime;
            \_txtEndTime = txtEndTime;
        }
    
        private string AllottedTime =>
            \_txtAllottedTime.Text;
        private string StartTime =>
            \_txtStartTime.Text;
        private string EndTime =>
            \_txtEndTime.Text;
    
        public bool TextWasEnteredByUser =>
            string.IsNullOrEmpty(AllottedTime) ||
            string.IsNullOrEmpty(StartTime) ||
            string.IsNullOrEmpty(EndTime);
    }
    
    public List TimeSets
    {
        new TimeSet(txtTimeLimit1, txtEntryTime1, txtExitTime1),
        new TimeSet(txtTimeLimit2, txtEntryTime2, txtExitTime2),
        new TimeSet(txtTimeLimit3, txtEntryTime3, txtExitTime3)
    };
    
    public void park1()
    {
        park(TimeSets\[0\]);
    }
    
    public void park2()
    {
        park(TimeSets\[1\]);
    }
    
    public void park3()
    {
        park(TimeSets\[2\]);
    }
    
    public void park(TimeSet timeSet)
    {
        if (!timeSet.TextWasEnteredByUser)
        {
            MessageBox.Show("Enter all time values");
        }
        else
        {
            TimeSpan alloted = TimeSpan.Parse(timeSet.AllottedTime);
            DateTime start = DateTime.Parse(timeSet.StartTime);
            DateTime end = DateTime.Parse(timeSet.EndTime);
    
            if (start > end)
                end = end.AddDays(1);
    
            TimeSpan duration = end.Subtract(start);
    
            //If the start time is greater than end that means the diff is above 12 hours
            //So subtracting the hours from a day to get the number of hours used if (TimeSpan.Compare(alloted, duration) == -1)
            if (TimeSpan.Compare(alloted, duration) == -1)
            {
                overTime1++;
            }
    
            completeTime1++;
            lblOverTime1.Text = "" + overTime1;
            int percentage = (overTime1 \* 100) / completeTime1;
            lblOverTimePercentage1.Text = "" + percentage;
    
            if (percentage > 50)
            {
                warnWarden();
    
    C# question winforms algorithms help

  • [Solved]How i deserialize a specific JSON with Newtonsoft
    J josda1000

    I believe the issue lies in that you have multiple fields in Ranked (formerly RankedConquest) marked as type object. I'm pretty sure Newtonsoft doesn't know how to convert from whatever is in the JSON string to the object field, so either specify a class or a value type.

    Josh Davis
    This is what plays in my head when I finish projects.

    C# collaboration json

  • To spice things up (cuz yeah it's quiet.)
    J josda1000

    http://mises.org/daily/5045/The-Education-Bubble-Is-Fuel-for-Revolt[^] Read. Discuss.

    Josh Davis
    This is what plays in my head when I finish projects.

    The Back Room com question learning

  • revolution
    J josda1000

    Basically lately I've been a lurker. I noticed that a hell of a lot of nothing has been talked about in the back room in the last week or two, and I thought it was a great time to show people that history time and again shows to for those who think that standing up to the government is a fool's game. People who think like this, people who are scared of the government, are those whom has no inner spirit for the most part. If you have dignity for yourself and others, show it. That's the way I see it. "Government is there for the greater good." Ha. There's something consistent with all governments: it's involuntary. It's a thief. It's a murderer. The very basis of government is that it's force and an aggressor. You pay your taxes for fear of going to jail. It is the only group on the planet that consistently steals to give to the rich, and whatever they don't want they give back to you to make it seem like a Robin Hood story. They constantly cause wars "to spread democracy" when it's just oil they're after, having nothing to do, again, with the common man. #justsayin Sorry I ranted Ian, but seriously, people need to see what this whole thing is about. Yes, if people want change, they can make it happen. But why is that? He was trying to revoke their rights... but that's impossible. They are acting in self defense, which is absolutely a natural right. You can't take away rights; it's impossible. They're unalienable. You couldn't trade a right even if you wanted to. Anyway, good to see you're still checkin out the back room Ian, it's been awhile.

    Josh Davis
    This is what plays in my head when I finish projects.

    The Back Room csharp com question

  • revolution
    J josda1000

    So, for the past few weeks, Tunisia, Albania, England and now Egypt are rioting/revolting. So even though they have the guns, the state is not able to keep this down. It's not that they can't, it's that their power comes only from consent. So: do you fear the people? Do you fear the government? Do you feel sympathy for the people, or do you think that the state should rule with such a heavy hand? http://english.aljazeera.net/watch_now/[^] Egypt revolution at your fingertips.

    Josh Davis
    This is what plays in my head when I finish projects.

    The Back Room csharp com question

  • Joke about an elephant. OK fine, a half joke. OK fine, not really a joke.
    J josda1000

    An elephant was standing on the corner shredding documents, when a man walks up. "What are you shredding?" "The Constitution, Bill of rights, Declaration of Independence, and Federalist Papers." "Why are you doing that?" "To prevent a terrorist attack." "But, there hasn't been a terrorist attack in nine years!" "See how well it works!?"

    Josh Davis
    This is what plays in my head when I finish projects.

    The Back Room com question

  • Bernanke's Solutions are the Problem
    J josda1000

    Yeah you're right, I should be. I suggest we get this done within a year. I expect price inflation to really hit in 2012 (appropriate with all of the mayan crap on the web lol). If they really do have two more rounds of QE, we're screwed. Of course, "capitalism" will be blamed by some on this site... but I know more libertarians every day, and just found out that my friend is now libertarian because of me and the show, and my tweets on twitter lol If enough people wake up, it'll be great.

    Josh Davis
    This is what plays in my head when I finish projects.

    The Back Room com help question

  • Bernanke's Solutions are the Problem
    J josda1000

    Distind wrote:

    No matter how many times someone points out the massive failures of free economies you'll believe that won't you.

    It's funny that liberals are named as such... originally liberals were the ones who wanted to be free of government intervention, in all cases. Anyway. Yes, I will. Because I've argued against Ian a few times, and a few others as well, point for point.

    Distind wrote:

    I can't disagree on the federal interest rate being to low for to long, but the magical free market is hardly the answer to it's own failures.

    The failures were caused by interventionism. QE will not help anything. Interest rates rising will cause another collapse (and they must inevitably be raised.) Once the interest rates rise higher, this will signal that the banks have to become more responsible because they'll have to pay them back. This will cause interest rates to rise on all loans... causing another housing crash, or whatever the bubble is today. And no, don't tell me it's gold/silver/commodities. Because I'll tell you, you will not see a significant dip in that sector. The market is a part of nature, because we (people) ARE the market. It's like saying that wings need to be clipped off birds because they cause their own killing when flying into a window. Or it's like saying that mice cause their own death by dwelling in someone's house and then stepping on a mouse trap.

    Distind wrote:

    It's going to cause issues at some point, but with how much people scream whenever something costs them more and they can actually blame someone I doubt it's going up any time soon.

    It already is. Are you blind? Check out the price changes in food over the last few months. Or pretty much any other price. And why is this? Maybe, just maybe, it's because of "quantitative easing", which is the very definition of inflation (no matter how much you Keynesians wish to not believe it) or the interest rates.

    Distind wrote:

    Inflation happens, it's happened for years, and to be perfectly honest it's the basics of the free market that do it.

    TOTALLY IGNORANT. You want to know what a free market looks like? Try the United States from 1860ish to 1913. There was no central bank. The dollar rose in value 13%... causing prices to drop. Why did it rise? Because there was

    The Back Room com help question

  • The Yanks have done it again
    J josda1000

    Don't you understand that this is precisely why we need to end the federal reserve system? If you understand this basic point of relaxation from political pressure and confusion, you should understand that this is only one big reason as to abolishing it. The good thing is, Ron and Rand will be introducing legislation to end/audit the fed next session in both houses.

    Josh Davis
    This is what plays in my head when I finish projects.

    The Back Room com question

  • Bernanke's Solutions are the Problem
    J josda1000

    http://mises.org/daily/4798[^] Think about it. Think about the prices of EVERYTHING going up, not just commodities. (BTW, since I bought my silver, I've realized a 50% profit.) Yes, the market reacts quickly to politicians and what they say... but eventually the market just adjusts for itself. Think about the monetary inflation. Think about the fiddling of interest rates. Just think outside of your "beliefs" and look at the numbers, look at facts. Political economies do not last. If this economy was free of intervention, we'd be a lot more safe. I do fear for hyperinflation at this point. I'm glad I got some silver.

    Josh Davis
    This is what plays in my head when I finish projects.

    The Back Room com help question

  • MARTIANS FIND EARTH!
    J josda1000

    http://www.youtube.com/watch?v=eO33o0se_Aw[^] This is great. It's a classic.

    Josh Davis
    This is what plays in my head when I finish projects.

    The Back Room com question

  • I've just hit 2000 points
    J josda1000

    It's a reference to Dragonball Z. Not that I like the show, but it became a meme in the interwebs.

    Josh Davis
    This is what plays in my head when I finish projects.

    The Lounge

  • I've just hit 2000 points
    J josda1000

    I wish I had OVER NINE THOUSAND!!!!

    Josh Davis
    This is what plays in my head when I finish projects.

    The Lounge
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups