/// <summary> /// Method to Get List of HostelStrDetails /// </summary> /// <param name="argEn">HostelStrDetails Entity is an Input.</param> /// <returns>Returns List of HostelStrDetails</returns> public List <HostelStrDetailsEn> GetList(HostelStrDetailsEn argEn) { List <HostelStrDetailsEn> loEnList = new List <HostelStrDetailsEn>(); string sqlCmd = "select * from SAS_HostelStrDetails"; try { if (!FormHelp.IsBlank(sqlCmd)) { using (IDataReader loReader = _DatabaseFactory.ExecuteReader(Helper.GetDataBaseType, DataBaseConnectionString, sqlCmd).CreateDataReader()) { while (loReader.Read()) { HostelStrDetailsEn loItem = LoadObject(loReader); loEnList.Add(loItem); } loReader.Close(); } } } catch (Exception ex) { throw ex; } return(loEnList); }
/// <summary> /// Method to Delete HostelStrDetails /// </summary> /// <param name="argEn">HostelStrDetails Entity is an Input.</param> /// <returns>Returns Boolean</returns> public bool Delete(HostelStrDetailsEn argEn) { bool lbRes = false; string sqlCmd = "DELETE FROM SAS_HostelStrDetails WHERE SAHS_Code = @SAHS_Code"; try { if (!FormHelp.IsBlank(sqlCmd)) { DbCommand cmd = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString); _DatabaseFactory.AddInParameter(ref cmd, "@SAHS_Code", DbType.String, argEn.HSCode); _DbParameterCollection = cmd.Parameters; int liRowAffected = _DatabaseFactory.ExecuteNonQuery(Helper.GetDataBaseType, cmd, DataBaseConnectionString, sqlCmd, _DbParameterCollection); if (liRowAffected > -1) { lbRes = true; } else { throw new Exception("Deletion Failed! No Row has been updated..."); } } } catch (Exception ex) { throw ex; } return(lbRes); }
/// <summary> /// Method to Get HostelStrDetails Entity /// </summary> /// <param name="argEn">HostelStrDetails Entity is an Input.HSCode as Input Property.</param> /// <returns>Returns HostelStrDetails Entity</returns> public HostelStrDetailsEn GetItem(HostelStrDetailsEn argEn) { HostelStrDetailsEn loItem = new HostelStrDetailsEn(); string sqlCmd = "Select * FROM SAS_HostelStrDetails WHERE SAHS_Code = @SAHS_Code"; try { if (!FormHelp.IsBlank(sqlCmd)) { DbCommand cmd = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString); _DatabaseFactory.AddInParameter(ref cmd, "@SAHS_Code", DbType.String, argEn.HSCode); _DbParameterCollection = cmd.Parameters; using (IDataReader loReader = _DatabaseFactory.GetIDataReader(Helper.GetDataBaseType, cmd, DataBaseConnectionString, sqlCmd, _DbParameterCollection).CreateDataReader()) { if (loReader != null) { loReader.Read(); loItem = LoadObject(loReader); } loReader.Close(); } } } catch (Exception ex) { throw ex; } return(loItem); }
/// <summary> /// Method to Get HostelStrDetails Entity /// </summary> /// <param name="argEn">HostelStrDetails Entity is an Input.HSCode as Input Property.</param> /// <returns>Returns HostelStrDetails Entity</returns> public HostelStrDetailsEn GetItem(HostelStrDetailsEn argEn) { try { HostelStrDetailsDAL loDs = new HostelStrDetailsDAL(); return(loDs.GetItem(argEn)); } catch (Exception ex) { throw ex; } }
/// <summary> /// Method to Get List of HostelStrDetails /// </summary> /// <param name="argEn">HostelStrDetails Entity is an Input.</param> /// <returns>Returns List of HostelStrDetails</returns> public List <HostelStrDetailsEn> GetList(HostelStrDetailsEn argEn) { try { HostelStrDetailsDAL loDs = new HostelStrDetailsDAL(); return(loDs.GetList(argEn)); } catch (Exception ex) { throw ex; } }
/// <summary> /// Method to Load HostelStrDetails Entity /// </summary> /// <param name="argReader">IDataReader Object is an Input.</param> /// <returns>Returns HostelStrDetails Entity</returns> private HostelStrDetailsEn LoadObject(IDataReader argReader) { HostelStrDetailsEn loItem = new HostelStrDetailsEn(); loItem.HSCode = GetValue <string>(argReader, "SAHS_Code"); loItem.HDCode = GetValue <string>(argReader, "SAHD_Code"); loItem.FTCode = GetValue <string>(argReader, "SAFT_Code"); loItem.HDType = GetValue <string>(argReader, "SAHD_Type"); loItem.HDPriority = GetValue <int>(argReader, "SAHD_Priority"); return(loItem); }
/// <summary> /// Method to Update HostelStrDetails /// </summary> /// <param name="argEn">HostelStrDetails Entity is an Input.</param> /// <returns>Returns Boolean</returns> public bool Update(HostelStrDetailsEn argEn) { bool flag; using (TransactionScope ts = new TransactionScope()) { try { HostelStrDetailsDAL loDs = new HostelStrDetailsDAL(); flag = loDs.Update(argEn); ts.Complete(); } catch (Exception ex) { throw ex; } } return(flag); }
/// <summary> /// Method to Check Validation /// </summary> /// <param name="argEn">HostelStrDetails Entity is as Input.</param> /// <returns>Returns a Boolean</returns> public bool IsValid(HostelStrDetailsEn argEn) { try { if (argEn.HSCode == null || argEn.HSCode.ToString().Length <= 0) { throw new Exception("HSCode Is Required!"); } if (argEn.FTCode == null || argEn.FTCode.ToString().Length <= 0) { throw new Exception("FTCode Is Required!"); } return(true); } catch (Exception ex) { throw ex; } }
/// <summary> /// Method to Get List of Hostel Amounts /// </summary> /// <param name="argEn">HostelStrDetails Entity is an Input.HSCode as input Property</param> /// <returns>Returns List of HostelStrDetails</returns> public List <HostelStrDetailsEn> GetHostelAmtList(HostelStrDetailsEn argEn) { List <HostelStrDetailsEn> loEnList = new List <HostelStrDetailsEn>(); string sqlCmd = "SELECT SAS_HostelStrDetails.*, SAS_FeeTypes.SAFT_Desc " + "FROM SAS_HostelStrDetails INNER JOIN SAS_FeeTypes ON SAS_HostelStrDetails.SAFT_Code = SAS_FeeTypes.SAFT_Code " + "WHERE SAS_HostelStrDetails.SAHS_Code = @SAHS_Code"; try { if (!FormHelp.IsBlank(sqlCmd)) { DbCommand cmd = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString); _DatabaseFactory.AddInParameter(ref cmd, "@SAHS_Code", DbType.String, argEn.HSCode); _DbParameterCollection = cmd.Parameters; using (IDataReader loReader = _DatabaseFactory.GetIDataReader(Helper.GetDataBaseType, cmd, DataBaseConnectionString, sqlCmd, _DbParameterCollection).CreateDataReader()) { HostelStrAmountDAL loHostelStrAmt = new HostelStrAmountDAL(); HostelStrAmountEn loHostelStrAmtEn = new HostelStrAmountEn(); while (loReader.Read()) { HostelStrDetailsEn loItem = LoadObject(loReader); loItem.Description = GetValue <string>(loReader, "SAFT_Desc"); loHostelStrAmtEn.HSCode = loItem.HSCode; loHostelStrAmtEn.FTCode = loItem.FTCode; //getting the list of Hostel FeeAmounts loItem.ListFeeAmount = loHostelStrAmt.GetDescList(loHostelStrAmtEn); loEnList.Add(loItem); } loReader.Close(); } } } catch (Exception ex) { throw ex; } return(loEnList); }
/// <summary> /// Method to Insert HostelStrDetails /// </summary> /// <param name="argEn">HostelStrDetails Entity is an Input.</param> /// <returns>Returns Boolean</returns> public bool Insert(HostelStrDetailsEn argEn) { bool lbRes = false; //int iOut = 0; try { string sqlCmd = "INSERT INTO SAS_HostelStrDetails(SAHS_Code,SAHD_Code,SAFT_Code,SAHD_Type,SAHD_Priority, safs_taxmode) VALUES (@SAHS_Code,@SAHD_Code,@SAFT_Code,@SAHD_Type,@SAHD_Priority, @safs_taxmode) "; if (!FormHelp.IsBlank(sqlCmd)) { DbCommand cmd = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString); _DatabaseFactory.AddInParameter(ref cmd, "@SAHS_Code", DbType.String, clsGeneric.NullToString(argEn.HSCode)); _DatabaseFactory.AddInParameter(ref cmd, "@SAHD_Code", DbType.String, clsGeneric.NullToString(argEn.HDCode)); _DatabaseFactory.AddInParameter(ref cmd, "@SAFT_Code", DbType.String, clsGeneric.NullToString(argEn.FTCode)); _DatabaseFactory.AddInParameter(ref cmd, "@SAHD_Type", DbType.String, clsGeneric.NullToString(argEn.HDType)); _DatabaseFactory.AddInParameter(ref cmd, "@SAHD_Priority", DbType.Int32, clsGeneric.NullToInteger(argEn.HDPriority)); _DatabaseFactory.AddInParameter(ref cmd, "@safs_taxmode", DbType.Int32, clsGeneric.NullToInteger(argEn.TaxId)); _DbParameterCollection = cmd.Parameters; int liRowAffected = _DatabaseFactory.ExecuteNonQuery(Helper.GetDataBaseType, cmd, DataBaseConnectionString, sqlCmd, _DbParameterCollection); if (liRowAffected > -1) { lbRes = true; } else { throw new Exception("Insertion Failed! No Row has been updated..."); } } } catch (Exception ex) { throw ex; } return(lbRes); }
/// <summary> /// Method to Get List of Active or Inactive Hostels /// </summary> /// <param name="argEn">HostelStructure Entity is an Input.RoomType,Code,Block and Status are Input Properties.</param> /// <returns>Returns List of HostelStructure</returns> public List <HostelStructEn> GetHostelList(HostelStructEn argEn) { List <HostelStructEn> loEnList = new List <HostelStructEn>(); argEn.RoomTYpe = argEn.RoomTYpe.Replace("*", "%"); argEn.Code = argEn.Code.Replace("*", "%"); argEn.Block = argEn.Block.Replace("*", "%"); string sqlCmd = "select * from SAS_HostelStruct WHERE SAHS_Code <> '0'"; if (argEn.RoomTYpe.Length != 0) { sqlCmd = sqlCmd + " and SAHB_RoomTYpe like '" + argEn.RoomTYpe + "'"; } if (argEn.Code.Length != 0) { sqlCmd = sqlCmd + " and SAHB_Code like '" + argEn.Code + "'"; } if (argEn.Block.Length != 0) { sqlCmd = sqlCmd + " and SAHB_Block like '" + argEn.Block + "'"; } //if (argEn.Status == true) sqlCmd = sqlCmd + " and SAFS_Status = 1"; if (argEn.Status == true) { sqlCmd = sqlCmd + " and SAFS_Status = true"; } //if (argEn.Status == false) sqlCmd = sqlCmd + " and SAFS_Status = 0 "; if (argEn.Status == false) { sqlCmd = sqlCmd + " and SAFS_Status = false "; } try { if (!FormHelp.IsBlank(sqlCmd)) { HostelStrDetailsEn loHostelStrDetEn = new HostelStrDetailsEn(); HostelStrDetailsDAL loHostelStrDet = new HostelStrDetailsDAL(); using (IDataReader loReader = _DatabaseFactory.ExecuteReader(Helper.GetDataBaseType, DataBaseConnectionString, sqlCmd).CreateDataReader()) { while (loReader.Read()) { HostelStructEn loItem = LoadObject(loReader); loHostelStrDetEn.HSCode = loItem.HostelStructureCode; loItem.lstHFeeSD = loHostelStrDet.GetHostelAmtList(loHostelStrDetEn); loEnList.Add(loItem); } loReader.Close(); } } } catch (Exception ex) { throw ex; } return(loEnList); }
/// <summary> /// Method to Update HostelStrDetails /// </summary> /// <param name="argEn">HostelStrDetails Entity is an Input.</param> /// <returns>Returns Boolean</returns> public bool Update(HostelStrDetailsEn argEn) { bool lbRes = false; int iOut = 0; string sqlCmd = "Select count(*) as cnt From SAS_HostelStrDetails WHERE SAHS_Code = @SAHS_Code"; try { if (!FormHelp.IsBlank(sqlCmd)) { DbCommand cmdSel = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString); _DatabaseFactory.AddInParameter(ref cmdSel, "@SAHS_Code", DbType.String, argEn.HSCode); _DbParameterCollection = cmdSel.Parameters; using (IDataReader dr = _DatabaseFactory.GetIDataReader(Helper.GetDataBaseType, cmdSel, DataBaseConnectionString, sqlCmd, _DbParameterCollection).CreateDataReader()) { if (dr.Read()) { iOut = clsGeneric.NullToInteger(dr["cnt"]); } if (iOut > 0) { throw new Exception("Record Already Exist"); } } if (iOut == 0) { sqlCmd = "UPDATE SAS_HostelStrDetails SET SAHS_Code = @SAHS_Code, SAHD_Code = @SAHD_Code, SAFT_Code = @SAFT_Code, SAHD_Type = @SAHD_Type, SAHD_Priority = @SAHD_Priority WHERE SAHS_Code = @SAHS_Code"; if (!FormHelp.IsBlank(sqlCmd)) { DbCommand cmd = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString); _DatabaseFactory.AddInParameter(ref cmd, "@SAHS_Code", DbType.String, argEn.HSCode); _DatabaseFactory.AddInParameter(ref cmd, "@SAHD_Code", DbType.String, argEn.HDCode); _DatabaseFactory.AddInParameter(ref cmd, "@SAFT_Code", DbType.String, argEn.FTCode); _DatabaseFactory.AddInParameter(ref cmd, "@SAHD_Type", DbType.String, argEn.HDType); _DatabaseFactory.AddInParameter(ref cmd, "@SAHD_Priority", DbType.Int32, argEn.HDPriority); _DbParameterCollection = cmd.Parameters; int liRowAffected = _DatabaseFactory.ExecuteNonQuery(Helper.GetDataBaseType, cmd, DataBaseConnectionString, sqlCmd, _DbParameterCollection); if (liRowAffected > -1) { lbRes = true; } else { throw new Exception("Update Failed! No Row has been updated..."); } } } } } catch (Exception ex) { throw ex; } return(lbRes); }