public List<Maticsoft.Model.Members.PointsLimit> DataTableToList(DataTable dt) { List<Maticsoft.Model.Members.PointsLimit> list = new List<Maticsoft.Model.Members.PointsLimit>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { Maticsoft.Model.Members.PointsLimit item = new Maticsoft.Model.Members.PointsLimit(); if ((dt.Rows[i]["PointsLimitID"] != null) && (dt.Rows[i]["PointsLimitID"].ToString() != "")) { item.PointsLimitID = int.Parse(dt.Rows[i]["PointsLimitID"].ToString()); } if ((dt.Rows[i]["Cycle"] != null) && (dt.Rows[i]["Cycle"].ToString() != "")) { item.Cycle = int.Parse(dt.Rows[i]["Cycle"].ToString()); } if ((dt.Rows[i]["CycleUnit"] != null) && (dt.Rows[i]["CycleUnit"].ToString() != "")) { item.CycleUnit = dt.Rows[i]["CycleUnit"].ToString(); } if ((dt.Rows[i]["MaxTimes"] != null) && (dt.Rows[i]["MaxTimes"].ToString() != "")) { item.MaxTimes = int.Parse(dt.Rows[i]["MaxTimes"].ToString()); } list.Add(item); } } return list; }
public void btnSave_Click(object sender, EventArgs e) { if (this.LimitBll.Exists(this.tName.Text.Trim())) { MessageBox.ShowSuccessTip(this, "已存在该规则限制名称,请重新填写"); } else { Maticsoft.Model.Members.PointsLimit model = new Maticsoft.Model.Members.PointsLimit { Name = this.tName.Text.Trim() }; if (PageValidate.IsNumber(this.tCycle.Text.Trim())) { model.Cycle = Globals.SafeInt(this.tCycle.Text.Trim(), 0); } if (PageValidate.IsNumber(this.tMaxTimes.Text.Trim())) { model.MaxTimes = Globals.SafeInt(this.tMaxTimes.Text.Trim(), 0); } model.CycleUnit = this.DropCycleUnit.SelectedValue; if (this.LimitBll.Add(model) > 0) { base.Response.Redirect("PointsLimit.aspx"); } else { this.lblMsg.ForeColor = Color.Red; this.lblMsg.Text = "添加条件限制出错!"; } } }
public Maticsoft.Model.Members.PointsLimit GetModel(int PointsLimitID) { StringBuilder builder = new StringBuilder(); builder.Append("select top 1 PointsLimitID,Name,Cycle,CycleUnit,MaxTimes from Accounts_PointsLimit "); builder.Append(" where PointsLimitID=@PointsLimitID"); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@PointsLimitID", SqlDbType.Int, 4) }; cmdParms[0].Value = PointsLimitID; Maticsoft.Model.Members.PointsLimit limit = new Maticsoft.Model.Members.PointsLimit(); DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms); if (set.Tables[0].Rows.Count <= 0) { return null; } if ((set.Tables[0].Rows[0]["PointsLimitID"] != null) && (set.Tables[0].Rows[0]["PointsLimitID"].ToString() != "")) { limit.PointsLimitID = int.Parse(set.Tables[0].Rows[0]["PointsLimitID"].ToString()); } if ((set.Tables[0].Rows[0]["Name"] != null) && (set.Tables[0].Rows[0]["Name"].ToString() != "")) { limit.Name = set.Tables[0].Rows[0]["Name"].ToString(); } if ((set.Tables[0].Rows[0]["Cycle"] != null) && (set.Tables[0].Rows[0]["Cycle"].ToString() != "")) { limit.Cycle = int.Parse(set.Tables[0].Rows[0]["Cycle"].ToString()); } if ((set.Tables[0].Rows[0]["CycleUnit"] != null) && (set.Tables[0].Rows[0]["CycleUnit"].ToString() != "")) { limit.CycleUnit = set.Tables[0].Rows[0]["CycleUnit"].ToString(); } if ((set.Tables[0].Rows[0]["MaxTimes"] != null) && (set.Tables[0].Rows[0]["MaxTimes"].ToString() != "")) { limit.MaxTimes = int.Parse(set.Tables[0].Rows[0]["MaxTimes"].ToString()); } return limit; }