Tuesday, July 17, 2012

Using Entities in IList


BL Method which return Collective List objects
///
/// To Fetch the User Name & Code from DB
///

///
public List> GetLOBStationAccountUser(LOBStationAccountMap objLOBStationAccountMap)
{
List> lstCusomterALL = null; List lstSelectedAccount = null; List lstAvailablAccount = null; List lstCustomerAccount = null; SqlParameter[] ObjSqlParam = new SqlParameter[3]; string connString = SqlHelper.GetConnectionString(); //SqlConnection con = null; SqlDataReader dr = null; try { ObjSqlParam[0] = new SqlParameter("@ProductLobID", objLOBStationAccountMap.ProductLobID); ObjSqlParam[1] = new SqlParameter("@StationID", objLOBStationAccountMap.StationID == 0 ? System.Data.SqlTypes.SqlInt32.Null : objLOBStationAccountMap.StationID); ObjSqlParam[2] = new SqlParameter("@CustAccntID", objLOBStationAccountMap.CustAcntIdArray.Trim().Equals(string.Empty)? System.Data.SqlTypes.SqlString.Null: objLOBStationAccountMap.CustAcntIdArray ); //con = new SqlConnection(connString); dr = SqlHelper.ExecuteReader(connString, CommandType.StoredProcedure, "[DBSP_IMP_Get_LOBStatnAccntUsrMap]", ObjSqlParam); lstAvailablAccount = new List(); if (dr.HasRows) { while (dr.Read()) { UserMaster objCustomerAccountMaster = new UserMaster(); objCustomerAccountMaster.UserID = Convert.ToInt32(dr["UserID"]); objCustomerAccountMaster.UserCodeName = Convert.ToString(dr["UserCodeName"]); objCustomerAccountMaster.UserName = Convert.ToString(dr["UserName"]); lstAvailablAccount.Add(objCustomerAccountMaster); } } lstSelectedAccount = new List(); if (dr.NextResult()) { while (dr.Read()) { UserMaster objCustomerAccountMaster = new UserMaster(); objCustomerAccountMaster.UserID = Convert.ToInt32(dr["UserID"]); objCustomerAccountMaster.UserCodeName = Convert.ToString(dr["UserCodeName"]); objCustomerAccountMaster.UserName = Convert.ToString(dr["UserName"]); lstSelectedAccount.Add(objCustomerAccountMaster); } } lstCustomerAccount = new List(); if (dr.NextResult()) { while (dr.Read()) { UserMaster objCustomerAccountMaster = new UserMaster(); objCustomerAccountMaster.UserID = Convert.ToInt32(dr["UserID"]); objCustomerAccountMaster.UsrCustomerAccountID = Convert.ToInt32(dr["CustomerAccountID"]); objCustomerAccountMaster.UsrLobStationAccountID = Convert.ToInt32(dr["LOBStationAccountID"]); lstCustomerAccount.Add(objCustomerAccountMaster); } } lstCusomterALL = new List>(); lstCusomterALL.Add(lstAvailablAccount); lstCusomterALL.Add(lstSelectedAccount); lstCusomterALL.Add(lstCustomerAccount); } catch (Exception ex) { throw ex; } finally { dr.Close(); dr.Dispose(); //con.Close(); }
return lstCusomterALL;
}

IList objects accessed in CS Page
List> lstUserAvail_Selected;
lstUserAvail_Selected = objImportsConfigurationBL.GetLOBStationAccountUser(objLOBStationAccountMap);
if (lstUserAvail_Selected != null) { if (lstUserAvail_Selected.Count > 0) { this.SetAvailExistUsers(lstUserAvail_Selected[0], lstAvailFrame); if (lstUserAvail_Selected[1].Count > 0) this.SetAvailExistUsers(lstUserAvail_Selected[1], lstSelectedFrame); //if ( lstUserAvail_Selected.Count > 1 && lstUserAvail_Selected[2].Count > 1) // this.SetMappedCustomerAccounts(lstUserAvail_Selected[2]); } }

No comments:

Post a Comment