Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.T_ReturnCommand model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_ReturnCommand set ");
            strSql.Append("MNCode=@MNCode,");
            strSql.Append("DevCode=@DevCode,");
            strSql.Append("OrderCode=@OrderCode,");
            strSql.Append("OrderName=@OrderName,");
            strSql.Append("OrderText=@OrderText,");
            strSql.Append("WriteTime=@WriteTime");
            strSql.Append(" where OrderID=@OrderID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MNCode",    SqlDbType.NVarChar,   50),
                new SqlParameter("@DevCode",   SqlDbType.NVarChar,   50),
                new SqlParameter("@OrderCode", SqlDbType.NVarChar,   50),
                new SqlParameter("@OrderName", SqlDbType.NVarChar,  255),
                new SqlParameter("@OrderText", SqlDbType.NVarChar,  255),
                new SqlParameter("@WriteTime", SqlDbType.DateTime),
                new SqlParameter("@OrderID",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.MNCode;
            parameters[1].Value = model.DevCode;
            parameters[2].Value = model.OrderCode;
            parameters[3].Value = model.OrderName;
            parameters[4].Value = model.OrderText;
            parameters[5].Value = model.WriteTime;
            parameters[6].Value = model.OrderID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.T_ReturnCommand DataRowToModel(DataRow row)
 {
     Maticsoft.Model.T_ReturnCommand model = new Maticsoft.Model.T_ReturnCommand();
     if (row != null)
     {
         if (row["OrderID"] != null && row["OrderID"].ToString() != "")
         {
             model.OrderID = int.Parse(row["OrderID"].ToString());
         }
         if (row["MNCode"] != null)
         {
             model.MNCode = row["MNCode"].ToString();
         }
         if (row["DevCode"] != null)
         {
             model.DevCode = row["DevCode"].ToString();
         }
         if (row["OrderCode"] != null)
         {
             model.OrderCode = row["OrderCode"].ToString();
         }
         if (row["OrderName"] != null)
         {
             model.OrderName = row["OrderName"].ToString();
         }
         if (row["OrderText"] != null)
         {
             model.OrderText = row["OrderText"].ToString();
         }
         if (row["WriteTime"] != null && row["WriteTime"].ToString() != "")
         {
             model.WriteTime = DateTime.Parse(row["WriteTime"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.T_ReturnCommand model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_ReturnCommand(");
            strSql.Append("MNCode,DevCode,OrderCode,OrderName,OrderText,WriteTime)");
            strSql.Append(" values (");
            strSql.Append("@MNCode,@DevCode,@OrderCode,@OrderName,@OrderText,@WriteTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MNCode",    SqlDbType.NVarChar,  50),
                new SqlParameter("@DevCode",   SqlDbType.NVarChar,  50),
                new SqlParameter("@OrderCode", SqlDbType.NVarChar,  50),
                new SqlParameter("@OrderName", SqlDbType.NVarChar, 255),
                new SqlParameter("@OrderText", SqlDbType.NVarChar, 255),
                new SqlParameter("@WriteTime", SqlDbType.DateTime)
            };
            parameters[0].Value = model.MNCode;
            parameters[1].Value = model.DevCode;
            parameters[2].Value = model.OrderCode;
            parameters[3].Value = model.OrderName;
            parameters[4].Value = model.OrderText;
            parameters[5].Value = model.WriteTime;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.T_ReturnCommand GetModel(int OrderID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 OrderID,MNCode,DevCode,OrderCode,OrderName,OrderText,WriteTime from T_ReturnCommand ");
            strSql.Append(" where OrderID=@OrderID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@OrderID", SqlDbType.Int, 4)
            };
            parameters[0].Value = OrderID;

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

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