public bool Available(string id, Enums.IDType IDType) { string SQLCommand = string.Empty; DataTable dt = new DataTable(); switch (IDType) { case Enums.IDType.CLNT: SQLCommand = "select * from client where id = '" + IDType.ToString() + id + "'"; break; case Enums.IDType.INVO: SQLCommand = "select * from invoice where id = '" + IDType.ToString() + id + "'"; break; case Enums.IDType.MANF: SQLCommand = "select * from manufacturer where id = '" + IDType.ToString() + id + "'"; break; case Enums.IDType.PROD: SQLCommand = "select * from product where id = '" + IDType.ToString() + id + "'"; break; case Enums.IDType.PUOR: SQLCommand = "select * from purchaseorder where id = '" + IDType.ToString() + id + "'"; break; case Enums.IDType.SUPP: SQLCommand = "select * from supplier where id = '" + IDType.ToString() + id + "'"; break; case Enums.IDType.USER: SQLCommand = "select * from user where id = '" + IDType.ToString() + id + "'"; break; case Enums.IDType.CONT: SQLCommand = "select * from contact where id = '" + IDType.ToString() + id + "'"; break; } if (db.SQLQuery(ref dt, SQLCommand)) { if (dt.Rows.Count > 0) { return(true); } else { return(false); } } else { return(false); } }
public static List <string> SelectAll(Enums.IDType IDType) { List <string> ListOfManufactuer = new List <string>(); DataTable dt = new DataTable(); string SQLCommand = string.Empty; switch (IDType) { case Enums.IDType.CLNT: SQLCommand = "Select ID from client"; break; case Enums.IDType.INVO: SQLCommand = "Select concat(name,'(',ID,')') manu from invoice"; break; case Enums.IDType.MANF: SQLCommand = "Select concat(name,'(',ID,')') manu from Manufacturer"; break; case Enums.IDType.PROD: SQLCommand = "Select concat(name,'(',ID,')') manu from product"; break; case Enums.IDType.PUOR: SQLCommand = "Select ID manu from OrderReceived"; break; case Enums.IDType.SUPP: SQLCommand = "Select concat(name,'(',ID,')') manu from Supplier"; break; case Enums.IDType.USER: SQLCommand = "Select concat(username,'(',ID,')') manu from User"; break; case Enums.IDType.CONT: SQLCommand = "Select concat(name,'(',ID,')') manu from Contacts"; break; } if (db.SQLQuery(ref dt, SQLCommand)) { foreach (DataRow dr in dt.Rows) { ListOfManufactuer.Add(dr[0].ToString()); } } return(ListOfManufactuer); }
public static DataTable Select(Enums.IDType idType, string ID) { DataTable dt = new DataTable(); string SQLCommand = string.Empty; switch (idType) { case Enums.IDType.CLNT: SQLCommand = "select* from client where id = '" + ID + "'"; break; case Enums.IDType.INVO: SQLCommand = "Select * from invoice where id = '" + ID + "'"; break; case Enums.IDType.MANF: SQLCommand = "Select * from Manufacturer where id = '" + ID + "'"; break; case Enums.IDType.PROD: SQLCommand = "Select * from product where id = '" + ID + "'"; break; case Enums.IDType.PUOR: SQLCommand = "Select * from OrderReceived where id = '" + ID + "'"; break; case Enums.IDType.SUPP: SQLCommand = "Select * from Supplier where id = '" + ID + "'"; break; case Enums.IDType.USER: SQLCommand = "Select username,role from User where id = '" + ID + "'"; break; case Enums.IDType.CONT: SQLCommand = "Select * from Contacts where id = '" + ID + "'"; break; } db.SQLQuery(ref dt, SQLCommand); return(dt); }
public static string Get(Enums.IDType idType) { var chars = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var random = new Random(); var result = new string( Enumerable.Repeat(chars, 5) .Select(s => s[random.Next(s.Length)]) .ToArray()); GenerateID dig = new GenerateID(); if (dig.Available(result, idType)) { return(Get(idType)); } else { return(idType.ToString() + result); } }