C# - Design Pattern For Dealing With Syncing Variables?

Jan 30, 2012

Suppose I have two events:

Public Sub Control1Updated() Handles control1.TextChanged
control2.Text = SomeFunction(control1.Text)
End Sub

[code]....

Basically the pairs of {control1.Text, control2.Text} and {control2.Text, control1.Text} should be the same. If control1.Text is changed to let's say "a" then control2.Text is ALWAYS "b". If control2.Text is changed to "b" then control1.Text is ALWAYS "a". How do I achieve this with events without going into an infinite loop? [the best I can think of is to make a check if the other control.Text is already the desired value].

View 1 Replies


ADVERTISEMENT

Looking For Design Pattern / For Each Instead Of For With Index

Jun 4, 2012

Using VB.Net, I'm looking for best practices in dealing with the following idiom:[code]What I really want is something VB.Net doesn't offer -- additional and simultaneous iterators on For Each statements.[code]I'm interested in both Linq and non-Linq recommendations, comments about Copy method design, comparisions to C# or other languages.

View 3 Replies

.net - Design Pattern For TypeOf Subclass?

Mar 4, 2012

I am working on a parser for a serial data protocol. I have an overarching Packet class, a couple sub-classes such as CommandPacket and StatusPacket, and then a few sub-classes of each of those:

[Code]..

While I don't think it is entirely relelvant to the discussion, I am doing this in VB.NET. There is also a similar (but not quite the same) question posted here: Java - subclass validation design pattern

View 2 Replies

C# - Design Pattern For Custom Events In .NET?

Feb 21, 2010

What is the proper design pattern for custom events in .NET (VB or C#).

I am refering to custom events, where in you override the AddHandler, RemoveHander, and RaiseEvent methods.

View 1 Replies

Design Pattern For Database Interaction?

Mar 12, 2012

I've been studying design patterns off-and-on now for a project I've recently been working on. I've been fortunate with this last one not to have to work with databases, but will soon have an opportunity.

View 8 Replies

'Producer Consumer' Design Pattern Using Queues?

Jul 23, 2009

I'm trying to replicate a design pattern used in a graphical programming language called LabVIEW. One thread produces commands, and another thread, or series of threads, consumes the commands.This is very similar to using Queues in VB...but there doesn't seem to be an easy way to start the consumer thread when new items are added to the queue.

Here is what I would like to accomplish, please let me know if there is a straightforward way to accomplish this with out of box .Net functionality.1) Start the Consumer Thread...it sits idle, waiting for some new commands to appear in its Queue.2) Producer places a few commands into the Queue. Example: "Home X Axis", "Home Y Axis", "Initialize Pump", "Display Ready Message"3) Consumer thread 'wakes up' at seeing the new commands, then performs the 4 tasks specified in 2.4) Consumer thread goes 'idle' again, and simply waits for new commands to appear in the Queue.

Process can continue on and on forever. The main problem I see with Queues is that there is no 'Wait for Something to Appear in Queue then Retrieve it" functionality. I don't want to use a perpetual loop to keep checking ever n milliseconds.

View 1 Replies

C# - Anonymous Method Alternative For Design Pattern?

Apr 18, 2012

With C# anonymous delegates, we can avoid declaration of extra method, I know in VB.NET they're not available, but is there a design pattern that I can use so that I can avoid writing an extra method each time? I need it for SPSecurity.RunWithElevatedPrivileges which will be used a lot of times in our code.

[Code]...

View 1 Replies

What Are The Features Of The Controller Class In The MVC Design Pattern

Aug 13, 2009

In the MVC design pattern we must use a controller(s) classes.

What are the fucntions (features) of the controller apart from handling communication bewteen Model and View?e.eg; can we include input validation code in the controller?

View 4 Replies

What Type Of Code Should Put In The Controller In The MVC Design Pattern

Jul 7, 2009

In teh MVC design pattern, Controller is strongly related to the view (GUI). IN my application i need to generated a new BrandID, i used stored procedure to retreive the highest BrandID from teh DB (The model calls the stored procedure and sends the retreival value to the Controller), then in the controller increments the BrandID by "1" to create a new brand ID. SInce, controller is strogly related to "view", should i include this "brandID increment" part in teh controller or in the model classes?

View 3 Replies

C# - Which Design Pattern For Activity Logging (Audit Trailing)

Jun 15, 2012

I have a winform which allows people to edit data from a database, to simplify things assume there is a Customer table in database with 3 fields - Name, City, Country. Through winform(s) people can Add/Edit/Delete customers.For each of these actions we need to save:

What the field names are (Name,City,Country in this case)What the field values were before they were modified What the field values are after they are modified.If the action is Add or Delete then 2 and 3 will be the same.I have already implemented this using XMLSerialisation (but not using any of the design patterns) and my XML output looks like this.

<?xml version="1.0" encoding="utf-8"?>
<ActivityItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<UserID>26</UserID>
<FormTitle>frmCustomer</FormTitle>

[code]....

The solution can handle different areas of the system with different number of fields (i.e the same thing works when you are modifying Products for instance).is there a well defined design pattern to deal with this kind of behavior?

View 2 Replies

Lifetime Of Multiple Instances Of An Object / Design Pattern?

Sep 5, 2009

having difficulty with understanding object lifetime / instantiation.I have a windows from with a datagridview and a panel. The datagridview has a checkbox column and a list of names which is populated from a database.The panel has a few text boxes (e.g. name, age, favourite sports team) and a 'save changes' button.

The idea is that when the user selects a person in the datagridview by checking the appropriate checkbox then the panel shows the relevant data for that person (name, age, fav sports team) by pulling the data from a database. If the user would like to update the person's details they can do so by typing in the textboxes and then clicking the 'save changes' button. All quite simple so far.

The way I have designed this is to have a 'panel' class and to create an instance when the user checks a checkbox.(NB - the reason I have created a 'panel' class is that I intend to replicate the datagridview and panel on other tabpages within my form and thought it would be useful to have a generic 'panel' class that I could re-use.)

My code looks a bit like this:

If CheckBoxClicked Then
Dim UpdatePanel As New UpdatePanel(MyForm.NameTextBox, MyForm.AgeTextBox, MyForm.FavSportTeamTextBox, MyForm.SaveButton)
UpdatePanel.GetData()
...

When the user clicks the SaveButton the data is updated to the database and I have a display message (simple textbox) which says "Update successful" and displays for 5 seconds before hiding itself.

Here is the problem:Suppose a user checks a checkbox, reviews the data and does not make any changes, and then checks another checkbox and decides to update the data by clicking the 'save changes' button. What happens is that the "Update successful" message is displayed twice.

I think this is because every time the user checks a checkbox an instance of UpdatePanel is created. If a I select five different people using the checkboxes and then hit 'save changes' I get five "Update successful" messages.

I am not sure how to overcome this. It feels like each time a checkbox is clicked I need to check if an instance of UpdatePanel exists and then destroy it. I tried using UpdatePanel = Nothing and also investigated IDisposable and GC.Collect() but with no luck.

[code]....

View 1 Replies

Asp.net - Refactor To Design Pattern: Displaying/hiding Different Combinations Of Controls Based On State?

May 26, 2009

Assume you have controls A, B, C, D and E all with a Visibility property. You also have states 1,2,3,4,5 and 6 in which various combinations of your controls would be displayed. Currently this is being handled by switch statements for each state: i.e.

Select Case PageState
case "1"
a.visible = false
b.visible = true

[code]....

As you can imagine, this becomes a pain as every state needs a show/hide statement for each control. How can I refactor this so that adding controls and/or states becomes trivial?My first instinct is to extend the control and add a collection of states that it should display for but this sounds like overkill.

Edit:I was deliberately vague in my question in case this has other implications. In my current instance the "controls" in question are ASP Panels. Does that change anything?

View 4 Replies

C# - Get A Code Template/design Pattern Can Use When Reacting To Mouse Clicks Or Button Presses?

May 3, 2011

One of the problems that I constantly see with Winforms applications is that the GUI thread is stuck while a long-running task is running or just plain stops refreshing (yes, I know - needs threading). Is there a code template/design pattern I can use when reacting to mouse clicks or button presses? Should there be a processing thread always running in the GUI app? Basically, how do I write a great Winforms Application that is easy to maintain and doesn't have any quirky refresh bugs?

View 4 Replies

Syncing A Textbox To A DataGridView Column

Aug 11, 2009

Is there a way to sync a textbox with a binding source to a datagridview?The textbox seems to be syncing to the first row of the datatable instead of the row that is selected in the datagridview.

View 7 Replies

Syncing All Songs In Textbox Onto USB MP3 Player

May 26, 2010

I would like some simple codes that allow you to import songs into a listbox then at the application of a button it will sync all of the songs in the textbox onto a USB MP3 Player.

View 5 Replies

Syncing Database Client Server In VB 2010?

Mar 24, 2012

I'm creating a VB2010 application which will require a connection to MSSQL. Should I Install SQL 2008 on my computer then use MS SQL 2008 as my data source or skip installing SQL 2008 and use MDF instead?

Also the program must have the following requirement

Program must use SQL as their database source End user must not install SQL server on their machine Program must be able to update (sync) the local SQL database from SQL server on the web. (User will have option to delete everything on their local database and load everything fresh from the server or to merge the update with existing data) Programs will (most of the time) run in an offline environment. When the user have access to internet they can update the database The program must allow user to add,edit, delete their local database while offline Only certain user (authorized user) can update their local database back to the serverC

Is it possible to created a program that meets all the above requirement ?

View 1 Replies

USB Mass Storage Devices - Moving / Syncing Files

Aug 18, 2010

I have a system that detects USB mass storage devices. I have a "list of items" listbox (ListBox3) and a list of USB's (Listbox4) When Button4 is pressed it will transfer all files in listbox3 onto the mass storage device selected in listbox4

View 29 Replies

Making Syncing Selected Rows In A Data Grid View?

Mar 17, 2012

I am trying to make an address book and need help. I am in the middle of making a search function for the program and I've got that working fine. What I would like to do is take the row that is selected from the search results and make that the selected entry for the main form. To explain what I mean I will include pics..

View 6 Replies

Css - Design A Webpage In Asp.net Design View Which Support Multi Resolution?

Nov 26, 2010

I have created my webpage in asp.net in 1024*768 resolution, my problem was that when i change my monitor resolution then the controls in my webpage will be displayed in unmanaged manner .

How to arrange items in my webpage which support multiple resolution ...

Whatever the resolution of my monitor the controls in my webpage will display as it is as managed in 1024*768 reolution !

View 1 Replies

Form Design - Cannot Expand Vertically In Design View

Jun 27, 2011

I seem to have reached a limit on the size of the form. I cannot make the form longer and I need to add more fields. Is there a limit on how many fields can be included in a form?

View 1 Replies

C# - Design Reference And Object Oriented Design Of A CRM

May 25, 2011

I searched codeplex and google. I have found so many such as tustena but unfortunately they are not domain driven based and in these solutions I could not find a good modelling documents or references. i am a newbie in CRM but I am sensetive to design it with solid object-oriented fundamentals. Any reference or open source solution especifically for CRM design and implementaion in .NET? Cheers

View 1 Replies

Dealing With Fractions In .NET?

Jul 5, 2009

I recently found myself in a thread deling with convertions from decimal number to fractions... Being a bit too brusk and dismissing the idea at first.I have now implemented a structure based on code frm Javelia whithc can be seen in this thread.Solitare also proveided code that I eventually understood and was working.[URL]...it a step longer and developed a structure that can also implement calculating with fractions... My first try is also posted in the tread above...

The implimentation is far from perfect, as it does not deal with POW of fractions.. So if anybody has some ideas on hoe to do this with squer root and all pleas let me know and Ill update the code..

[Code]...

View 7 Replies

.net - Dealing With Large Integers?

Apr 19, 2012

So I am making a file crypter so that I can encrypt my VB.NET Application that I am making so that people can't decompile it. I had made this in C# and am transfering it to VB.NET, Everything worked fine in C# but once I had re-written the code in VB.NET i get this error inside of my RC4 Encryption method:

'Arithmetic operation resulted in an overflow.'

The error is occuring here:

Dim t As Int64 = (s(i) + s(j)) Mod 256

This is the same code above in c#:

int t = (s[i] + s[j]) % 256;

Is there anyway to make that calculation with it erroring? And why does it work in C# but not VB.NET?

View 2 Replies

.net - Polymorphism In .Net When Dealing With Generics?

Jan 6, 2012

I have a function called Modify. It is delcared like so:Public Function Modify(Of SIMType As {New, DAOBase})(ByVal obj As DAOBase) As Boolean

You can see that this function is generic. It takes as a paramer a object that is a DAOBase or subclasses of DAOBase.Inside the modify function there is a call like so:

DAOToGP(obj)This is where the polymorphism comes into play. There are four or so subclasses I have created of DAOBase. I have written a DAOToGP() for each of these types. So in the Modify() function, when it calls the DAOToGP(obj), polymorphism should kick in and it should call the correct implementation of DAOToGP() depending on the type that I pass into Modify().

However, I get the following error:Error 20 Overload resolution failed because no accessible 'DAOToGP' can be called without a narrowing conversion:'Public Shared Function DAOToGP(distributor As Distributors) As Microsoft.Dynamics.GP.Vendor': Argument matching parameter 'distributor' narrows from 'SierraLib.DAOBase' to 'IMS.Distributors'.'Public Shared Function DAOToGP(product As Products) As Microsoft.Dynamics.GP.SalesItem': Argument matching parameter 'product' narrows from 'SierraLib.DAOBase' to 'IMS.Products'. C:Usersdvargo.SIERRAWOWIRESDocumentsVisual Studio 2010ProjectsSIMDev_2SIMIMSDVSIMLibGPGPSIMRunnerRunnersRunnerBase.vb 66 39 IMS

I am kind of at a loss here. I am not sure why it cant figure out which function to call.

View 2 Replies

Asp.net - JavaScript / Dealing With Different Browsers?

Aug 23, 2011

my code works fine in JavaScript but doesn't work correctly in Firefox or safari and wondering why. What I'm doing is I have a loop going through each element and depending on the variable inside a text box just want to alert something. Like i said earlier this code works fine in IE. Here is the code below:

Here is an example of text box:

<asp:TextBox ID="txtMac" runat="server" req="yes" errMessage="Mac"/>
for (a = 0; a < theForm.elements.length; a++) {
if (theForm.elements[a].type == "text" && theForm.elements[a].req == "yes") {
alert("Made it here")
}
}

View 5 Replies

Dealing With Apostrophe In Filter?

Jul 19, 2011

Problem dealing with apostrophe in filter?

View 5 Replies

Dealing With HUGE Numbers

Sep 21, 2009

I've been messing around with prime numbers for a while now, but I now want to use massive numbers, say a few million digits in length. Is there a way of storing and performing mathematical functions with such large numbers? Is it even possible on my home computer? I read on another old thread, something about a big number library, but the links he gave are now dead.

View 4 Replies

Dealing With Multiple Requests?

Jul 30, 2009

I have a website and say a user comes along and fills out the form with bogus data. Then after he fills it out, he enters another one and another one and another one of bogus data. He's basically just trying to clog up the data base.

How is the best way to combat this? Would it make sense to when they submit the data track the IP address?

View 4 Replies

IDE :: Datetimepicker When Dealing With Time Only?

Jan 6, 2010

I sure this has been asked more then once... New to vb.net and I have been experimenting with a datetimepicker and how it looks at and deals with time. What I am trying to do is to add up my time (not worried about the date at all). I have it figured out and can get it to work so long as I do not go over 24 hours... and that is where my issue comes into play.

How do I display my total time in hours once it has gotten over 24 hours ( I do not want days.. just hours) for instance, a 40 hour work week, not 1 day and 16 hours.

[Code]...

View 2 Replies

Sql - Dealing With A Varbinary Field?

Jun 10, 2009

A partner of ours is making a call to a web service that includes a parameter called token. Token is the result of an MD5 hash of two numbers, and helps us authenticate that the user using our partners system. Our partner asks the user for two strings, concatenates them, runs them through MD5, and then calls our web service. The result of the MD5 is the token, and it is submitted to us as a string.

We store valid tokens in a DB - since we use the SQL Server to compute the tokens on our end, SQL seemed to be happiest storing the tokens as a varbinary, which is its native result for an MD5 computation.

We have two pieces of code that attempt to do the same thing - run a select query that pulls out a value based on the token submitted. One uses a dynamic query (which is a problem), but it works. The other one attempts to do the same thing in a parameterized (safer) fashion, it does not work - it is unable to locate the token.

Here's the two competing attempts. First, the parameterized version which fails:

byteArrayToken = System.Text.UnicodeEncoding.Unicode.GetBytes(stringToken)
scSelectThing.CommandText = "select thing from tokenstable where token=@token"
Dim param As SqlParameter = scSelectThing.Parameters.Add("@token",

[Code].....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved