public System.Data.DataTable ListAsDataTable(BranchInventoryColumns clsBranchInventoryColumns, BranchInventoryColumns SearchColumns, int BranchID, long ProductID, string SortField, System.Data.SqlClient.SortOrder SortOrder) { string SQL = SQLSelect(clsBranchInventoryColumns); if (BranchID != 0) { SQL += "AND tblBranchInventory.BranchID = @BranchID "; } if (ProductID != 0) { SQL += "AND tblBranchInventory.ProductID = @ProductID "; } if (SortField != string.Empty && SortField != null) { SQL += "ORDER BY " + SortField + " "; if (SortOrder != System.Data.SqlClient.SortOrder.Descending) { SQL += "ASC "; } else { SQL += "DESC "; } } MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; if (BranchID != 0) { cmd.Parameters.AddWithValue("@BranchID", BranchID); } if (ProductID != 0) { cmd.Parameters.AddWithValue("@ProductID", ProductID); } System.Data.DataTable dt = new System.Data.DataTable("tblBranch"); base.MySqlDataAdapterFill(cmd, dt); return(dt); }
private string SQLSelect(BranchInventoryColumns clsBranchInventoryColumns) { string stSQL = "SELECT "; if (clsBranchInventoryColumns.BranchInventoryID) { stSQL += "tblBranchInventory." + BranchInventoryColumnNames.BranchInventoryID + ", "; } if (clsBranchInventoryColumns.ProductID) { stSQL += "tblBranchInventory." + BranchInventoryColumnNames.ProductID + ", "; } if (clsBranchInventoryColumns.ProductCode) { stSQL += "tblBranchInventory." + BranchInventoryColumnNames.ProductCode + ", "; } if (clsBranchInventoryColumns.VariationMatrixID) { stSQL += "tblBranchInventory." + BranchInventoryColumnNames.VariationMatrixID + ", "; } if (clsBranchInventoryColumns.MatrixDescription) { stSQL += "tblBranchInventory." + BranchInventoryColumnNames.MatrixDescription + ", "; } if (clsBranchInventoryColumns.Quantity) { stSQL += "tblBranchInventory." + BranchInventoryColumnNames.Quantity + ", "; } if (clsBranchInventoryColumns.Quantity) { stSQL += "fnProductQuantityConvert(tblBranchInventory.ProductID, tblBranchInventory." + BranchInventoryColumnNames.Quantity + ", 0) AS ConvertedQuantity, "; } if (clsBranchInventoryColumns.BranchCode) { stSQL += "tblBranch." + BranchInventoryColumnNames.BranchCode + ", "; } stSQL += "tblBranchInventory.BranchID FROM tblBranchInventory "; if (clsBranchInventoryColumns.BranchCode) { stSQL += "INNER JOIN tblBranch ON tblBranchInventory.BranchID = tblBranch.BranchID "; } return(stSQL); }
public System.Data.DataTable ListAsDataTable(BranchInventoryColumns clsBranchInventoryColumns, BranchInventoryColumns SearchColumns, int BranchID, long ProductID, string SortField, System.Data.SqlClient.SortOrder SortOrder) { string SQL = SQLSelect(clsBranchInventoryColumns); if (BranchID != 0) SQL += "AND tblBranchInventory.BranchID = @BranchID "; if (ProductID != 0) SQL += "AND tblBranchInventory.ProductID = @ProductID "; if (SortField != string.Empty && SortField != null) { SQL += "ORDER BY " + SortField + " "; if (SortOrder != System.Data.SqlClient.SortOrder.Descending) SQL += "ASC "; else SQL += "DESC "; } MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; if (BranchID != 0) cmd.Parameters.AddWithValue("@BranchID", BranchID); if (ProductID != 0) cmd.Parameters.AddWithValue("@ProductID", ProductID); System.Data.DataTable dt = new System.Data.DataTable("tblBranch"); base.MySqlDataAdapterFill(cmd, dt); return dt; }
private string SQLSelect(BranchInventoryColumns clsBranchInventoryColumns) { string stSQL = "SELECT "; if (clsBranchInventoryColumns.BranchInventoryID) stSQL += "tblBranchInventory." + BranchInventoryColumnNames.BranchInventoryID + ", "; if (clsBranchInventoryColumns.ProductID) stSQL += "tblBranchInventory." + BranchInventoryColumnNames.ProductID + ", "; if (clsBranchInventoryColumns.ProductCode) stSQL += "tblBranchInventory." + BranchInventoryColumnNames.ProductCode + ", "; if (clsBranchInventoryColumns.VariationMatrixID) stSQL += "tblBranchInventory." + BranchInventoryColumnNames.VariationMatrixID + ", "; if (clsBranchInventoryColumns.MatrixDescription) stSQL += "tblBranchInventory." + BranchInventoryColumnNames.MatrixDescription + ", "; if (clsBranchInventoryColumns.Quantity) stSQL += "tblBranchInventory." + BranchInventoryColumnNames.Quantity + ", "; if (clsBranchInventoryColumns.Quantity) stSQL += "fnProductQuantityConvert(tblBranchInventory.ProductID, tblBranchInventory." + BranchInventoryColumnNames.Quantity + ", 0) AS ConvertedQuantity, "; if (clsBranchInventoryColumns.BranchCode) stSQL += "tblBranch." + BranchInventoryColumnNames.BranchCode + ", "; stSQL += "tblBranchInventory.BranchID FROM tblBranchInventory "; if (clsBranchInventoryColumns.BranchCode) stSQL += "INNER JOIN tblBranch ON tblBranchInventory.BranchID = tblBranch.BranchID "; return stSQL; }