Exemplo n.º 1
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Model.OrgWorkStation ReaderBind(IDataReader dataReader)
        {
            Model.OrgWorkStation model = new Model.OrgWorkStation();
            object ojb;

            ojb = dataReader["WId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.WId = Convert.ToInt32(ojb);
            }
            ojb = dataReader["OrgId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.OrgId = Convert.ToInt64(ojb);
            }
            model.Size         = dataReader["Size"].ToString();
            model.Area         = dataReader["Area"].ToString();
            model.Manager      = dataReader["Manager"].ToString();
            model.ManagerPhone = dataReader["ManagerPhone"].ToString();
            ojb = dataReader["StartTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.StartTime = Convert.ToDateTime(ojb);
            }
            model.ToolsMemo = dataReader["ToolsMemo"].ToString();
            return(model);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.OrgWorkStation model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into OrgWorkStation(");
            strSql.Append("OrgId,Size,Area,Manager,ManagerPhone,StartTime,ToolsMemo)");

            strSql.Append(" values (");
            strSql.Append("@OrgId,@Size,@Area,@Manager,@ManagerPhone,@StartTime,@ToolsMemo)");
            strSql.Append(";select @@IDENTITY");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "OrgId", DbType.Int64, model.OrgId);
            db.AddInParameter(dbCommand, "Size", DbType.String, model.Size);
            db.AddInParameter(dbCommand, "Area", DbType.String, model.Area);
            db.AddInParameter(dbCommand, "Manager", DbType.String, model.Manager);
            db.AddInParameter(dbCommand, "ManagerPhone", DbType.AnsiString, model.ManagerPhone);
            db.AddInParameter(dbCommand, "StartTime", DbType.DateTime, model.StartTime);
            db.AddInParameter(dbCommand, "ToolsMemo", DbType.String, model.ToolsMemo);
            int    result;
            object obj = db.ExecuteScalar(dbCommand);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.OrgWorkStation model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update OrgWorkStation set ");
            strSql.Append("OrgId=@OrgId,");
            strSql.Append("Size=@Size,");
            strSql.Append("Area=@Area,");
            strSql.Append("Manager=@Manager,");
            strSql.Append("ManagerPhone=@ManagerPhone,");
            strSql.Append("StartTime=@StartTime,");
            strSql.Append("ToolsMemo=@ToolsMemo");
            strSql.Append(" where WId=@WId ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "WId", DbType.Int32, model.WId);
            db.AddInParameter(dbCommand, "OrgId", DbType.Int64, model.OrgId);
            db.AddInParameter(dbCommand, "Size", DbType.String, model.Size);
            db.AddInParameter(dbCommand, "Area", DbType.String, model.Area);
            db.AddInParameter(dbCommand, "Manager", DbType.String, model.Manager);
            db.AddInParameter(dbCommand, "ManagerPhone", DbType.AnsiString, model.ManagerPhone);
            db.AddInParameter(dbCommand, "StartTime", DbType.DateTime, model.StartTime);
            db.AddInParameter(dbCommand, "ToolsMemo", DbType.String, model.ToolsMemo);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.OrgWorkStation GetModel(int WId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select WId,OrgId,Size,Area,Manager,ManagerPhone,StartTime,ToolsMemo from OrgWorkStation ");
            strSql.Append(" where WId=@WId ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "WId", DbType.Int32, WId);
            Model.OrgWorkStation model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.OrgWorkStation DataRowToModel(DataRow row)
 {
     Model.OrgWorkStation model = new Model.OrgWorkStation();
     if (row != null)
     {
         if (row["WId"] != null && row["WId"].ToString() != "")
         {
             model.WId = Convert.ToInt32(row["WId"].ToString());
         }
         if (row["OrgId"] != null && row["OrgId"].ToString() != "")
         {
             model.OrgId = Convert.ToInt64(row["OrgId"].ToString());
         }
         if (row["Size"] != null)
         {
             model.Size = row["Size"].ToString();
         }
         if (row["Area"] != null)
         {
             model.Area = row["Area"].ToString();
         }
         if (row["Manager"] != null)
         {
             model.Manager = row["Manager"].ToString();
         }
         if (row["ManagerPhone"] != null)
         {
             model.ManagerPhone = row["ManagerPhone"].ToString();
         }
         if (row["StartTime"] != null && row["StartTime"].ToString() != "")
         {
             model.StartTime = Convert.ToDateTime(row["StartTime"].ToString());
         }
         if (row["ToolsMemo"] != null)
         {
             model.ToolsMemo = row["ToolsMemo"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.OrgWorkStation DataRowToModel(DataRow row)
 {
     Model.OrgWorkStation model=new Model.OrgWorkStation();
     if (row != null)
     {
         if(row["WId"]!=null && row["WId"].ToString()!="")
         {
             model.WId=Convert.ToInt32(row["WId"].ToString());
         }
         if(row["OrgId"]!=null && row["OrgId"].ToString()!="")
         {
             model.OrgId=Convert.ToInt64(row["OrgId"].ToString());
         }
         if(row["Size"]!=null)
         {
             model.Size=row["Size"].ToString();
         }
         if(row["Area"]!=null)
         {
             model.Area=row["Area"].ToString();
         }
         if(row["Manager"]!=null)
         {
             model.Manager=row["Manager"].ToString();
         }
         if(row["ManagerPhone"]!=null)
         {
             model.ManagerPhone=row["ManagerPhone"].ToString();
         }
         if(row["StartTime"]!=null && row["StartTime"].ToString()!="")
         {
             model.StartTime=Convert.ToDateTime(row["StartTime"].ToString());
         }
         if(row["ToolsMemo"]!=null)
         {
             model.ToolsMemo=row["ToolsMemo"].ToString();
         }
     }
     return model;
 }
Exemplo n.º 7
0
 /// <summary>
 /// 对象实体绑定数据
 /// </summary>
 public Model.OrgWorkStation ReaderBind(IDataReader dataReader)
 {
     Model.OrgWorkStation model=new Model.OrgWorkStation();
     object ojb;
     ojb = dataReader["WId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.WId=Convert.ToInt32(ojb);
     }
     ojb = dataReader["OrgId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.OrgId=Convert.ToInt64(ojb);
     }
     model.Size=dataReader["Size"].ToString();
     model.Area=dataReader["Area"].ToString();
     model.Manager=dataReader["Manager"].ToString();
     model.ManagerPhone=dataReader["ManagerPhone"].ToString();
     ojb = dataReader["StartTime"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.StartTime=Convert.ToDateTime(ojb);
     }
     model.ToolsMemo=dataReader["ToolsMemo"].ToString();
     return model;
 }