
Joe Mamma
Avatar/Signature-
Posts
1093 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Joe Mamma
-
yeah. . . that could be a problem I guess :o
-
you guys are way over complicating this i think. Remoting is the perfect application model. .net 2.0? IPC remoting. here is an example I wote on the msdn forums for win app to win app, can be easily switched to make the client an asp.net application against a vb.net server.
-
whoa wait a second. . . events are processed on postback. what you need to do is write javascript for the client side onhover event. . . thats the event in jscript right? onhover???
-
isnt this what an image list is for? Wont disposing an image list dispose the Bitmaps? load your images into an image list. Add references to the images to a hash table. to free, dispose the image list, reset your hashtable.
-
suppose you have two form types - public class ThisForm:Form {} and public class ThatForm:Form {} now, in the Main form of your app, you have two menuItems - ShowThisFormMenuItem and ShowThatFormMenuItem put this code in your form: protected override OnLoad(EventArgs e) { ShowThisFormMenuItem.Tag = typeof(ThisForm); ShowThatFormMenuItem.Tag = typeof(ThatForm); base.OnLoad(e); } wire both menuitems to this event handler- protected void ShowFormMenuItemClick(object sender, System.EventArgs e) { using (Form frm = Activator.CreateObject(((sender as MenuItem).Tag) as Type) as Form) frm.ShowDialog(); }
-
are these singleton forms??? meanin you can only have one form of one type open at a time??? I have a neat solution for MDI apps if this is the case.
-
Advise required for database structure
Joe Mamma replied to Rattlesnake's topic in Database / XML / Reporting
First, save yourself alot of trouble and make Month, Year one fields. . . a Date. You can force it to be the first day of the month, or the last, depending on what is appropriate. Dates are dates! treat them that way! Second I could see a need for two tables. . . if there is anywhere else in the database where (CustomerID, ProductID) is a primary key, it makes sense to add a surrogate to that table and then use that surrogate key in the MonthlyForecast for that relationship. for example, lets say you also were trackingproduct inquiries such as Customer A requested info on Product 1 and you were keeping track of Customer support for a customer and Products such as JohnDoe supports Customer A on Product1 and MaryDoe supports Customer A on product 2. this would be the best schema: note: Bold indicates primary key fields, Italic indicates surrogate key [CustomerProduct] CustomerID references (Customer) ProductId references (Product) CustomerProductID (unique) [ProductInquiry] CustomerProductID references (CustomerProduct) DateOfInquiry DateOfResponse [ProductSupport] CustomerProductID references (CustomerProduct) EmployeeID references (Employee) [SalesForecast] CustomerProductID references (CustomerProduct) ForecastDate ForecastQuantity Third, as far as unpivoting an excel spreadsheet I don't know of any automatic way. you can open the spreadsheet using the Jet OleDb Provider. psuedo code: for i = 0 to 11 select CustomerID, ProductID, i Month, monthcolYear into aDataTable add a ForecastDate column to aDataTable as a date time and iterate throught the table setting the ForecastDate based on Month and Year now you got a datatable you can use to move to the SQL server psuedo code: foreach row in aDataTable if not exist select * from CustomerProduct where CustomerProduct.CustomerID = aDataTable.CustomerID and CustomerProduct.ProductID = aDataTable.ProductID insert into CustomerProduct(CustomerID, ProductID) values(aDataTable.CustomerID, aDataTable.ProductID) foreach row in aDataTable insert into SalesForecast select CustomerProductID, aDataTable.ForecastDate, aDataTable.ForecastQuanity from CustomerProduct where CustomerProduct.CustomerID = aDataTable.CustomerID and CustomerProduct.ProductID = aDataTable.ProductID -
hah! never!!!
-
watch it. . . 31 is young to some of us!
-
this is a test. . . this is only a test. . .
-
-
I have seen a few people tring to reinvent the wheel by creating an application log file and then having problems with accessing the file, keeping the fiole synced between instances, etc. . . Don't rebuild the wheel, just do the following: 1. Drop an EventLog component from the components tab on to your form/page and : windows - eventLog1.Source = this.Name; eventLog1.Log = Application.ProductName; eventLog1.WriteEntry("Something Happened", System.Diagnostics.EventLogEntryType.Information,0); or ASP.NET eventLog1.Source = this.Name; eventLog1.Log = HttpContext.Current.Request.ApplicationPath; eventLog1.WriteEntry("Something Happened", System.Diagnostics.EventLogEntryType.Information,0);
-
That is just a coincidence. . . Use parameters. . . never build sql!
-
Not using parameters!
-
oops. . .just saw that this is ASP.NET!!! the same ideas should apply!
-
now. . . all that being said - Do you need more than one of these selected year combo's in your app??? It may be worth your while to inherit from ComboBox and publish out a max, min, AllowNull and SelectedYear properties. Implement ISupoportInitialize and Create and Populate the bound collection in it's EndInit method (only if not designmode!!!) - public class YearCombo : System.Windows.Forms.ComboBox, ISupportInitialize { int _min; int _max; bool _allowNull; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public YearCombo(System.ComponentModel.IContainer container) { /// /// Required for Windows.Forms Class Composition Designer support /// container.Add(this); InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } public YearCombo() { /// /// Required for Windows.Forms Class Composition Designer support /// InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Component Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { components = new System.ComponentModel.Container(); } #endregion #region ISupportInitialize Members public void BeginInit() { // TODO: Add YearCombo.BeginInit implementation } public void EndInit() { if (DesignMode) return; ArrayList al = new ArrayList(); if (_allowNull) al.Add(string.Empty); for (int i = _min; i <= _max; i++) al.Add(new YearValue(i)); this.DataSource = al; } #endregion public int MinYear { get { return _min; } set { if (_max < value) throw new ArgumentException( string.Format("Minimum Year must be less than or equal to {0}", _max.ToString())); _min = value; this.EndInit(); } } public int MaxYear { get { return _max; } set { if (_min > value) throw new ArgumentException( string.Format("Maximum Year must be greater than or equal to {0}", _min.ToString())); _max = value; this.EndInit(); } } public bool AllowNull { get { return _allowNull; } set { if (_allowNull = value) return; _allowNull = value; EndInit(); } } public YearValue SelectedYear { get { //returns null if empty string is selected. . . return this.SelectedValue as YearValue; } } } public class YearValue { int _value; public override string ToString() { string s = _value.ToString().PadLeft(4,'0'); return s.Substring(s.Length-2,2); } public YearValue(int value) { _value = value; } public int Value { get { return _value; } set { _value = value; } } }
-
or - if (this.SelectedYear == null) MessageBox.Show("Please Select a Year") else MessageBox.Show(string.format("{0} = {1}", this.SelectedYear.ToString(), this.SelectedYear.Value.ToString()));
-
there are many ways to filet this feline. . . and maybe this is simpler. . . though the value of the combobox will be a DateValue object where the first one the value was an int. . . public class YearValue { int _value; public override string ToString() { string s = _value.ToString().PadLeft(4,'0'); return s.Substring(s.Length-2,2); } public YearValue(int value) { _value = value; } public int Value { get { return _value; } set { _value = value; } } } and to load: comboBox1.DataSource = new ArrayList( new object[] { new YearValue(2005), new YearValue(2006), new YearValue(2007), new YearValue(2008), new YearValue(2009), new YearValue(2010) } ); set the DropDownStyle of the combo to DropDownList. And to get the actual year value: MessageBox.Show((comboBox1.SelectedValue as YearValue).Value.ToString()); do you need to allow a null selection in the combo??? comboBox1.DataSource = new ArrayList( new object[] { string.Empty; new YearValue(2005), new YearValue(2006), new YearValue(2007), new YearValue(2008), new YearValue(2009), new YearValue(2010) } ); then you can add a property to your form: protected YearValue SelectedYear { get { //returns null if empty string is selected. . . return comboBox1.SelectedValue as YearValue; } } then to get the value: if (this.SelectedYear == null) MessageBox.Show("Please Select a Year") else MessageBox.Show(this.SelectedYear.Value.ToString()); Again. . .the concept here is that the control only manages the GUI events and presentation, That is, it presents the selected object from the bound collection to the GUI. It has a reference to the collection of objects but it dose not explicitly contain the objects. I hope this sparks some ideas.
-
dont mix format with value. . . Do something like the following: public class YearValue { int _value; int _min; int _max; public string Display { get { return _value.ToString().PadLeft(4,'0').Substring(2,2); } } public int Value { get { return _value; } set { if ((value >= _min) && (value <= _max)) _value = value; else throw new ArgumentException("Value out of range"); } } public YearValue() { _min = 2000; _max = 2010; _value = 2000; } public YearValue(int min, int max) { _min = min; _max = max; _value = min; } public YearValue(int min, int max, int value) { _min = min; _max = max; Value = value; } } usage System.Collections.ArrayList al = new ArrayList(); al.Add(new YearValue(2005, 2010, 2005)); al.Add(new YearValue(2005, 2010, 2006)); al.Add(new YearValue(2005, 2010, 2007)); al.Add(new YearValue(2005, 2010, 2008)); al.Add(new YearValue(2005, 2010, 2009)); al.Add(new YearValue(2005, 2010, 2010)); comboBox1.DataSource = al; comboBox1.DisplayMember = "Display"; comboBox1.ValueMember = "Value";
-
well. . . '05' is a string. . . do you want the integer 5 or the string '05' to get the the string '05' string currentYear = DateTime.Now.ToString('yy'); from there you can figure out how to get integer 5.
-
yes. . . now, this isnt a submit button. . . if you want the submit to do the check, then you need to attach to the form's onsubmit event. If onsubmit return's false, the form is not submitted. . . that being said you would do something like: <html> <script> function editValues() { var invals = new Object(); invals.value1 = document.all.value1.innerHTML; invals.value2 = document.all.value2.innerHTML; var vals = window.showModalDialog("./editVals.htm", invals, " dialogHeight: 200px; dialogWidth:300px; dialogTop: px; dialogLeft: px; " + "center: Yes; edge: Raised; help: Yes; resizable: No; status: No; scroll:no;"); if (vals == null) return false; document.all.value1.innerHTML = vals.value1; document.all.value2.innerHTML = vals.value2; return true; } </script> <body> <form onsubmit='editValues();'> <span ID="value1">foo</SPAN> <br> <span ID="value2">foo</SPAN> <br> <input type="submit"/> </form> </BODY> </HTML>
-
sounds like a job for CSLA. check out lhotka's C# Business objects http://lhotka.net/