Esempio n. 1
0
        //Created By : Jessica
        //Created Date :  19/02/16
        /// <summary>
        /// Method to Get List of Hostel Amounts
        /// </summary>
        /// <param name="argEn">HostelStruct Entity is an Input.HSCode as input Property</param>
        /// <returns>Returns List of HostelStruct</returns>
        public List <HostelStructEn> GetHostelDetailsAmtList(HostelStructEn argEn)
        {
            List <HostelStructEn> loEnList = new List <HostelStructEn>();
            string sqlCmd = @"
                            select  hsd.SAHS_Code , hsd.saft_code, hsd.sahd_priority,
                            hsd.safs_taxmode, ft.*,
                            local.saha_amount as Local_Amount, local.safa_gstamount as Local_GSTAmount, nonlocal.saha_amount as NonLocal_Amount, nonlocal.safa_gstamount as NonLocal_GSTAmount
                            , local.sasc_code as Local_Category, nonlocal.sasc_code as NonLocal_Category, hsd.sahd_type
                            from  sas_hostelstrDetails hsd 
                            inner join SAS_FeeTypes ft on ft.saft_code = hsd.saft_code
                            left join (select saha_amount,  safa_gstamount, sahs_code, saft_code, sasc_code from sas_hostelstrAmount where sas_hostelstrAmount.sasc_code in ('Local', 'W')  )as local on local.sahs_code = hsd.sahs_code and local.saft_code = hsd.saft_code
                            left join (select saha_amount,  safa_gstamount, sahs_code, saft_code, sasc_code from sas_hostelstrAmount where sas_hostelstrAmount.sasc_code in ('International', 'BW')  )as nonlocal on nonlocal.sahs_code = hsd.sahs_code and nonlocal.saft_code = hsd.saft_code
                            WHERE hsd.SAHS_Code = @SAHS_Code";

            sqlCmd = sqlCmd + " order by hsd.saft_code";

            try
            {
                if (!FormHelp.IsBlank(sqlCmd))
                {
                    DbCommand cmd = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString);
                    _DatabaseFactory.AddInParameter(ref cmd, "@SAHS_Code", DbType.String, argEn.HostelStructureCode);
                    _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())
                        {
                            HostelStructEn loItemDetails = new HostelStructEn();
                            loItemDetails.HostelStructureCode = GetValue <string>(loReader, "SAHS_Code");
                            loItemDetails.FTCode             = GetValue <string>(loReader, "saft_code");
                            loItemDetails.Description        = GetValue <string>(loReader, "saft_desc");
                            loItemDetails.LocalAmount        = GetValue <double>(loReader, "Local_Amount");
                            loItemDetails.LocalGSTAmount     = GetValue <double>(loReader, "Local_GSTAmount");
                            loItemDetails.NonLocalAmount     = GetValue <double>(loReader, "NonLocal_Amount");
                            loItemDetails.NonLocalGSTAmount  = GetValue <double>(loReader, "NonLocal_GSTAmount");
                            loItemDetails.TaxId              = GetValue <int>(loReader, "safs_taxmode");
                            loItemDetails.NonLocalTempAmount = loItemDetails.NonLocalAmount - loItemDetails.NonLocalGSTAmount;
                            loItemDetails.LocalTempAmount    = loItemDetails.LocalAmount - loItemDetails.LocalGSTAmount;
                            loItemDetails.LocalCategory      = GetValue <string>(loReader, "Local_Category");
                            loItemDetails.NonLocalCategory   = GetValue <string>(loReader, "NonLocal_Category");
                            loItemDetails.FeeCategory        = GetValue <string>(loReader, "sahd_type");
                            loItemDetails.Priority           = GetValue <int>(loReader, "sahd_priority");
                            loEnList.Add(loItemDetails);
                        }
                        loReader.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(loEnList);
        }
Esempio n. 2
0
        /// <summary>
        /// Method to Delete HostelStructure
        /// </summary>
        /// <param name="argEn">HostelStructure Entity is an Input.</param>
        /// <returns>Returns Boolean</returns>
        public bool Delete(HostelStructEn argEn)
        {
            bool   lbRes  = false;
            string sqlCmd = "DELETE FROM SAS_HostelStruct 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.HostelStructureCode);
                    _DbParameterCollection = cmd.Parameters;

                    HostelStrDetailsEn  loHstrDet    = new HostelStrDetailsEn();
                    HostelStrDetailsDAL loHstrDetDal = new HostelStrDetailsDAL();
                    HostelStrAmountEn   loHstrAmt    = new HostelStrAmountEn();
                    HostelStrAmountDAL  loHstAmtDal  = new HostelStrAmountDAL();
                    loHstrAmt.HSCode = argEn.HostelStructureCode;
                    loHstrDet.HSCode = argEn.HostelStructureCode;
                    loHstAmtDal.Delete(loHstrAmt);
                    loHstrDetDal.Delete(loHstrDet);

                    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);
        }
Esempio n. 3
0
        /// <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);
        }
Esempio n. 4
0
        /// <summary>
        /// Method to Insert HostelStructure
        /// </summary>
        /// <param name="argEn">HostelStructure Entity is an Input.</param>
        /// <returns>Returns Boolean</returns>
        //public bool Insert(HostelStructEn argEn)
        //{
        //    bool lbRes = false;
        //    int iOut = 0;
        //    string sqlCmd = "Select count(*) as cnt From SAS_HostelStruct WHERE SAHS_Code != @SAHS_Code and SAHB_Code=@SAHB_Code and SAHB_Block=@SAHB_Block and SAHB_RoomTYpe=@SAHB_RoomTYpe";
        //    try
        //    {
        //        if (!FormHelp.IsBlank(sqlCmd))
        //        {
        //            DbCommand cmdSel = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString);
        //            _DatabaseFactory.AddInParameter(ref cmdSel, "@SAHS_Code", DbType.String, argEn.HostelStructureCode);
        //            _DatabaseFactory.AddInParameter(ref cmdSel, "@SAHB_Block", DbType.String, argEn.Block);
        //            _DatabaseFactory.AddInParameter(ref cmdSel, "@SAHB_Code", DbType.String, argEn.Code);
        //            _DatabaseFactory.AddInParameter(ref cmdSel, "@SAHB_RoomTYpe", DbType.String, argEn.RoomTYpe);
        //            _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 = "INSERT INTO SAS_HostelStruct(SAHS_Code,SAHB_Code,SAHB_Block,SAHB_RoomTYpe,SAHS_EffectFm,SAFS_Status,SAHS_UpdatedUser,SAHS_UpdatedDtTm) VALUES (@SAHS_Code,@SAHB_Code,@SAHB_Block,@SAHB_RoomTYpe,@SAHS_EffectFm,@SAFS_Status,@SAHS_UpdatedUser,@SAHS_UpdatedDtTm) ";

        //            if (!FormHelp.IsBlank(sqlCmd))
        //            {

        //                argEn.HostelStructureCode = GetAutoNumber("HostelCode");
        //                DbCommand cmd = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString);
        //                _DatabaseFactory.AddInParameter(ref cmd, "@SAHS_Code", DbType.String, argEn.HostelStructureCode);
        //                _DatabaseFactory.AddInParameter(ref cmd, "@SAHB_Code", DbType.String, argEn.Code);
        //                _DatabaseFactory.AddInParameter(ref cmd, "@SAHB_Block", DbType.String, argEn.Block);
        //                _DatabaseFactory.AddInParameter(ref cmd, "@SAHB_RoomTYpe", DbType.String, argEn.RoomTYpe);
        //                _DatabaseFactory.AddInParameter(ref cmd, "@SAHS_EffectFm", DbType.String, argEn.EffectFm);
        //                _DatabaseFactory.AddInParameter(ref cmd, "@SAFS_Status", DbType.Boolean, argEn.Status);
        //                _DatabaseFactory.AddInParameter(ref cmd, "@SAHS_UpdatedUser", DbType.String, argEn.UpdatedUser);
        //                _DatabaseFactory.AddInParameter(ref cmd, "@SAHS_UpdatedDtTm", DbType.String, argEn.UpdatedDtTm);
        //                _DbParameterCollection = cmd.Parameters;

        //                int liRowAffected = _DatabaseFactory.ExecuteNonQuery(Helper.GetDataBaseType, cmd,
        //                        DataBaseConnectionString, sqlCmd, _DbParameterCollection);
        //                int i = 0;
        //                int j = 0;

        //                HostelStrDetailsDAL loHstrDal = new HostelStrDetailsDAL();
        //                HostelStrAmountDAL loHstrAmDal = new HostelStrAmountDAL();
        //                while (i < argEn.lstHFeeSD.Count)
        //                {
        //                    //inserting new hostel feeDetails
        //                    argEn.lstHFeeSD[i].HSCode = argEn.HostelStructureCode;
        //                    loHstrDal.Insert(argEn.lstHFeeSD[i]);
        //                    while (j < argEn.lstHFeeSD[i].ListFeeAmount.Count)
        //                    {
        //                        //inserting new hostel feeAmounts
        //                        argEn.lstHFeeSD[i].ListFeeAmount[j].HSCode = argEn.HostelStructureCode;
        //                        loHstrAmDal.Insert(argEn.lstHFeeSD[i].ListFeeAmount[j]);
        //                        j = j + 1;
        //                    }
        //                    i = i + 1;
        //                }
        //                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 Insert HostelStructure
        /// </summary>
        /// <param name="argEn">HostelStructure Entity is an Input.</param>
        /// <returns>Returns Boolean</returns>
        public bool Insert(HostelStructEn argEn, bool GenerateAutoNumber = true)
        {
            bool lbRes = false;
            int  iOut  = 0;
            //DO NOT USE SAHS_CODE TO CHECKING, CHECK COMPOSITE KEY ( SAHB_Code, SAHB_Block, SAHB_RoomTYpe)
            //string sqlCmd = "Select count(*) as cnt From SAS_HostelStruct WHERE SAHS_Code = @SAHS_Code and SAHB_Code=@SAHB_Code and SAHB_Block=@SAHB_Block and SAHB_RoomTYpe=@SAHB_RoomTYpe";
            string sqlCmd = "Select count(*) as cnt From SAS_HostelStruct WHERE SAHB_Code=@SAHB_Code and SAHB_Block=@SAHB_Block and SAHB_RoomTYpe=@SAHB_RoomTYpe";

            try
            {
                if (!FormHelp.IsBlank(sqlCmd))
                {
                    DbCommand cmdSel = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString);
                    // _DatabaseFactory.AddInParameter(ref cmdSel, "@SAHS_Code", DbType.String, argEn.HostelStructureCode);
                    _DatabaseFactory.AddInParameter(ref cmdSel, "@SAHB_Block", DbType.String, argEn.Block);
                    _DatabaseFactory.AddInParameter(ref cmdSel, "@SAHB_Code", DbType.String, argEn.Code);
                    _DatabaseFactory.AddInParameter(ref cmdSel, "@SAHB_RoomTYpe", DbType.String, argEn.RoomTYpe);
                    _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 = "INSERT INTO SAS_HostelStruct(SAHS_Code,SAHB_Code,SAHB_Block,SAHB_RoomTYpe,SAHS_EffectFm,SAFS_Status,SAHS_UpdatedUser,SAHS_UpdatedDtTm) VALUES (@SAHS_Code,@SAHB_Code,@SAHB_Block,@SAHB_RoomTYpe,@SAHS_EffectFm,@SAFS_Status,@SAHS_UpdatedUser,@SAHS_UpdatedDtTm) ";

                    if (!FormHelp.IsBlank(sqlCmd))
                    {
                        if (GenerateAutoNumber)
                        {
                            argEn.HostelStructureCode = GetAutoNumber("HostelCode");
                        }
                        DbCommand cmd = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString);
                        _DatabaseFactory.AddInParameter(ref cmd, "@SAHS_Code", DbType.String, clsGeneric.NullToString(argEn.HostelStructureCode));
                        _DatabaseFactory.AddInParameter(ref cmd, "@SAHB_Code", DbType.String, clsGeneric.NullToString(argEn.Code));
                        _DatabaseFactory.AddInParameter(ref cmd, "@SAHB_Block", DbType.String, clsGeneric.NullToString(argEn.Block));
                        _DatabaseFactory.AddInParameter(ref cmd, "@SAHB_RoomTYpe", DbType.String, clsGeneric.NullToString(argEn.RoomTYpe));
                        _DatabaseFactory.AddInParameter(ref cmd, "@SAHS_EffectFm", DbType.String, clsGeneric.NullToString(argEn.EffectFm));
                        _DatabaseFactory.AddInParameter(ref cmd, "@SAFS_Status", DbType.Boolean, clsGeneric.NullToBoolean(argEn.Status));
                        _DatabaseFactory.AddInParameter(ref cmd, "@SAHS_UpdatedUser", DbType.String, clsGeneric.NullToString(argEn.UpdatedUser));
                        _DatabaseFactory.AddInParameter(ref cmd, "@SAHS_UpdatedDtTm", DbType.String, clsGeneric.NullToString(DateTime.Now.ToString("dd/MM/yyyy")));
                        _DbParameterCollection = cmd.Parameters;

                        int liRowAffected = _DatabaseFactory.ExecuteNonQuery(Helper.GetDataBaseType, cmd,
                                                                             DataBaseConnectionString, sqlCmd, _DbParameterCollection);
                        int i = 0;
                        int j = 0;

                        HostelStrDetailsDAL loHstrDal   = new HostelStrDetailsDAL();
                        HostelStrAmountDAL  loHstrAmDal = new HostelStrAmountDAL();
                        while (i < argEn.lstHFeeSD.Count)
                        {
                            //inserting new hostel feeDetails
                            argEn.lstHFeeSD[i].HSCode = argEn.HostelStructureCode;
                            loHstrDal.Insert(argEn.lstHFeeSD[i]);
                            j = 0;
                            while (j < argEn.lstHFeeSD[i].ListFeeAmount.Count)
                            {
                                //inserting new hostel feeAmounts
                                argEn.lstHFeeSD[i].ListFeeAmount[j].HSCode = argEn.HostelStructureCode;
                                loHstrAmDal.Insert(argEn.lstHFeeSD[i].ListFeeAmount[j]);
                                j = j + 1;
                            }
                            i = i + 1;
                        }
                        if (liRowAffected > -1)
                        {
                            lbRes = true;
                        }
                        else
                        {
                            throw new Exception("Insertion Failed! No Row has been updated...");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(lbRes);
        }