Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(LPWeb.Model.ProspectOtherIncome model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ProspectOtherIncome(");
            strSql.Append("ContactId,Type,MonthlyIncome)");
            strSql.Append(" values (");
            strSql.Append("@ContactId,@Type,@MonthlyIncome)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ContactId",     SqlDbType.Int,        4),
                new SqlParameter("@Type",          SqlDbType.NVarChar, 100),
                new SqlParameter("@MonthlyIncome", SqlDbType.Decimal, 5)
            };
            parameters[0].Value = model.ContactId;
            parameters[1].Value = model.Type;
            parameters[2].Value = model.MonthlyIncome;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LPWeb.Model.ProspectOtherIncome model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ProspectOtherIncome set ");
            strSql.Append("ContactId=@ContactId,");
            strSql.Append("Type=@Type,");
            strSql.Append("MonthlyIncome=@MonthlyIncome");
            strSql.Append(" where ProspectOtherIncomeId=@ProspectOtherIncomeId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ContactId",             SqlDbType.Int,        4),
                new SqlParameter("@Type",                  SqlDbType.NVarChar, 100),
                new SqlParameter("@MonthlyIncome",         SqlDbType.Decimal,    5),
                new SqlParameter("@ProspectOtherIncomeId", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ContactId;
            parameters[1].Value = model.Type;
            parameters[2].Value = model.MonthlyIncome;
            parameters[3].Value = model.ProspectOtherIncomeId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LPWeb.Model.ProspectOtherIncome GetModel(int ProspectOtherIncomeId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ProspectOtherIncomeId,ContactId,Type,MonthlyIncome from ProspectOtherIncome ");
            strSql.Append(" where ProspectOtherIncomeId=@ProspectOtherIncomeId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProspectOtherIncomeId", SqlDbType.Int, 4)
            };
            parameters[0].Value = ProspectOtherIncomeId;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ProspectOtherIncomeId"] != null && ds.Tables[0].Rows[0]["ProspectOtherIncomeId"].ToString() != "")
                {
                    model.ProspectOtherIncomeId = int.Parse(ds.Tables[0].Rows[0]["ProspectOtherIncomeId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ContactId"] != null && ds.Tables[0].Rows[0]["ContactId"].ToString() != "")
                {
                    model.ContactId = int.Parse(ds.Tables[0].Rows[0]["ContactId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Type"] != null && ds.Tables[0].Rows[0]["Type"].ToString() != "")
                {
                    model.Type = ds.Tables[0].Rows[0]["Type"].ToString();
                }
                if (ds.Tables[0].Rows[0]["MonthlyIncome"] != null && ds.Tables[0].Rows[0]["MonthlyIncome"].ToString() != "")
                {
                    model.MonthlyIncome = decimal.Parse(ds.Tables[0].Rows[0]["MonthlyIncome"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }