|
| | Lunan Programming Corner (XHTML,CSS,ASP.NET,C#,MYSQL) | |
| | Author | Message |
|---|
lunan Junior Member

Number of posts: 258 Course / Major: IT in Computing Registration date: 2008-08-18 Points: 771 Reputation: 1
 | Subject: Lunan Programming Corner (XHTML,CSS,ASP.NET,C#,MYSQL) Wed Jun 17, 2009 7:28 am | |
| Introducing...Lunan...as a developer...XD
Shall we start? btw this first post...will be an index...so if there are no meaningful post here...forgive me
C# Class programming and Logic (Intermediate) - Page 1 Tricks and Tips for XHTML CSS (Beginner) - Page 1 MYSQL Beginner Guide (Beginner) - Page 1
Last edited by lunan on Wed Jun 17, 2009 9:42 am; edited 4 times in total |
|  | | lunan Junior Member

Number of posts: 258 Course / Major: IT in Computing Registration date: 2008-08-18 Points: 771 Reputation: 1
 | Subject: Re: Lunan Programming Corner (XHTML,CSS,ASP.NET,C#,MYSQL) Wed Jun 17, 2009 8:33 am | |
| This topic dedicated to the intermediate, not usable for beginner, especially in .NET ASSIGNMENT CLASS LIBRARY (DLL) IOCONTROL CLASS | Spoiler: | | |
| Quote: | using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO;
namespace ClassLibrary { public abstract class IOControl { private string _LastFileLocation; public string LastFileLocation { get { return _LastFileLocation; } set { _LastFileLocation = value; }
}
public abstract void OpenFile(string FileLocation);
public abstract void WriteFile(string FileLocation);
public bool Add() { return false; } public bool Delete() { return false; } public bool Update() { return false; } public int Search() { return -1; } public string Print() { return ""; } public void ArraySplitter() { }
} }
|
|
USER CLASS
| Spoiler: | | |
| Quote: | using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO;
namespace ClassLibrary { public class User : IOControl { private List<int> _CustomerID = new List<int>(); private List<string> _CustomerAddress = new List<string>(); private List<string> _CustomerName = new List<string>(); private List<int> _MembershipLevel = new List<int>(); private List<string> _STempFile = new List<string>();
public User(string FileLocation) { try { OpenFile(FileLocation); ArraySplitter(); LastFileLocation = FileLocation; _CustomerID.Capacity = 100; _CustomerName.Capacity = 100; _CustomerAddress.Capacity = 100; _MembershipLevel.Capacity = 100; } catch (Exception e) { e.ToString(); } }
public User() {
} public bool Add(int CustomerID, string CustomerAddress, string CustomerName, int MembershipLevel) { try { if (Search(CustomerID) == -1) {
_CustomerID.Add(CustomerID); _CustomerAddress.Add(CustomerAddress); _CustomerName.Add(CustomerName); _MembershipLevel.Add(MembershipLevel);
return true; } else { return false; } } catch (Exception e) { e.ToString(); return false; } }
public bool Delete(int CustomerID) { try { if (Search(CustomerID) == -1) { return false; } else { int x = Search(CustomerID);
_CustomerID.RemoveAt(x); _CustomerAddress.RemoveAt(x); _CustomerName.RemoveAt(x); _MembershipLevel.RemoveAt(x);
return true; } } catch (Exception e) { e.ToString(); return false; } }
public bool Update(int CustomerID, string CustomerAddress, string CustomerName, int MembershipLevel) { try { if (Search(CustomerID) == -1) { return false; } else { _CustomerID[Search(CustomerID)] = CustomerID; _CustomerAddress[Search(CustomerID)] = CustomerAddress; _CustomerName[Search(CustomerID)] = CustomerName; _MembershipLevel[Search(CustomerID)] = MembershipLevel; return true; } } catch (Exception e) { e.ToString(); return false; } }
public int Search(int CustomerID) { try { int intreturn = 0; for (int i = 0; i < _CustomerID.Count; i++) { if (_CustomerID[i] == CustomerID) { intreturn = i; break; } else { intreturn = -1; }
} return intreturn; } catch (Exception e) { e.ToString(); return -1; } } public string Print(int Index) { try { Console.WriteLine(_CustomerID[Index].ToString()); return "ok"; } catch (ArgumentOutOfRangeException) { Console.WriteLine("error"); return "error"; } }
public new void ArraySplitter() { try { string[] TempArray; for (int i = 0; i <= _STempFile.Count; i++) {
TempArray = _STempFile[i].Split((",").ToCharArray()); for (int x = 0; x < 1; x++) { _CustomerID.Add(int.Parse(TempArray[x])); _CustomerAddress.Add(TempArray[x + 1]); _CustomerName.Add(TempArray[x + 2]); _MembershipLevel.Add(int.Parse(TempArray[x + 3]));
} Array.Clear(TempArray, 0, 4);
} _STempFile.Clear(); }
catch (Exception e) { e.ToString(); } }
public override void OpenFile(string FileLocation) { try { string[] temp = File.ReadAllLines(FileLocation); _STempFile.AddRange(temp);
} catch (Exception e) { e.ToString();
}
}
public override void WriteFile(string FileLocation) { try { FileStream file = new FileStream(FileLocation, FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(file);
for (int i = 0; i < _CustomerID.Count; i++) { sw.WriteLine(_CustomerID[i].ToString() + "," + _CustomerAddress[i] + "," + _CustomerName[i] + "," + _MembershipLevel[i].ToString());
} sw.Close(); } catch (Exception e) { e.ToString(); } }
}
}
|
|
INVENTORY CLASS
| Spoiler: | | |
| Quote: | using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO;
namespace ClassLibrary { public class Inventory : IOControl { private List<int> _ProductID = new List<int>(); private List<string> _ProductDescription = new List<string>(); private List<int> _ProductInventory = new List<int>(); private List<float> _ProductPrice = new List<float>(); private List<string> _STempFile = new List<string>();
public bool Add(int ProductID, string ProductDescription, int ProductInventory, float ProductPrice) { try { if (Search(ProductID) == -1) {
_ProductID.Add(ProductID); _ProductDescription.Add(ProductDescription); _ProductInventory.Add(ProductInventory); _ProductPrice.Add(ProductPrice);
return true; } else { return false; } } catch (Exception e) { e.ToString(); return false; } }
public bool Delete(int ProductID) { try { if (Search(ProductID) == -1) { return false; } else { int x = Search(ProductID);
_ProductID.RemoveAt(x); _ProductDescription.RemoveAt(x); _ProductInventory.RemoveAt(x); _ProductPrice.RemoveAt(x);
return true; } } catch (Exception e) { e.ToString(); return false; } }
public bool Update(int ProductID, string ProductDescription, int ProductInventory, float ProductPrice) { try { if (Search(ProductID) == -1) { return false; } else { _ProductID[Search(ProductID)] = ProductID; _ProductDescription[Search(ProductID)] = ProductDescription; _ProductInventory[Search(ProductID)] = ProductInventory; _ProductPrice[Search(ProductID)] = ProductPrice; return true; } } catch (Exception e) { e.ToString(); return false; } }
public int Search(int ProductID) { try { int intreturn = 0; for (int i = 0; i < _ProductID.Count; i++) { if (_ProductID[i] == ProductID) { intreturn = i; break; } else { intreturn = -1; }
} return intreturn; } catch (Exception e) { e.ToString(); return -1; } }
public new void ArraySplitter() { try { string[] TempArray; for (int i = 0; i <= _STempFile.Count; i++) {
TempArray = _STempFile[i].Split((",").ToCharArray()); for (int x = 0; x < 1; x++) { _ProductID.Add(int.Parse(TempArray[x])); _ProductDescription.Add(TempArray[x + 1]); _ProductInventory.Add(int.Parse(TempArray[x + 2])); _ProductPrice.Add(float.Parse(TempArray[x + 3]));
} Array.Clear(TempArray, 0, 4);
} _STempFile.Clear(); }
catch (Exception e) { e.ToString(); } }
public override void OpenFile(string FileLocation) { try { string[] temp = File.ReadAllLines(FileLocation); _STempFile.AddRange(temp);
} catch (Exception e) { e.ToString();
} }
public override void WriteFile(string FileLocation) { try { FileStream file = new FileStream(FileLocation, FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(file);
for (int i = 0; i < _ProductID.Count; i++) { sw.WriteLine(_ProductID[i].ToString() + "," + _ProductDescription[i] + "," + _ProductInventory[i].ToString() + "," + _ProductPrice[i].ToString());
} sw.Close(); } catch (Exception e) { e.ToString(); } } } }
|
|
|
|  | | lunan Junior Member

Number of posts: 258 Course / Major: IT in Computing Registration date: 2008-08-18 Points: 771 Reputation: 1
 | Subject: Re: Lunan Programming Corner (XHTML,CSS,ASP.NET,C#,MYSQL) Wed Jun 17, 2009 8:34 am | |
| CHECKOUT MODULE | Spoiler: | | |
| Quote: | using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO;
namespace ClassLibrary { public class Checkout : IOControl { private List<string> _Date = new List<string>(); private List<string> _ProdID_Quantity = new List<string>(); private List<int> _CustomerID = new List<int>();
private DateTime _CurrentTransactionDate; private List<int> _CurrentTransactionQuantity = new List<int>(); private int _CurrentTransactionCustomerID = 0; private List<int> _CurrentTransactionProductID = new List<int>(); private List<string> _STempFile = new List<string>();
public bool CurrentTransaction(int ProductID, int Quantity, int CustomerID) { if (_CurrentTransactionCustomerID == CustomerID || _CurrentTransactionCustomerID == 0) { _CurrentTransactionDate = DateTime.Now; _CurrentTransactionProductID.Add(ProductID); _CurrentTransactionQuantity.Add(Quantity); return true; }
else { return false;
}
}
public bool Delete(int CustomerIDIndex) { try { _CustomerID.RemoveAt(CustomerIDIndex); _ProdID_Quantity.RemoveAt(CustomerIDIndex); _Date.RemoveAt(CustomerIDIndex); return true; } catch (Exception e) { e.ToString(); return false; } }
//to write temp data to database public bool Finalize() { string TempContainer = "";
//Error check if (_CurrentTransactionProductID.Count == _CurrentTransactionQuantity.Count) { _Date.Add(_CurrentTransactionDate.ToShortDateString()); _CustomerID.Add(_CurrentTransactionCustomerID);
//First iteration for (int x = 0; x <= _CurrentTransactionProductID.Count; x++) { TempContainer = TempContainer + _CurrentTransactionProductID[x].ToString(); }
TempContainer = TempContainer + "."; //second iteration for (int x = 0; x <= _CurrentTransactionQuantity.Count; x++) { TempContainer = TempContainer + _CurrentTransactionQuantity[x].ToString(); }
_ProdID_Quantity.Add(TempContainer);
return true;
}
else { return false; }
}
public new void ArraySplitter() { try { string[] TempArray; List<string> TempList = new List<string>(); for (int i = 0; i <= _STempFile.Count; i++) {
TempArray = _STempFile[i].Split((",").ToCharArray()); for (int x = 0; x < 1; x++) { _CustomerID.Add(int.Parse(TempArray[x])); _Date.Add(TempArray[x + 1]); _ProdID_Quantity.Add(TempArray[x + 2]);
} Array.Clear(TempArray, 0, 4);
}
_STempFile.Clear(); } catch (Exception e) { e.ToString(); } }
public override void OpenFile(string FileLocation) { try { string[] temp = File.ReadAllLines(FileLocation); _STempFile.AddRange(temp);
} catch (Exception e) { e.ToString();
} }
public override void WriteFile(string FileLocation) { try { FileStream file = new FileStream(FileLocation, FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(file);
for (int i = 0; i < _CustomerID.Count; i++) { sw.WriteLine(_CustomerID[i].ToString() + "," + _Date[i].ToString() + "," + _ProdID_Quantity[i].ToString()); } sw.Close(); } catch (Exception e) { e.ToString(); } } } }
|
|
Big time mistake of mine is when i design the database, i should have separate the checkout module of getting transaction ID and Quantity separate. put that in 1 table where there are multiple entries rather than consolidating them in the string. which rather confusing enough as it is.
so, tips for developer who are working with data. DESIGN YOUR TABLE FIRST.....unlike me who just go with the flow, and rather regretting it
and you can see from the programming, im so lazy to implement the correct exception handler present (i should throw an exception...). but all in all, .NET provides nice exception, unlike c++ which if you have problem, its just crash.
sorry for splitting topic like this...got error where msg too big XD
1 more about formatting...its kinda hard to read. so...i hope you understand |
|  | | lunan Junior Member

Number of posts: 258 Course / Major: IT in Computing Registration date: 2008-08-18 Points: 771 Reputation: 1
 | Subject: Re: Lunan Programming Corner (XHTML,CSS,ASP.NET,C#,MYSQL) Wed Jun 17, 2009 9:19 am | |
| Tips and Trick for XHTML CSS 1.Use FIREFOX to develop apps. Reason why? EXTENSION - Firebug(The Kings of Extension), ColorZilla,HTTPFOX,FirePHP,HackBar,and VIEW DEPENDENCIES(very important) i'll add later on 2.NEVER EVER USER DREAMWEAVER TO DO DRAG AND DROP ! Reason why?dreamweaver preview is screwed, BIG TIME. try using it, but dont complain when things go awry. My suggestion is to use Microsoft Expression Web 2 if you wish to drag and drop. (1 more thing, dreamweaver is fine for coding...just preview and debug it using web browser..) 3.Split your CSS and XHTML coding, which provide cleaner look, and optimise your image, dont put like 100KB small image...its just wasting bandwidth 4.If you can, screw EM(CSS style for width height)..or variable witdh and height. nice when you resize browser, or targeting lots of monitor res...but screw the whole layout. use fixed width and height instead 5.Avoid table to do the layout. Table is not meant to be used for layout. only forum, and some highly advanced website use it. do DIV styling with float instead. 6.Avoid using XHTML attributes, instead use css. 7.Many teacher and many of your assignment will ask about the w3c compliance, XHTML and CSS. My opinion? can you create site, with multiple browser compatibility, and still compliant? Unless you are an expert user, it might be hard. so, do you sacrifice cross-browser for compliant ? or the other way around, like ME  CSS RESETTER (google for the definition.i cant explain much...) basically forces your css to be compatible across browser, but somehow resetter didnt pass compliance. i'll put my past project underlining this soon. EDIT:Putting CSS RESETTER
Last edited by lunan on Wed Jun 17, 2009 1:16 pm; edited 1 time in total |
|  | | lunan Junior Member

Number of posts: 258 Course / Major: IT in Computing Registration date: 2008-08-18 Points: 771 Reputation: 1
 | Subject: Re: Lunan Programming Corner (XHTML,CSS,ASP.NET,C#,MYSQL) Wed Jun 17, 2009 9:41 am | |
| MYSQL Guide 1.Dont create composite key if you have primary key that is used in another table, dont create a weak table of composite key. The big reason why is the performance problem when searching later on. Instead, create another table to hold that as a foreign key EX: you have customer table and Inventory table. you want to make a Transaction record. Dont just create a weak table consists of a composite key, from 2 table, but create a table, with transaction ID as a primary key and use the other as a foreign. 2.Do the Normalisation Process up to 3NF or 5NF, to obtain a good table. 3.Ensure that you are using unique primary key. dont use product id or even some kind of data value as primary key. you will regret it soon. create a new field like product_primary with INT as the base, from 0 or 1 counting up. that's it for now. (no more ideas  ) |
|  | | Lance Administrator


Number of posts: 779 Registration date: 2008-06-21 Points: 975 Reputation: 1
Character Recognitions Special Status: Nil
Awards & Medals:

  
 | Subject: Re: Lunan Programming Corner (XHTML,CSS,ASP.NET,C#,MYSQL) Wed Jun 17, 2009 12:47 pm | |
| Free lesson? XD _________________ No one knows everything, and everyone knows something a bit different from others. We are all teaching each other as we go along. - James Nachtwey
|
|  | | lunan Junior Member

Number of posts: 258 Course / Major: IT in Computing Registration date: 2008-08-18 Points: 771 Reputation: 1
 | Subject: Re: Lunan Programming Corner (XHTML,CSS,ASP.NET,C#,MYSQL) Wed Jun 17, 2009 1:13 pm | |
| sure why not?im just sharing how life of a developer XD more like...sharing the code and good practices...why quite lack in swinburne (they still teach table based layout at WWW internet...) will put some tutorial and lesson too...if i have time (holiday comin soon and me without internet). probably i'll compile the article first,then bam, when comin back, post all the articles  i create this place coz there's no place to share knowledge at swinburne, especially IT  will post some of the project i done too (while i work part time and several library and assignment) but 1 thing though, this was not meant to replace your teacher, or lecture  just supplemental. also, you are free to ask, and i'll do what i can to help you  |
|  | | Lance Administrator


Number of posts: 779 Registration date: 2008-06-21 Points: 975 Reputation: 1
Character Recognitions Special Status: Nil
Awards & Medals:

  
 | Subject: Re: Lunan Programming Corner (XHTML,CSS,ASP.NET,C#,MYSQL) Wed Jun 17, 2009 5:01 pm | |
| Keep it up lunan! It's good for one to put lots of effort in the things you like to do~ Too bad my interest is not in the same field as yours. _________________ No one knows everything, and everyone knows something a bit different from others. We are all teaching each other as we go along. - James Nachtwey
|
|  | | mandy New Member

Number of posts: 22 Course / Major: Marketing Registration date: 2009-09-26 Points: 351 Reputation: -20
 | Subject: Re: Lunan Programming Corner (XHTML,CSS,ASP.NET,C#,MYSQL) Sat Sep 26, 2009 7:33 pm | |
| |
|  | | | | Lunan Programming Corner (XHTML,CSS,ASP.NET,C#,MYSQL) | |
|
| Page 1 of 1 |
| | Permissions of this forum: | You cannot reply to topics in this forum
| |
| |
| |