Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CuXiaoModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CORE.dbo.CuXiao (");
            strSql.Append("MerId,BranchId,CuXiaoLabel,Invalid,ZoneId,CuXiaoName,CuXiaoContent,CreateTime,CreateUser,PyCode,BgTime,EndTime,Status");
            strSql.Append(") values (");
            strSql.Append("@MerId,@BranchId,@CuXiaoLabel,@Invalid,@ZoneId,@CuXiaoName,@CuXiaoContent,@CreateTime,@CreateUser,@PyCode,@BgTime,@EndTime,@Status");
            strSql.Append(") ");
            strSql.Append(";");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MerId",         SqlDbType.Decimal,     9),
                new SqlParameter("@BranchId",      SqlDbType.VarChar,    50),
                new SqlParameter("@CuXiaoLabel",   SqlDbType.VarChar,    50),
                new SqlParameter("@Invalid",       SqlDbType.Bit,         1),
                new SqlParameter("@ZoneId",        SqlDbType.VarChar,    50),
                new SqlParameter("@CuXiaoName",    SqlDbType.VarChar,   250),
                new SqlParameter("@CuXiaoContent", SqlDbType.VarChar,   500),
                new SqlParameter("@CreateTime",    SqlDbType.DateTime),
                new SqlParameter("@CreateUser",    SqlDbType.VarChar,    50),
                new SqlParameter("@PyCode",        SqlDbType.VarChar,   250),
                new SqlParameter("@BgTime",        SqlDbType.DateTime),
                new SqlParameter("@EndTime",       SqlDbType.DateTime),
                new SqlParameter("@Status",        SqlDbType.Int, 4)
            };

            parameters[0].Value  = model.MerId;
            parameters[1].Value  = model.BranchId;
            parameters[2].Value  = model.CuXiaoLabel;
            parameters[3].Value  = model.Invalid;
            parameters[4].Value  = model.ZoneId;
            parameters[5].Value  = model.CuXiaoName;
            parameters[6].Value  = model.CuXiaoContent;
            parameters[7].Value  = model.CreateTime;
            parameters[8].Value  = model.CreateUser;
            parameters[9].Value  = model.PyCode;
            parameters[10].Value = model.BgTime;
            parameters[11].Value = model.EndTime;
            parameters[12].Value = model.Status;

            bool result = false;

            try
            {
                model.CuXiaoId = decimal.Parse(helper.ExecuteNonQueryBackId(strSql.ToString(), "CuXiaoId", parameters));


                result = true;
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            finally
            {
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CuXiaoModel GetModel(decimal CuXiaoId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select CuXiaoId, MerId, BranchId, CuXiaoLabel, Invalid, ZoneId, CuXiaoName, CuXiaoContent, CreateTime, CreateUser, PyCode, BgTime, EndTime, Status  ");
            strSql.Append("  from CORE.dbo.CuXiao ");
            strSql.Append(" where CuXiaoId=@CuXiaoId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CuXiaoId", SqlDbType.Decimal)
            };
            parameters[0].Value = CuXiaoId;


            CuXiaoModel model = new CuXiaoModel();
            DataSet     ds    = helper.ExecSqlReDs(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["CuXiaoId"].ToString() != "")
                {
                    model.CuXiaoId = decimal.Parse(ds.Tables[0].Rows[0]["CuXiaoId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MerId"].ToString() != "")
                {
                    model.MerId = decimal.Parse(ds.Tables[0].Rows[0]["MerId"].ToString());
                }
                model.BranchId    = ds.Tables[0].Rows[0]["BranchId"].ToString();
                model.CuXiaoLabel = ds.Tables[0].Rows[0]["CuXiaoLabel"].ToString();
                if (ds.Tables[0].Rows[0]["Invalid"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Invalid"].ToString() == "1") || (ds.Tables[0].Rows[0]["Invalid"].ToString().ToLower() == "true"))
                    {
                        model.Invalid = true;
                    }
                    else
                    {
                        model.Invalid = false;
                    }
                }
                model.ZoneId        = ds.Tables[0].Rows[0]["ZoneId"].ToString();
                model.CuXiaoName    = ds.Tables[0].Rows[0]["CuXiaoName"].ToString();
                model.CuXiaoContent = ds.Tables[0].Rows[0]["CuXiaoContent"].ToString();
                if (ds.Tables[0].Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
                }
                model.CreateUser = ds.Tables[0].Rows[0]["CreateUser"].ToString();
                model.PyCode     = ds.Tables[0].Rows[0]["PyCode"].ToString();
                if (ds.Tables[0].Rows[0]["BgTime"].ToString() != "")
                {
                    model.BgTime = DateTime.Parse(ds.Tables[0].Rows[0]["BgTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EndTime"].ToString() != "")
                {
                    model.EndTime = DateTime.Parse(ds.Tables[0].Rows[0]["EndTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Status"].ToString() != "")
                {
                    model.Status = int.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
                }

                return(model);
            }
            else
            {
                return(model);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CuXiaoModel model)
        {
            bool          reValue = true;
            int           reCount = 0;
            StringBuilder strSql  = new StringBuilder();

            strSql.Append("update CORE.dbo.CuXiao set ");

            strSql.Append(" MerId = @MerId , ");
            strSql.Append(" BranchId = @BranchId , ");
            strSql.Append(" CuXiaoLabel = @CuXiaoLabel , ");
            strSql.Append(" Invalid = @Invalid , ");
            strSql.Append(" ZoneId = @ZoneId , ");
            strSql.Append(" CuXiaoName = @CuXiaoName , ");
            strSql.Append(" CuXiaoContent = @CuXiaoContent , ");
            strSql.Append(" CreateTime = @CreateTime , ");
            strSql.Append(" CreateUser = @CreateUser , ");
            strSql.Append(" PyCode = @PyCode , ");
            strSql.Append(" BgTime = @BgTime , ");
            strSql.Append(" EndTime = @EndTime , ");
            strSql.Append(" Status = @Status  ");
            strSql.Append(" where CuXiaoId=@CuXiaoId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@CuXiaoId",      SqlDbType.Decimal,     9),
                new SqlParameter("@MerId",         SqlDbType.Decimal,     9),
                new SqlParameter("@BranchId",      SqlDbType.VarChar,    50),
                new SqlParameter("@CuXiaoLabel",   SqlDbType.VarChar,    50),
                new SqlParameter("@Invalid",       SqlDbType.Bit,         1),
                new SqlParameter("@ZoneId",        SqlDbType.VarChar,    50),
                new SqlParameter("@CuXiaoName",    SqlDbType.VarChar,   250),
                new SqlParameter("@CuXiaoContent", SqlDbType.VarChar,   500),
                new SqlParameter("@CreateTime",    SqlDbType.DateTime),
                new SqlParameter("@CreateUser",    SqlDbType.VarChar,    50),
                new SqlParameter("@PyCode",        SqlDbType.VarChar,   250),
                new SqlParameter("@BgTime",        SqlDbType.DateTime),
                new SqlParameter("@EndTime",       SqlDbType.DateTime),
                new SqlParameter("@Status",        SqlDbType.Int, 4)
            };

            parameters[0].Value  = model.CuXiaoId;
            parameters[1].Value  = model.MerId;
            parameters[2].Value  = model.BranchId;
            parameters[3].Value  = model.CuXiaoLabel;
            parameters[4].Value  = model.Invalid;
            parameters[5].Value  = model.ZoneId;
            parameters[6].Value  = model.CuXiaoName;
            parameters[7].Value  = model.CuXiaoContent;
            parameters[8].Value  = model.CreateTime;
            parameters[9].Value  = model.CreateUser;
            parameters[10].Value = model.PyCode;
            parameters[11].Value = model.BgTime;
            parameters[12].Value = model.EndTime;
            parameters[13].Value = model.Status; try
            {//异常处理
                reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters);
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            if (reCount <= 0)
            {
                reValue = false;
            }
            return(reValue);
        }