コード例 #1
0
        public bool Delete(string compId, IEntity entity, DbTransaction transaction)
        {
            WebContribImp oEntity = entity as WebContribImp;

            if (oEntity == null)
            {
                throw new InvalidValueException("Unable to cast entity object");
            }

            Database  database       = ConnectionSetting.GetDatabase(Core.ApplicationContext.DataConnectionString, compId);
            DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.trav_tblArWebContribImp_CSI_Delete",
                                                                                 UseStoredProcedure, GetCommandFromResource());

            database.AddInParameter(commandWrapper, "@Id", DbType.Int64, oEntity.Id);

            int results = 0;

            if (transaction != null)
            {
                results = database.ExecuteNonQuery(commandWrapper, transaction);
            }
            else
            {
                results = database.ExecuteNonQuery(commandWrapper);
            }

            if (results == 0)
            {
                //throw new DataException("The record has been already deleted.");
                return(false);
            }

            return(Convert.ToBoolean(results));
        }//end Delete
コード例 #2
0
        public bool Update(string compId, IEntity entity, DbTransaction transaction)
        {
            PartnerItemXref oEntity = entity as PartnerItemXref;

            if (oEntity == null)
            {
                throw new InvalidValueException("Unable to cast entity object");
            }

            Database  database       = ConnectionSetting.GetDatabase(Core.ApplicationContext.DataConnectionString, compId);
            DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.trav_tblEdPartnerItemXref_Update",
                                                                                 UseStoredProcedure, GetCommandFromResource());

            database.AddInParameter(commandWrapper, "@PartnerId", DbType.AnsiString, oEntity.PartnerId);
            database.AddInParameter(commandWrapper, "@OriginalPartnerId", DbType.AnsiString, oEntity.OriginalPartnerId);
            database.AddInParameter(commandWrapper, "@TravItemId", DbType.AnsiString, oEntity.TravItemId);
            database.AddInParameter(commandWrapper, "@OriginalTravItemId", DbType.AnsiString, oEntity.OriginalTravItemId);
            database.AddInParameter(commandWrapper, "@TravUom", DbType.AnsiString, oEntity.TravUom);
            database.AddInParameter(commandWrapper, "@OriginalTravUom", DbType.AnsiString, oEntity.OriginalTravUom);
            database.AddInParameter(commandWrapper, "@EdiUom", DbType.AnsiString, oEntity.EdiUom);
            database.AddInParameter(commandWrapper, "@EAN", DbType.AnsiString, oEntity.EAN);
            database.AddInParameter(commandWrapper, "@GTIN", DbType.AnsiString, oEntity.GTIN);
            database.AddInParameter(commandWrapper, "@UPC", DbType.AnsiString, oEntity.UPC);
            database.AddInParameter(commandWrapper, "@SKU", DbType.AnsiString, oEntity.SKU);
            database.AddInParameter(commandWrapper, "@BuyerCode", DbType.AnsiString, oEntity.BuyerCode);
            database.AddInParameter(commandWrapper, "@VendorCode", DbType.AnsiString, oEntity.VendorCode);
            database.AddInParameter(commandWrapper, "@InternalCode", DbType.AnsiString, oEntity.InternalCode);
            database.AddInParameter(commandWrapper, "@InternalCode1", DbType.AnsiString, oEntity.InternalCode1);
            database.AddInParameter(commandWrapper, "@InternalCode2", DbType.AnsiString, oEntity.InternalCode2);

            int results = 0;

            if (transaction != null)
            {
                results = database.ExecuteNonQuery(commandWrapper, transaction);
            }
            else
            {
                results = database.ExecuteNonQuery(commandWrapper);
            }
            oEntity.OriginalPartnerId  = oEntity.PartnerId;
            oEntity.OriginalTravItemId = oEntity.TravItemId;
            oEntity.OriginalTravUom    = oEntity.TravUom;

            oEntity.AcceptChanges();

            return(Convert.ToBoolean(results));
        }
コード例 #3
0
        public IDataReader LoadData(string compId, DbTransaction transaction, FilterCriteria criteria)
        {
            Database  database = ConnectionSetting.GetDatabase(Core.ApplicationContext.DataConnectionString, compId);
            DbCommand commandWrapper;

            if (string.IsNullOrEmpty(criteria.WhereClause) && string.IsNullOrEmpty(criteria.OrderBy))
            {
                commandWrapper = GetListCommand("dbo.trav_tblArWebContribImp_CSI_GetList", database, criteria.FilterByKey);
            }
            else
            {
                commandWrapper = GetPagedCommand("dbo.trav_tblArWebContribImp_CSI_GetPaged", database, criteria.WhereClause, criteria.OrderBy,
                                                 criteria.PageSize, criteria.PageIndex);
            }

            if (transaction == null)
            {
                return(database.ExecuteReader(commandWrapper));
            }
            else
            {
                return(database.ExecuteReader(commandWrapper, transaction));
            }
        }
コード例 #4
0
        public bool Update(string compId, IEntity entity, DbTransaction transaction)
        {
            WebContribImp oEntity = entity as WebContribImp;

            if (oEntity == null)
            {
                throw new InvalidValueException("Unable to cast entity object");
            }

            Database  database       = ConnectionSetting.GetDatabase(Core.ApplicationContext.DataConnectionString, compId);
            DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.trav_tblArWebContribImp_CSI_Update",
                                                                                 UseStoredProcedure, GetCommandFromResource());

            database.AddInParameter(commandWrapper, "@Id", DbType.Int64, oEntity.Id);
            database.AddInParameter(commandWrapper, "@TransId", DbType.AnsiString, oEntity.TransId);
            database.AddInParameter(commandWrapper, "@PmtDate", DbType.DateTime, (oEntity.PmtDate.HasValue ? (object)oEntity.PmtDate : System.DBNull.Value));
            database.AddInParameter(commandWrapper, "@PmtAmt", DbType.Decimal, oEntity.PmtAmt);
            database.AddInParameter(commandWrapper, "@CheckNum", DbType.AnsiString, oEntity.CheckNum);
            database.AddInParameter(commandWrapper, "@GroupId", DbType.AnsiString, oEntity.GroupId);
            database.AddInParameter(commandWrapper, "@PmtMethodId", DbType.AnsiString, oEntity.PmtMethodId);
            database.AddInParameter(commandWrapper, "@CcHolder", DbType.AnsiString, oEntity.CcHolder);
            database.AddInParameter(commandWrapper, "@CcNum", DbType.AnsiString, oEntity.CcNum);
            database.AddInParameter(commandWrapper, "@CcExpire", DbType.DateTime, (oEntity.CcExpire.HasValue ? (object)oEntity.CcExpire : System.DBNull.Value));
            database.AddInParameter(commandWrapper, "@CcAuth", DbType.AnsiString, oEntity.CcAuth);
            database.AddInParameter(commandWrapper, "@CurrencyId", DbType.AnsiString, oEntity.CurrencyId);
            database.AddInParameter(commandWrapper, "@ExchRate", DbType.Decimal, oEntity.ExchRate);
            database.AddInParameter(commandWrapper, "@SourceCode", DbType.AnsiString, oEntity.SourceCode);
            database.AddInParameter(commandWrapper, "@Area", DbType.AnsiString, oEntity.Area);
            database.AddInParameter(commandWrapper, "@CustName", DbType.AnsiString, oEntity.CustName);
            database.AddInParameter(commandWrapper, "@Addr1", DbType.AnsiString, oEntity.Addr1);
            database.AddInParameter(commandWrapper, "@Addr2", DbType.AnsiString, oEntity.Addr2);
            database.AddInParameter(commandWrapper, "@City", DbType.AnsiString, oEntity.City);
            database.AddInParameter(commandWrapper, "@Region", DbType.AnsiString, oEntity.Region);
            database.AddInParameter(commandWrapper, "@Country", DbType.AnsiString, oEntity.Country);
            database.AddInParameter(commandWrapper, "@PostalCode", DbType.AnsiString, oEntity.PostalCode);
            database.AddInParameter(commandWrapper, "@SpAcknowlgmnt", DbType.AnsiString, oEntity.SpAcknowlgmnt);
            database.AddInParameter(commandWrapper, "@Lang", DbType.AnsiString, oEntity.Lang);
            database.AddInParameter(commandWrapper, "@DntSendAcknYN", DbType.Boolean, oEntity.DntSendAcknYN);
            database.AddInParameter(commandWrapper, "@RptExchRate", DbType.Decimal, oEntity.RptExchRate);
            database.AddInParameter(commandWrapper, "@EmailAddr", DbType.AnsiString, oEntity.EmailAddr);
            database.AddInParameter(commandWrapper, "@SendEmailYN", DbType.Boolean, oEntity.SendEmailYN);
            database.AddInParameter(commandWrapper, "@ValidYN", DbType.Boolean, oEntity.ValidYN);
            database.AddInParameter(commandWrapper, "@ImportedYN", DbType.Boolean, oEntity.ImportedYN);
            database.AddInParameter(commandWrapper, "@TravRcptHeaderId", DbType.Int32, (oEntity.TravRcptHeaderId.HasValue ? (object)oEntity.TravRcptHeaderId : System.DBNull.Value));
            database.AddInParameter(commandWrapper, "@WebId", DbType.Int64, oEntity.WebId);
            database.AddInParameter(commandWrapper, "@SkipYN", DbType.Boolean, (oEntity.SkipYN.HasValue ? (object)oEntity.SkipYN : System.DBNull.Value));
            database.AddInParameter(commandWrapper, "@Errdescr", DbType.AnsiString, oEntity.Errdescr);
            database.AddInParameter(commandWrapper, "@GroupCountry", DbType.AnsiString, oEntity.GroupCountry);
            database.AddInParameter(commandWrapper, "@GroupState", DbType.AnsiString, oEntity.GroupState);
            database.AddInParameter(commandWrapper, "@GroupCity", DbType.AnsiString, oEntity.GroupCity);
            database.AddInParameter(commandWrapper, "@GroupName", DbType.AnsiString, oEntity.GroupName);
            database.AddInParameter(commandWrapper, "@BillToAddr1", DbType.AnsiString, oEntity.BillToAddr1);
            database.AddInParameter(commandWrapper, "@BillToAddr2", DbType.AnsiString, oEntity.BillToAddr2);
            database.AddInParameter(commandWrapper, "@BillToCity", DbType.AnsiString, oEntity.BillToCity);
            database.AddInParameter(commandWrapper, "@BillToRegion", DbType.AnsiString, oEntity.BillToRegion);
            database.AddInParameter(commandWrapper, "@BillToCountry", DbType.AnsiString, oEntity.BillToCountry);
            database.AddInParameter(commandWrapper, "@BillToPostalCode", DbType.AnsiString, oEntity.BillToPostalCode);
            database.AddInParameter(commandWrapper, "@CF", DbType.Xml, oEntity.CF);

            int results = 0;

            if (transaction != null)
            {
                results = database.ExecuteNonQuery(commandWrapper, transaction);
            }
            else
            {
                results = database.ExecuteNonQuery(commandWrapper);
            }

            oEntity.AcceptChanges();

            return(Convert.ToBoolean(results));
        }