Exemple #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MesWeb.Model.T_Product DataRowToModel(DataRow row)
 {
     MesWeb.Model.T_Product model = new MesWeb.Model.T_Product();
     if (row != null)
     {
         if (row["ProductID"] != null && row["ProductID"].ToString() != "")
         {
             model.ProductID = int.Parse(row["ProductID"].ToString());
         }
         if (row["ProductZoneID"] != null && row["ProductZoneID"].ToString() != "")
         {
             model.ProductZoneID = int.Parse(row["ProductZoneID"].ToString());
         }
         if (row["Axis_No"] != null && row["Axis_No"].ToString() != "")
         {
             model.Axis_No = int.Parse(row["Axis_No"].ToString());
         }
         if (row["OperatorID"] != null && row["OperatorID"].ToString() != "")
         {
             model.OperatorID = int.Parse(row["OperatorID"].ToString());
         }
         if (row["DateTime"] != null && row["DateTime"].ToString() != "")
         {
             model.DateTime = DateTime.Parse(row["DateTime"].ToString());
         }
         if (row["Length"] != null && row["Length"].ToString() != "")
         {
             model.Length = decimal.Parse(row["Length"].ToString());
         }
     }
     return(model);
 }
Exemple #2
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(MesWeb.Model.T_Product model)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("T_Product_Update");

            db.AddInParameter(dbCommand, "ProductID", DbType.Int32, model.ProductID);
            db.AddInParameter(dbCommand, "ProductZoneID", DbType.Int32, model.ProductZoneID);
            db.AddInParameter(dbCommand, "Axis_No", DbType.Int32, model.Axis_No);
            db.AddInParameter(dbCommand, "OperatorID", DbType.Int32, model.OperatorID);
            db.AddInParameter(dbCommand, "DateTime", DbType.DateTime, model.DateTime);
            db.AddInParameter(dbCommand, "Length", DbType.Double, model.Length);
            db.ExecuteNonQuery(dbCommand);
        }
Exemple #3
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Add(MesWeb.Model.T_Product model)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("T_Product_ADD");

            db.AddOutParameter(dbCommand, "ProductID", DbType.Int32, 4);
            db.AddInParameter(dbCommand, "ProductZoneID", DbType.Int32, model.ProductZoneID);
            db.AddInParameter(dbCommand, "Axis_No", DbType.Int32, model.Axis_No);
            db.AddInParameter(dbCommand, "OperatorID", DbType.Int32, model.OperatorID);
            db.AddInParameter(dbCommand, "DateTime", DbType.DateTime, model.DateTime);
            db.AddInParameter(dbCommand, "Length", DbType.Double, model.Length);
            db.ExecuteNonQuery(dbCommand);
            return((int)db.GetParameterValue(dbCommand, "ProductID"));
        }
Exemple #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MesWeb.Model.T_Product GetModel(int ProductID)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("T_Product_GetModel");

            db.AddInParameter(dbCommand, "ProductID", DbType.Int32, ProductID);

            MesWeb.Model.T_Product model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
Exemple #5
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public MesWeb.Model.T_Product ReaderBind(IDataReader dataReader)
        {
            MesWeb.Model.T_Product model = new MesWeb.Model.T_Product();
            object ojb;

            ojb = dataReader["ProductID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ProductID = (int)ojb;
            }
            ojb = dataReader["ProductZoneID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ProductZoneID = (int)ojb;
            }
            ojb = dataReader["Axis_No"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Axis_No = (int)ojb;
            }
            ojb = dataReader["OperatorID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.OperatorID = (int)ojb;
            }
            ojb = dataReader["DateTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.DateTime = (DateTime)ojb;
            }
            ojb = dataReader["Length"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Length = (decimal)ojb;
            }
            return(model);
        }