Exemple #1
0
		public MySqlDataReader Search(ClosingItemStatus ClosingItemstatus, string SearchKey, string SortField, SortOption SortOrder)
		{
			try
			{
				string SQL = "SELECT " +
								"ClosingItemID, " +
								"ClosingID, " +
								"ProductID, " +
								"ProductCode, " +
								"BarCode, " +
								"Description, " +
								"ProductUnitID, " +
								"ProductUnitCode, " +
								"Quantity, " +
								"UnitCost, " +
								"Discount, " +
								"InPercent, " +
								"TotalDiscount, " +
								"Amount, " +
								"VAT, " +
								"VatableAmount, " +
								"EVAT, " +
								"EVatableAmount, " +
								"LocalTax, " +
								"VariationMatrixID, " +
								"MatrixDescription, " +
								"ProductGroup, " +
								"ProductSubGroup, " +
								"ClosingItemStatus, " +
								"IsVatable, " +
								"Remarks " +
							"FROM tblClosingItems " +
								"WHERE (ProductCode LIKE @SearchKey or BarCode LIKE @SearchKey or Description LIKE @SearchKey " +
									"or MatrixDescription LIKE @SearchKey or ProductGroup LIKE @SearchKey or ProductSubGroup LIKE @SearchKey " +
									"or Remarks LIKE @SearchKey) " +
							"ORDER BY " + SortField;

				if (SortOrder == SortOption.Ascending)
					SQL += " ASC";
				else
					SQL += " DESC";

				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;
				
				MySqlParameter prmClosingItemStatus = new MySqlParameter("@ClosingItemStatus",MySqlDbType.Int16);			
				prmClosingItemStatus.Value = ClosingItemstatus.ToString("d");
				cmd.Parameters.Add(prmClosingItemStatus);

				MySqlParameter prmSearchKey = new MySqlParameter("@SearchKey",MySqlDbType.String);
				prmSearchKey.Value = "%" + SearchKey + "%";
				cmd.Parameters.Add(prmSearchKey);

				MySqlDataReader myReader = base.ExecuteReader(cmd);
				
				return myReader;			
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}		
Exemple #2
0
        public MySqlDataReader Search(ClosingItemStatus ClosingItemstatus, string SearchKey, string SortField, SortOption SortOrder)
        {
            try
            {
                string SQL = "SELECT " +
                             "ClosingItemID, " +
                             "ClosingID, " +
                             "ProductID, " +
                             "ProductCode, " +
                             "BarCode, " +
                             "Description, " +
                             "ProductUnitID, " +
                             "ProductUnitCode, " +
                             "Quantity, " +
                             "UnitCost, " +
                             "Discount, " +
                             "InPercent, " +
                             "TotalDiscount, " +
                             "Amount, " +
                             "VAT, " +
                             "VatableAmount, " +
                             "EVAT, " +
                             "EVatableAmount, " +
                             "LocalTax, " +
                             "VariationMatrixID, " +
                             "MatrixDescription, " +
                             "ProductGroup, " +
                             "ProductSubGroup, " +
                             "ClosingItemStatus, " +
                             "IsVatable, " +
                             "Remarks " +
                             "FROM tblClosingItems " +
                             "WHERE (ProductCode LIKE @SearchKey or BarCode LIKE @SearchKey or Description LIKE @SearchKey " +
                             "or MatrixDescription LIKE @SearchKey or ProductGroup LIKE @SearchKey or ProductSubGroup LIKE @SearchKey " +
                             "or Remarks LIKE @SearchKey) " +
                             "ORDER BY " + SortField;

                if (SortOrder == SortOption.Ascending)
                {
                    SQL += " ASC";
                }
                else
                {
                    SQL += " DESC";
                }

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                MySqlParameter prmClosingItemStatus = new MySqlParameter("@ClosingItemStatus", MySqlDbType.Int16);
                prmClosingItemStatus.Value = ClosingItemstatus.ToString("d");
                cmd.Parameters.Add(prmClosingItemStatus);

                MySqlParameter prmSearchKey = new MySqlParameter("@SearchKey", MySqlDbType.String);
                prmSearchKey.Value = "%" + SearchKey + "%";
                cmd.Parameters.Add(prmSearchKey);

                MySqlDataReader myReader = base.ExecuteReader(cmd);

                return(myReader);
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }