public static CBE.ProvinceCBE GetProvinceById(CBE.ProvinceCBE Province) { try { CBE.ProvinceCBECollection Provinces = new CBE.ProvinceCBECollection(); string spName = Constants.oraclePackagePrefix + "PROVINCE_GETBYID"; DbCommand command = VaaaN.MLFF.Libraries.CommonLibrary.DBA.DBAccessor.GetStoredProcCommand(spName); command.Parameters.Add(VaaaN.MLFF.Libraries.CommonLibrary.DBA.DBAccessor.CreateDbParameter(ref command, "P_PROVINCE_ID", DbType.Int32, Province.ProvinceId, ParameterDirection.Input)); Provinces = ConvertDataTableToCollection(VaaaN.MLFF.Libraries.CommonLibrary.DBA.DBAccessor.LoadDataSet(command, tableName).Tables[tableName]); return(Provinces[0]); } catch (Exception ex) { throw ex; } }
private static int GetNextValue() { //next value will be 1 if there is no row in the datatable. int nextValue = 1; try { //Get object collection CBE.ProvinceCBECollection objs = GetAll(); //Get all objects Id int[] sortedObjsId = new int[objs.Count]; for (int i = 0; i < objs.Count; i++) { sortedObjsId[i] = objs[i].ProvinceId; } //Sort the object id Array.Sort(sortedObjsId); for (int j = 0; j < sortedObjsId.Length; j++) { if (j + 1 < sortedObjsId.Length) { if (sortedObjsId[j] + 1 < sortedObjsId[j + 1]) { nextValue = sortedObjsId[j] + 1; break; } } else { nextValue = sortedObjsId[sortedObjsId.Length - 1] + 1; } } } catch (Exception ex) { throw ex; } return(nextValue); }
public static VaaaN.MLFF.Libraries.CommonLibrary.CBE.ProvinceCBECollection GetAll() { VaaaN.MLFF.Libraries.CommonLibrary.CBE.ProvinceCBECollection provinces = new CBE.ProvinceCBECollection(); try { //Stored procedure must have cur_out parameter. //There is no need to add ref cursor for oracle in code. string spName = VaaaN.MLFF.Libraries.CommonLibrary.Constants.oraclePackagePrefix + "PROVINCE_GETALL"; DbCommand command = VaaaN.MLFF.Libraries.CommonLibrary.DBA.DBAccessor.GetStoredProcCommand(spName); DataSet ds = VaaaN.MLFF.Libraries.CommonLibrary.DBA.DBAccessor.LoadDataSet(command, tableName); DataTable dt = ds.Tables[tableName]; provinces = ConvertDataTableToCollection(dt); } catch (Exception ex) { throw ex; } return(provinces); }