Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(LPWeb.Model.ArchiveLeadStatus model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ArchiveLeadStatus(");
            strSql.Append("LeadStatusName,Enabled)");
            strSql.Append(" values (");
            strSql.Append("@LeadStatusName,@Enabled)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LeadStatusName", SqlDbType.NVarChar, 255),
                new SqlParameter("@Enabled",        SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.LeadStatusName;
            parameters[1].Value = model.Enabled;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LPWeb.Model.ArchiveLeadStatus model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ArchiveLeadStatus set ");
            strSql.Append("LeadStatusName=@LeadStatusName,");
            strSql.Append("Enabled=@Enabled");
            strSql.Append(" where LeadStatusId=@LeadStatusId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LeadStatusId",   SqlDbType.Int,        4),
                new SqlParameter("@LeadStatusName", SqlDbType.NVarChar, 255),
                new SqlParameter("@Enabled",        SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.LeadStatusId;
            parameters[1].Value = model.LeadStatusName;
            parameters[2].Value = model.Enabled;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LPWeb.Model.ArchiveLeadStatus GetModel(int LeadStatusId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 LeadStatusId,LeadStatusName,Enabled from ArchiveLeadStatus ");
            strSql.Append(" where LeadStatusId=@LeadStatusId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LeadStatusId", SqlDbType.Int, 4)
            };
            parameters[0].Value = LeadStatusId;

            LPWeb.Model.ArchiveLeadStatus model = new LPWeb.Model.ArchiveLeadStatus();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["LeadStatusId"].ToString() != "")
                {
                    model.LeadStatusId = int.Parse(ds.Tables[0].Rows[0]["LeadStatusId"].ToString());
                }
                model.LeadStatusName = ds.Tables[0].Rows[0]["LeadStatusName"].ToString();
                if (ds.Tables[0].Rows[0]["Enabled"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Enabled"].ToString() == "1") || (ds.Tables[0].Rows[0]["Enabled"].ToString().ToLower() == "true"))
                    {
                        model.Enabled = true;
                    }
                    else
                    {
                        model.Enabled = false;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }