public DataTable GeInquries(NewInquiryBDto objNewInquiryBDto)
        {
            Database db = null;
            DbCommand dbCmd = null;
            DataSet ds = null;
            DataTable dt = null;
            try
            {
                db = DatabaseFactory.CreateDatabase(DALHelper.CRM_CONNECTION_STRING);
                dbCmd = db.GetStoredProcCommand(DALHelper.USP_INQ_INQUIRY_MAIN_HEAD_SELECT);

                if (objNewInquiryBDto.InquiryId != 0)
                    db.AddInParameter(dbCmd, "@INQ_NO", DbType.Int32, objNewInquiryBDto.InquiryId);
                else
                    db.AddInParameter(dbCmd, "@INQ_NO", DbType.Int32, DBNull.Value);

                if (objNewInquiryBDto.InquiryDate != DateTime.MinValue)
                    db.AddInParameter(dbCmd, "@INQUIRY_DATE", DbType.DateTime, objNewInquiryBDto.InquiryDate);
                else
                    db.AddInParameter(dbCmd, "@INQUIRY_DATE", DbType.DateTime, DBNull.Value);

                if (objNewInquiryBDto.InquiryToDate != DateTime.MinValue)
                    db.AddInParameter(dbCmd, "@INQUIRY_TO_DATE", DbType.DateTime, objNewInquiryBDto.InquiryToDate);
                else
                    db.AddInParameter(dbCmd, "@INQUIRY_TO_DATE", DbType.DateTime, DBNull.Value);

                if (!string.IsNullOrEmpty(objNewInquiryBDto.CustomerName) && objNewInquiryBDto.CustomerName != "0")
                    db.AddInParameter(dbCmd, "@CUSTOMER_ID", DbType.Int32, Convert.ToInt32(objNewInquiryBDto.CustomerName));
                else
                    db.AddInParameter(dbCmd, "@CUSTOMER_ID", DbType.Int32, DBNull.Value);

                if (!String.IsNullOrEmpty(objNewInquiryBDto.CustomerUniqueId))
                    db.AddInParameter(dbCmd, "@CUSTOMER_UNQ_ID", DbType.String, objNewInquiryBDto.CustomerUniqueId);
                else
                    db.AddInParameter(dbCmd, "@CUSTOMER_UNQ_ID", DbType.String, DBNull.Value);

                if (objNewInquiryBDto.SalesPersonId != 0) // it is user id not emp.id
                    db.AddInParameter(dbCmd, "@SALES_PERSON_ID", DbType.Int32, objNewInquiryBDto.SalesPersonId);
                else
                    db.AddInParameter(dbCmd, "@SALES_PERSON_ID", DbType.Int32, DBNull.Value);

                if (objNewInquiryBDto.InquiryMode != 0)
                    db.AddInParameter(dbCmd, "@INQUIRY_MODE", DbType.Int32, objNewInquiryBDto.InquiryMode);
                else
                    db.AddInParameter(dbCmd, "@INQUIRY_MODE", DbType.Int32, DBNull.Value);

                if (objNewInquiryBDto.ReferenceId != 0)
                    db.AddInParameter(dbCmd, "@REFERENCE_ID", DbType.Int32, objNewInquiryBDto.ReferenceId);
                else
                    db.AddInParameter(dbCmd, "@REFERENCE_ID", DbType.Int32, DBNull.Value);

                if (objNewInquiryBDto.Branch != 0)
                    db.AddInParameter(dbCmd, "@BRANCH_ID", DbType.Int32, objNewInquiryBDto.Branch);
                else
                    db.AddInParameter(dbCmd, "@BRANCH_ID", DbType.Int32, DBNull.Value);

                if (objNewInquiryBDto.AgentId != 0)
                    db.AddInParameter(dbCmd, "@AGENT_ID", DbType.Int32, objNewInquiryBDto.AgentId);
                else
                    db.AddInParameter(dbCmd, "@AGENT_ID", DbType.Int32, DBNull.Value);

                if (objNewInquiryBDto.TourSubType != 0)
                    db.AddInParameter(dbCmd, "@TOUR_SUBTYPE", DbType.Int32, objNewInquiryBDto.TourSubType);
                else
                    db.AddInParameter(dbCmd, "@TOUR_SUBTYPE", DbType.Int32, DBNull.Value);




                //if (objNewInquiryBDto.Rating != 0)
                //    db.AddInParameter(dbCmd, "@RATING", DbType.Int32, objNewInquiryBDto.Rating);
                //else
                //    db.AddInParameter(dbCmd, "@RATING", DbType.Int32, DBNull.Value);

                if (objNewInquiryBDto.CurrentStatus != 0)
                    db.AddInParameter(dbCmd, "@CURRENT_STATUS", DbType.Int32, objNewInquiryBDto.CurrentStatus);
                else
                    db.AddInParameter(dbCmd, "@CURRENT_STATUS", DbType.Int32, DBNull.Value);

                if (objNewInquiryBDto.TravelFromDate1 != DateTime.MinValue)
                    db.AddInParameter(dbCmd, "@NEXT_TRAVEL_FROM_DATE", DbType.DateTime, objNewInquiryBDto.TravelFromDate1);
                else
                    db.AddInParameter(dbCmd, "@NEXT_TRAVEL_FROM_DATE", DbType.DateTime, DBNull.Value);

                if (objNewInquiryBDto.TravelTODate1 != DateTime.MinValue)
                    db.AddInParameter(dbCmd, "@NEXT_TRAVEL_TO_DATE", DbType.DateTime, objNewInquiryBDto.TravelTODate1);
                else
                    db.AddInParameter(dbCmd, "@NEXT_TRAVEL_TO_DATE", DbType.DateTime, DBNull.Value);

                if (objNewInquiryBDto.CountryId != 0)
                    db.AddInParameter(dbCmd, "@COUNTRY_ID", DbType.Int32, objNewInquiryBDto.CountryId);
                else
                    db.AddInParameter(dbCmd, "@COUNTRY_ID", DbType.Int32, DBNull.Value);

                if (objNewInquiryBDto.Rating != 0)
                    db.AddInParameter(dbCmd, "@INQ_RATING", DbType.Int32, objNewInquiryBDto.Rating);
                else
                    db.AddInParameter(dbCmd, "@INQ_RATING", DbType.Int32, DBNull.Value);

                ds = db.ExecuteDataSet(dbCmd);

                using (ds)
                {
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        dt = ds.Tables[0];
                    }
                }
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME);
                if (rethrow)
                {
                    throw ex;
                }
            }
            finally
            {
                DALHelper.Destroy(ref dbCmd);
            }
            return dt;
        }
        public int InquiryMainHeadUpdate(NewInquiryBDto objNewInquiryBDto)
        {
            Database db = null;
            DbCommand dbCmd = null;
            int Result = 0;
            try
            {
                db = DatabaseFactory.CreateDatabase(DALHelper.CRM_CONNECTION_STRING);
                dbCmd = db.GetStoredProcCommand(DALHelper.USP_INQ_INQUIRY_MAIN_HEAD_UPDATE);
                db.AddInParameter(dbCmd, "@INQUIRY_ID", DbType.Int32, objNewInquiryBDto.InquiryId);
                if (objNewInquiryBDto.InquiryDate != DateTime.MinValue)
                    db.AddInParameter(dbCmd, "@INQUIRY_DATE", DbType.DateTime, objNewInquiryBDto.InquiryDate);
                else
                    db.AddInParameter(dbCmd, "@INQUIRY_DATE", DbType.DateTime, DBNull.Value);

                db.AddInParameter(dbCmd, "@CUSTOMER_ID", DbType.Int32, objNewInquiryBDto.CustomerId);
                db.AddInParameter(dbCmd, "@RELATION_ID", DbType.Int32, objNewInquiryBDto.RelationId);
                db.AddInParameter(dbCmd, "@RELATIVE_NAME", DbType.String, objNewInquiryBDto.RelativeName);
                db.AddInParameter(dbCmd, "@SALES_PERSON_ID", DbType.Int32, objNewInquiryBDto.SalesPersonId);
                db.AddInParameter(dbCmd, "@INQUIRY_MODE", DbType.Int32, objNewInquiryBDto.InquiryMode);
                db.AddInParameter(dbCmd, "@REFERENCE_ID", DbType.Int32, objNewInquiryBDto.ReferenceId);
                db.AddInParameter(dbCmd, "@REFERENCE_DESC", DbType.String, objNewInquiryBDto.ReferenceDesc);
                db.AddInParameter(dbCmd, "@BRANCH_ID", DbType.Int32, objNewInquiryBDto.Branch);
                db.AddInParameter(dbCmd, "@AGENT_ID", DbType.Int32, objNewInquiryBDto.AgentId);
                db.AddInParameter(dbCmd, "@RATING", DbType.Int32, objNewInquiryBDto.Rating);
                db.AddInParameter(dbCmd, "@CURRENT_STATUS", DbType.Int32, objNewInquiryBDto.CurrentStatus);
                db.AddInParameter(dbCmd, "@REMARKS", DbType.String, objNewInquiryBDto.Remarks);

                Result = db.ExecuteNonQuery(dbCmd);
                return Result;
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME);
                if (rethrow)
                {
                    throw ex;
                }
            }
            finally
            {
                DALHelper.Destroy(ref dbCmd);
            }
            return Result;
        }