/// <summary> /// 增加一条数据 /// </summary> public void Add(LPWeb.Model.UserLeadDist model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into UserLeadDist("); strSql.Append("UserID,EnableLeadRouting,MaxDailyLeads,LeadsAssignedToday,LastLeadAssigned,LastAssigned)"); strSql.Append(" values ("); strSql.Append("@UserID,@EnableLeadRouting,@MaxDailyLeads,@LeadsAssignedToday,@LastLeadAssigned,@LastAssigned)"); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4), new SqlParameter("@EnableLeadRouting", SqlDbType.Bit, 1), new SqlParameter("@MaxDailyLeads", SqlDbType.Int, 4), new SqlParameter("@LeadsAssignedToday", SqlDbType.Int, 4), new SqlParameter("@LastLeadAssigned", SqlDbType.Int, 4), new SqlParameter("@LastAssigned", SqlDbType.DateTime) }; parameters[0].Value = model.UserID; parameters[1].Value = model.EnableLeadRouting; parameters[2].Value = model.MaxDailyLeads; parameters[3].Value = model.LeadsAssignedToday; parameters[4].Value = model.LastLeadAssigned; parameters[5].Value = model.LastAssigned; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public LPWeb.Model.UserLeadDist GetModel(int UserID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 UserID,EnableLeadRouting,MaxDailyLeads,LeadsAssignedToday,LastLeadAssigned,LastAssigned from UserLeadDist "); strSql.Append(" where UserID=@UserID "); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4) }; parameters[0].Value = UserID; LPWeb.Model.UserLeadDist model = new LPWeb.Model.UserLeadDist(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["UserID"].ToString() != "") { model.UserID = int.Parse(ds.Tables[0].Rows[0]["UserID"].ToString()); } if (ds.Tables[0].Rows[0]["EnableLeadRouting"].ToString() != "") { if ((ds.Tables[0].Rows[0]["EnableLeadRouting"].ToString() == "1") || (ds.Tables[0].Rows[0]["EnableLeadRouting"].ToString().ToLower() == "true")) { model.EnableLeadRouting = true; } else { model.EnableLeadRouting = false; } } if (ds.Tables[0].Rows[0]["MaxDailyLeads"].ToString() != "") { model.MaxDailyLeads = int.Parse(ds.Tables[0].Rows[0]["MaxDailyLeads"].ToString()); } if (ds.Tables[0].Rows[0]["LeadsAssignedToday"].ToString() != "") { model.LeadsAssignedToday = int.Parse(ds.Tables[0].Rows[0]["LeadsAssignedToday"].ToString()); } if (ds.Tables[0].Rows[0]["LastLeadAssigned"].ToString() != "") { model.LastLeadAssigned = int.Parse(ds.Tables[0].Rows[0]["LastLeadAssigned"].ToString()); } if (ds.Tables[0].Rows[0]["LastAssigned"].ToString() != "") { model.LastAssigned = DateTime.Parse(ds.Tables[0].Rows[0]["LastAssigned"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(LPWeb.Model.UserLeadDist model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update UserLeadDist set "); strSql.Append("EnableLeadRouting=@EnableLeadRouting,"); strSql.Append("MaxDailyLeads=@MaxDailyLeads,"); strSql.Append("LeadsAssignedToday=@LeadsAssignedToday,"); strSql.Append("LastLeadAssigned=@LastLeadAssigned,"); strSql.Append("LastAssigned=@LastAssigned"); strSql.Append(" where UserID=@UserID "); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4), new SqlParameter("@EnableLeadRouting", SqlDbType.Bit, 1), new SqlParameter("@MaxDailyLeads", SqlDbType.Int, 4), new SqlParameter("@LeadsAssignedToday", SqlDbType.Int, 4), new SqlParameter("@LastLeadAssigned", SqlDbType.Int, 4), new SqlParameter("@LastAssigned", SqlDbType.DateTime) }; parameters[0].Value = model.UserID; parameters[1].Value = model.EnableLeadRouting; parameters[2].Value = model.MaxDailyLeads; parameters[3].Value = model.LeadsAssignedToday; parameters[4].Value = model.LastLeadAssigned; parameters[5].Value = model.LastAssigned; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }