/// <summary> /// 保存推广返利配置(新增、更新) /// </summary> /// <param name="config"></param> /// <returns></returns> public int SaveSpreadReturnConfig(SpreadReturnConfig config) { string sql; var prams = new List <DbParameter> { Database.MakeInParam("SpreadLevel", config.SpreadLevel), Database.MakeInParam("PresentScale", config.PresentScale), Database.MakeInParam("Nullity", config.Nullity), Database.MakeInParam("UpdateTime", config.UpdateTime) }; if (config.ConfigID > 0) { prams.Add(Database.MakeInParam("ConfigID", config.ConfigID)); sql = "UPDATE SpreadReturnConfig SET SpreadLevel=@SpreadLevel,PresentScale=@PresentScale,Nullity=@Nullity,UpdateTime=@UpdateTime WHERE ConfigID=@ConfigID"; } else { sql = @" IF NOT EXISTS (SELECT 1 FROM SpreadReturnConfig WHERE SpreadLevel = @SpreadLevel) BEGIN INSERT INTO SpreadReturnConfig(SpreadLevel,PresentScale,Nullity,UpdateTime) VALUES(@SpreadLevel,@PresentScale,@Nullity,@UpdateTime) END"; } return(Database.ExecuteNonQuery(CommandType.Text, sql, prams.ToArray())); }
/// <summary> /// 数据保存 /// </summary> protected void btnSave_Click(object sender, EventArgs e) { SpreadReturnConfig config = new SpreadReturnConfig(); if (IntParam > 0) { AuthUserOperationPermission(Permission.Edit); config.ConfigID = IntParam; } else { AuthUserOperationPermission(Permission.Add); } config.SpreadLevel = CtrlHelper.GetInt(txtSpreadLevel, 0); if (config.SpreadLevel > 3) { ShowError("目前平台仅支持最多三级代理返利!"); return; } config.PresentScale = Convert.ToDecimal(txtPresentScale.Text) / 1000; config.Nullity = Convert.ToBoolean(rblNullity.SelectedValue); config.UpdateTime = DateTime.Now; int result = FacadeManage.aideTreasureFacade.SaveSpreadReturnConfig(config); if (result > 0) { ShowInfo("操作成功", "SpreadReturnConfigList.aspx", 1200); } else { ShowError(config.ConfigID > 0 ? "操作失败" : "一个推广级别只能设置一个配置"); } }
/// <summary> /// 数据绑定 /// </summary> private void BindData() { if (IntParam > 0) { SpreadReturnConfig config = FacadeManage.aideTreasureFacade.GetSpreadReturnConfig(IntParam); if (config != null) { CtrlHelper.SetText(txtSpreadLevel, config.SpreadLevel.ToString()); CtrlHelper.SetText(txtPresentScale, (config.PresentScale * 1000).ToString("F0")); rblNullity.SelectedValue = config.Nullity.ToString(); } } }
/// <summary> /// 保存推广返利配置(新增、更新) /// </summary> /// <param name="config"></param> /// <returns></returns> public int SaveSpreadReturnConfig(SpreadReturnConfig config) { return(aideTreasureData.SaveSpreadReturnConfig(config)); }