コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CJH.Model.Act_Settlement model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Act_Settlement set ");
            strSql.Append("Section_Start=@Section_Start,");
            strSql.Append("Section_End=@Section_End,");
            strSql.Append("Balance=@Balance,");
            strSql.Append("Curr_Balance=@Curr_Balance");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Section_Start", SqlDbType.DateTime),
                new SqlParameter("@Section_End",   SqlDbType.DateTime),
                new SqlParameter("@Balance",       SqlDbType.Decimal,   9),
                new SqlParameter("@Curr_Balance",  SqlDbType.Decimal,   9),
                new SqlParameter("@ID",            SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Section_Start;
            parameters[1].Value = model.Section_End;
            parameters[2].Value = model.Balance;
            parameters[3].Value = model.Curr_Balance;
            parameters[4].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CJH.Model.Act_Settlement DataRowToModel(DataRow row)
 {
     CJH.Model.Act_Settlement model = new CJH.Model.Act_Settlement();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["Section_Start"] != null && row["Section_Start"].ToString() != "")
         {
             model.Section_Start = DateTime.Parse(row["Section_Start"].ToString());
         }
         if (row["Section_End"] != null && row["Section_End"].ToString() != "")
         {
             model.Section_End = DateTime.Parse(row["Section_End"].ToString());
         }
         if (row["Balance"] != null && row["Balance"].ToString() != "")
         {
             model.Balance = decimal.Parse(row["Balance"].ToString());
         }
         if (row["Curr_Balance"] != null && row["Curr_Balance"].ToString() != "")
         {
             model.Curr_Balance = decimal.Parse(row["Curr_Balance"].ToString());
         }
     }
     return(model);
 }
コード例 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(CJH.Model.Act_Settlement model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Act_Settlement(");
            strSql.Append("Section_Start,Section_End,Balance,Curr_Balance)");
            strSql.Append(" values (");
            strSql.Append("@Section_Start,@Section_End,@Balance,@Curr_Balance)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Section_Start", SqlDbType.DateTime),
                new SqlParameter("@Section_End",   SqlDbType.DateTime),
                new SqlParameter("@Balance",       SqlDbType.Decimal,9),
                new SqlParameter("@Curr_Balance",  SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.Section_Start;
            parameters[1].Value = model.Section_End;
            parameters[2].Value = model.Balance;
            parameters[3].Value = model.Curr_Balance;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CJH.Model.Act_Settlement GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,Section_Start,Section_End,Balance,Curr_Balance from Act_Settlement ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }