public List <Design> getDesignByName(string designName) { DatabaseOperations operations = new DatabaseOperations(); DataTable designs = operations.executeSelectQuery("SELECT * FROM Design WHERE Design.DesignName LIKE '" + designName + "%'"); List <Design> designList = new List <Design>(); foreach (DataRow dr in designs.Rows) { Design d = new Design(); d.DesignID = dr[0].ToString(); d.DesignName = dr[1].ToString(); d.DesignFile = (byte[])dr[2]; string paperTypeName = operations.executeSelectQuery("SELECT PaperTypeName FROM PaperType WHERE PaperType.PaperTypeID=" + dr[5].ToString()).Rows[0][0].ToString(); d.DesignPaperType = paperTypeName; d.DesignSize = dr[6].ToString(); designList.Add(d); } return(designList); }
public List <Design> getAllDesigns(string productName) { DatabaseOperations operations = new DatabaseOperations(); int productID = int.Parse(operations.executeSelectQuery("SELECT ProductID FROM Product WHERE Product.ProductName='" + productName + "'").Rows[0][0].ToString()); DataTable designs = operations.executeSelectQuery("SELECT * FROM Design WHERE Design.ProductID=" + productID); List <Design> designList = new List <Design>(); foreach (DataRow dr in designs.Rows) { Design d = new Design(); d.DesignID = dr[0].ToString(); d.DesignName = dr[1].ToString(); d.DesignFile = (byte[])dr[2]; string paperTypeName = operations.executeSelectQuery("SELECT PaperTypeName FROM PaperType WHERE PaperType.PaperTypeID=" + dr[5].ToString()).Rows[0][0].ToString(); d.DesignPaperType = paperTypeName; d.DesignSize = dr[6].ToString(); designList.Add(d); } return(designList); }
public bool saveDesign(Design d) { try { DatabaseOperations operations = new DatabaseOperations(); int paperTypeID = int.Parse(operations.executeSelectQuery("SELECT PaperTypeID FROM PaperType WHERE PaperType.PaperTypeName='" + d.DesignPaperType + "'").Rows[0][0].ToString()); int productID = int.Parse(operations.executeSelectQuery("SELECT ProductID FROM Product WHERE Product.ProductName='" + d.ProductName + "'").Rows[0][0].ToString()); int i = operations.executeInsUpdDelQuery("INSERT INTO Design (DesignID, DesignName, ProductID, PaperTypeID, Size) VALUES('" + d.DesignID + "','" + d.DesignName + "'," + productID + "," + paperTypeID + ",'" + d.DesignSize + "')"); int j = operations.executeUpdImageQuery("Design", "DesignFile", d.DesignFilePath, "DesignID", d.DesignID); if (i == 1 && j == 1) { return(true); } else { return(false); } } catch (Exception ex) { return(false); } }