예제 #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MesWeb.Model.T_EmployeeState DataRowToModel(DataRow row)
 {
     MesWeb.Model.T_EmployeeState model = new MesWeb.Model.T_EmployeeState();
     if (row != null)
     {
         if (row["EmployeeStateID"] != null && row["EmployeeStateID"].ToString() != "")
         {
             model.EmployeeStateID = int.Parse(row["EmployeeStateID"].ToString());
         }
         if (row["EmployeeID"] != null && row["EmployeeID"].ToString() != "")
         {
             model.EmployeeID = int.Parse(row["EmployeeID"].ToString());
         }
         if (row["State"] != null && row["State"].ToString() != "")
         {
             if ((row["State"].ToString() == "1") || (row["State"].ToString().ToLower() == "true"))
             {
                 model.State = true;
             }
             else
             {
                 model.State = false;
             }
         }
     }
     return(model);
 }
예제 #2
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(MesWeb.Model.T_EmployeeState model)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("T_EmployeeState_Update");

            db.AddInParameter(dbCommand, "EmployeeStateID", DbType.Int32, model.EmployeeStateID);
            db.AddInParameter(dbCommand, "EmployeeID", DbType.Int32, model.EmployeeID);
            db.AddInParameter(dbCommand, "State", DbType.Boolean, model.State);
            db.ExecuteNonQuery(dbCommand);
        }
예제 #3
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Add(MesWeb.Model.T_EmployeeState model)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("T_EmployeeState_ADD");

            db.AddOutParameter(dbCommand, "EmployeeStateID", DbType.Int32, 4);
            db.AddInParameter(dbCommand, "EmployeeID", DbType.Int32, model.EmployeeID);
            db.AddInParameter(dbCommand, "State", DbType.Boolean, model.State);
            db.ExecuteNonQuery(dbCommand);
            return((int)db.GetParameterValue(dbCommand, "EmployeeStateID"));
        }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MesWeb.Model.T_EmployeeState GetModel(int EmployeeStateID)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("T_EmployeeState_GetModel");

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

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

            ojb = dataReader["EmployeeStateID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.EmployeeStateID = (int)ojb;
            }
            ojb = dataReader["EmployeeID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.EmployeeID = (int)ojb;
            }
            ojb = dataReader["State"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.State = (bool)ojb;
            }
            return(model);
        }