Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.VisitLog model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into VisitLog(");
            strSql.Append("IID,VisitDate,StayDate,RPID,OrgId,StaId,CreateDate)");

            strSql.Append(" values (");
            strSql.Append("@IID,@VisitDate,@StayDate,@RPID,@OrgId,@StaId,@CreateDate)");
            strSql.Append(";select @@IDENTITY");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "IID", DbType.Int32, model.IID);
            db.AddInParameter(dbCommand, "VisitDate", DbType.DateTime, model.VisitDate);
            db.AddInParameter(dbCommand, "StayDate", DbType.Int64, model.StayDate);
            db.AddInParameter(dbCommand, "RPID", DbType.Int32, model.RPID);
            db.AddInParameter(dbCommand, "OrgId", DbType.Int64, model.OrgId);
            db.AddInParameter(dbCommand, "StaId", DbType.Int64, model.StaId);
            db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, model.CreateDate);
            int    result;
            object obj = db.ExecuteScalar(dbCommand);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }
Пример #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.VisitLog model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update VisitLog set ");
            strSql.Append("IID=@IID,");
            strSql.Append("VisitDate=@VisitDate,");
            strSql.Append("StayDate=@StayDate,");
            strSql.Append("RPID=@RPID,");
            strSql.Append("OrgId=@OrgId,");
            strSql.Append("StaId=@StaId,");
            strSql.Append("CreateDate=@CreateDate");
            strSql.Append(" where VLID=@VLID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "VLID", DbType.Int32, model.VLID);
            db.AddInParameter(dbCommand, "IID", DbType.Int32, model.IID);
            db.AddInParameter(dbCommand, "VisitDate", DbType.DateTime, model.VisitDate);
            db.AddInParameter(dbCommand, "StayDate", DbType.Int64, model.StayDate);
            db.AddInParameter(dbCommand, "RPID", DbType.Int32, model.RPID);
            db.AddInParameter(dbCommand, "OrgId", DbType.Int64, model.OrgId);
            db.AddInParameter(dbCommand, "StaId", DbType.Int64, model.StaId);
            db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, model.CreateDate);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Model.VisitLog ReaderBind(IDataReader dataReader)
        {
            Model.VisitLog model = new Model.VisitLog();
            object         ojb;

            ojb = dataReader["VLID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.VLID = Convert.ToInt32(ojb);
            }
            ojb = dataReader["IID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IID = Convert.ToInt32(ojb);
            }
            ojb = dataReader["VisitDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.VisitDate = Convert.ToDateTime(ojb);
            }
            ojb = dataReader["StayDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.StayDate = Convert.ToInt64(ojb);
            }
            ojb = dataReader["RPID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.RPID = Convert.ToInt32(ojb);
            }
            ojb = dataReader["OrgId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.OrgId = Convert.ToInt64(ojb);
            }
            ojb = dataReader["StaId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.StaId = Convert.ToInt64(ojb);
            }
            ojb = dataReader["CreateDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CreateDate = Convert.ToDateTime(ojb);
            }
            return(model);
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.VisitLog GetModel(int VLID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select VLID,IID,VisitDate,StayDate,RPID,OrgId,StaId,CreateDate from VisitLog ");
            strSql.Append(" where VLID=@VLID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "VLID", DbType.Int32, VLID);
            Model.VisitLog model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
Пример #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.VisitLog DataRowToModel(DataRow row)
 {
     Model.VisitLog model = new Model.VisitLog();
     if (row != null)
     {
         if (row["VLID"] != null && row["VLID"].ToString() != "")
         {
             model.VLID = Convert.ToInt32(row["VLID"].ToString());
         }
         if (row["IID"] != null && row["IID"].ToString() != "")
         {
             model.IID = Convert.ToInt32(row["IID"].ToString());
         }
         if (row["VisitDate"] != null && row["VisitDate"].ToString() != "")
         {
             model.VisitDate = Convert.ToDateTime(row["VisitDate"].ToString());
         }
         if (row["StayDate"] != null && row["StayDate"].ToString() != "")
         {
             model.StayDate = Convert.ToInt64(row["StayDate"].ToString());
         }
         if (row["RPID"] != null && row["RPID"].ToString() != "")
         {
             model.RPID = Convert.ToInt32(row["RPID"].ToString());
         }
         if (row["OrgId"] != null && row["OrgId"].ToString() != "")
         {
             model.OrgId = Convert.ToInt64(row["OrgId"].ToString());
         }
         if (row["StaId"] != null && row["StaId"].ToString() != "")
         {
             model.StaId = Convert.ToInt64(row["StaId"].ToString());
         }
         if (row["CreateDate"] != null && row["CreateDate"].ToString() != "")
         {
             model.CreateDate = Convert.ToDateTime(row["CreateDate"].ToString());
         }
     }
     return(model);
 }