Exemple #1
0
        public static int CreateInsurance(SqlConnection conn, CarInsurancePartner insurance)
        {
            var sql        = @"INSERT  INTO Configuration.dbo.CarInsurancePartner
        ( Name ,
          Img ,
          LinkUrl ,
          InsuranceId ,
          Remarks ,
          Title ,
          SubTitle ,
          TagText ,
          TagColor ,
          RegionCode ,
          ProviderCode ,
          DisplayIndex ,
          IsEnable 
        )
VALUES  ( @Name ,
          @Img ,
          @LinkUrl ,
          @InsuranceId ,
          @MarkText ,
          @Title ,
          @SubTitle ,
          @TagText ,
          @TagColor ,
          @RegionCode ,
          @ProviderCode ,
          @DisplayIndex ,
          @IsEnable 
        );
SELECT  SCOPE_IDENTITY();";
            var parameters = new SqlParameter[]
            {
                new SqlParameter("@Name", insurance.Name),
                new SqlParameter("@Img", insurance.Img),
                new SqlParameter("@LinkUrl", insurance.LinkUrl),
                new SqlParameter("@InsuranceId", insurance.InsuranceId),
                new SqlParameter("@MarkText", insurance.Remarks),
                new SqlParameter("@Title", insurance.Title),
                new SqlParameter("@SubTitle", insurance.SubTitle),
                new SqlParameter("@TagText", insurance.TagText),
                new SqlParameter("@TagColor", insurance.TagColor),
                new SqlParameter("@DisplayIndex", insurance.DisplayIndex),
                new SqlParameter("@ProviderCode", insurance.ProviderCode),
                new SqlParameter("@RegionCode", insurance.RegionCode),
                new SqlParameter("@IsEnable", insurance.IsEnable)
            };
            var pkid = SqlHelper.ExecuteScalar(conn, CommandType.Text, sql, parameters);

            if (pkid == DBNull.Value)
            {
                return(-1);
            }
            return(Convert.ToInt32(pkid));
        }
Exemple #2
0
        public static bool UpdateInsurance(SqlConnection conn, CarInsurancePartner insurance)
        {
            var sql        = @"UPDATE  Configuration.dbo.CarInsurancePartner
SET     Name = @Name ,
        Img = @Img ,
        LinkUrl = @LinkUrl ,
        InsuranceId = @InsuranceId ,
        Remarks = @MarkText ,
        Title = @Title ,
        SubTitle = @SubTitle ,
        TagText = @TagText ,
        TagColor = @TagColor ,
        DisplayIndex = @DisplayIndex ,
        IsEnable = @IsEnable ,
        ProviderCode = @ProviderCode ,
        RegionCode = @RegionCode ,
        LastUpdateDateTime = GETDATE()
WHERE   PKID = @PKID;";
            var parameters = new SqlParameter[]
            {
                new SqlParameter("@Name", insurance.Name),
                new SqlParameter("@Img", insurance.Img),
                new SqlParameter("@LinkUrl", insurance.LinkUrl),
                new SqlParameter("@InsuranceId", insurance.InsuranceId),
                new SqlParameter("@MarkText", insurance.Remarks),
                new SqlParameter("@Title", insurance.Title),
                new SqlParameter("@SubTitle", insurance.SubTitle),
                new SqlParameter("@TagText", insurance.TagText),
                new SqlParameter("@TagColor", insurance.TagColor),
                new SqlParameter("@DisplayIndex", insurance.DisplayIndex),
                new SqlParameter("@IsEnable", insurance.IsEnable),
                new SqlParameter("@ProviderCode", insurance.ProviderCode),
                new SqlParameter("@RegionCode", insurance.RegionCode),
                new SqlParameter("@PKID", insurance.PKID)
            };
            var count = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, parameters);

            return(count > 0);
        }
        public static bool CreateInsurance(string name, string img, string linkUrl, string insuranceId,
                                           string markText, string title, string subTitle, string tagText, string tagColor,
                                           int displayIndex, int isEnable, string regions, string regionCode, string providerCode)
        {
            if (displayIndex == -1)
            {
                displayIndex = readDbScopeManager.Execute(conn => DalCarInsuranceConfig.GetMaxInsuranceIndex(conn)) + 1;
            }
            CarInsurancePartner insurance = new CarInsurancePartner();

            insurance.Name         = name;
            insurance.Img          = img;
            insurance.LinkUrl      = linkUrl;
            insurance.InsuranceId  = insuranceId;
            insurance.Remarks      = markText;
            insurance.Title        = title;
            insurance.SubTitle     = subTitle;
            insurance.TagText      = tagText;
            insurance.TagColor     = tagColor;
            insurance.IsEnable     = isEnable;
            insurance.DisplayIndex = displayIndex - 1;
            insurance.RegionCode   = regionCode;
            insurance.ProviderCode = providerCode;
            var pkid = dbScopeManager.Execute(conn => DalCarInsuranceConfig.CreateInsurance(conn, insurance));

            if (pkid == -1)
            {
                return(false);
            }
            if (regions == "")
            {
                return(true);
            }
            var result = UpdateInsuranceRegions(pkid, regions);

            return(result);
        }
        public static bool UpdateInsurance(int insuracePartnerId, string name, string img, string linkUrl,
                                           string insuranceId, string markText, string title, string subTitle, string tagText,
                                           string tagColor, int displayIndex, int isEnable, string regionCode, string providerCode)
        {
            CarInsurancePartner insurance = new CarInsurancePartner();

            insurance.PKID         = insuracePartnerId;
            insurance.Name         = name;
            insurance.Img          = img;
            insurance.LinkUrl      = linkUrl;
            insurance.InsuranceId  = insuranceId;
            insurance.Remarks      = markText;
            insurance.Title        = title;
            insurance.SubTitle     = subTitle;
            insurance.TagText      = tagText;
            insurance.TagColor     = tagColor;
            insurance.DisplayIndex = displayIndex;
            insurance.IsEnable     = isEnable;
            insurance.RegionCode   = regionCode;
            insurance.ProviderCode = providerCode;
            var result = dbScopeManager.Execute(conn => DalCarInsuranceConfig.UpdateInsurance(conn, insurance));

            return(result);
        }