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

            strSql.Append("insert into LoanRules(");
            strSql.Append("Fileid,RuleGroupId,RuleId,Applied,AppliedBy)");
            strSql.Append(" values (");
            strSql.Append("@Fileid,@RuleGroupId,@RuleId,@Applied,@AppliedBy)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Fileid",      SqlDbType.Int,       4),
                new SqlParameter("@RuleGroupId", SqlDbType.Int,       4),
                new SqlParameter("@RuleId",      SqlDbType.Int,       4),
                new SqlParameter("@Applied",     SqlDbType.DateTime),
                new SqlParameter("@AppliedBy",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Fileid;
            parameters[1].Value = model.RuleGroupId;
            parameters[2].Value = model.RuleId;
            parameters[3].Value = model.Applied;
            parameters[4].Value = model.AppliedBy;

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

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

            strSql.Append("update LoanRules set ");
            strSql.Append("LoanRuleId=@LoanRuleId,");
            strSql.Append("Fileid=@Fileid,");
            strSql.Append("RuleGroupId=@RuleGroupId,");
            strSql.Append("RuleId=@RuleId,");
            strSql.Append("Applied=@Applied,");
            strSql.Append("AppliedBy=@AppliedBy");
            strSql.Append(" where LoanRuleId=@LoanRuleId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LoanRuleId",  SqlDbType.Int,       4),
                new SqlParameter("@Fileid",      SqlDbType.Int,       4),
                new SqlParameter("@RuleGroupId", SqlDbType.Int,       4),
                new SqlParameter("@RuleId",      SqlDbType.Int,       4),
                new SqlParameter("@Applied",     SqlDbType.DateTime),
                new SqlParameter("@AppliedBy",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.LoanRuleId;
            parameters[1].Value = model.Fileid;
            parameters[2].Value = model.RuleGroupId;
            parameters[3].Value = model.RuleId;
            parameters[4].Value = model.Applied;
            parameters[5].Value = model.AppliedBy;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LPWeb.Model.LoanRules GetModel(int LoanRuleId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 LoanRuleId,Fileid,RuleGroupId,RuleId,Applied,AppliedBy from LoanRules ");
            strSql.Append(" where LoanRuleId=@LoanRuleId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LoanRuleId", SqlDbType.Int, 4)
            };
            parameters[0].Value = LoanRuleId;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["LoanRuleId"].ToString() != "")
                {
                    model.LoanRuleId = int.Parse(ds.Tables[0].Rows[0]["LoanRuleId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fileid"].ToString() != "")
                {
                    model.Fileid = int.Parse(ds.Tables[0].Rows[0]["Fileid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["RuleGroupId"].ToString() != "")
                {
                    model.RuleGroupId = int.Parse(ds.Tables[0].Rows[0]["RuleGroupId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["RuleId"].ToString() != "")
                {
                    model.RuleId = int.Parse(ds.Tables[0].Rows[0]["RuleId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Applied"].ToString() != "")
                {
                    model.Applied = DateTime.Parse(ds.Tables[0].Rows[0]["Applied"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AppliedBy"].ToString() != "")
                {
                    model.AppliedBy = int.Parse(ds.Tables[0].Rows[0]["AppliedBy"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }