Пример #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DataTable  GetTableModel(int Id)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            var model = new Sys.Model.Attendance();
            var ds    = DbHelperSQL.RunProcedure("Attendance_GetModel", parameters, "ds");

            return(ds.Tables[0]);
        }
Пример #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Sys.Model.Attendance GetModel(int Id)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            var model = new Sys.Model.Attendance();
            var ds    = DbHelperSQL.RunProcedure("Attendance_GetModel", parameters, "ds");

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ICcode"] != null && ds.Tables[0].Rows[0]["ICcode"].ToString() != "")
                {
                    model.ICcode = ds.Tables[0].Rows[0]["ICcode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SId"] != null && ds.Tables[0].Rows[0]["SId"].ToString() != "")
                {
                    model.SId = int.Parse(ds.Tables[0].Rows[0]["SId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreateTime"] != null && ds.Tables[0].Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreateIp"] != null && ds.Tables[0].Rows[0]["CreateIp"].ToString() != "")
                {
                    model.CreateIp = ds.Tables[0].Rows[0]["CreateIp"].ToString();
                }
                if (ds.Tables[0].Rows[0]["MendSign"] != null && ds.Tables[0].Rows[0]["MendSign"].ToString() != "")
                {
                    model.MendSign = int.Parse(ds.Tables[0].Rows[0]["MendSign"].ToString());
                }
                return(model);
            }
            return(null);
        }
Пример #3
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Sys.Model.Attendance> DataTableToList(DataTable dt)
        {
            var modelList = new List <Sys.Model.Attendance>();
            var rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Sys.Model.Attendance model;
                for (var n = 0; n < rowsCount; n++)
                {
                    model = new Sys.Model.Attendance();
                    if (dt.Rows[n]["Id"] != null && dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    if (dt.Rows[n]["ICcode"] != null && dt.Rows[n]["ICcode"].ToString() != "")
                    {
                        model.ICcode = dt.Rows[n]["ICcode"].ToString();
                    }
                    if (dt.Rows[n]["SId"] != null && dt.Rows[n]["SId"].ToString() != "")
                    {
                        model.SId = int.Parse(dt.Rows[n]["SId"].ToString());
                    }
                    if (dt.Rows[n]["CreateTime"] != null && dt.Rows[n]["CreateTime"].ToString() != "")
                    {
                        model.CreateTime = DateTime.Parse(dt.Rows[n]["CreateTime"].ToString());
                    }
                    if (dt.Rows[n]["CreateIp"] != null && dt.Rows[n]["CreateIp"].ToString() != "")
                    {
                        model.CreateIp = dt.Rows[n]["CreateIp"].ToString();
                    }
                    if (dt.Rows[n]["MendSign"] != null && dt.Rows[n]["MendSign"].ToString() != "")
                    {
                        model.MendSign = int.Parse(dt.Rows[n]["MendSign"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Пример #4
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public bool Update(Sys.Model.Attendance model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",         SqlDbType.Int,        4),
                new SqlParameter("@ICcode",     SqlDbType.VarChar,   50),
                new SqlParameter("@SId",        SqlDbType.Int,        4),
                new SqlParameter("@CreateTime", SqlDbType.DateTime),
                new SqlParameter("@CreateIp",   SqlDbType.VarChar,   50),
                new SqlParameter("@MendSign",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Id;
            parameters[1].Value = model.ICcode;
            parameters[2].Value = model.SId;
            parameters[3].Value = model.CreateTime;
            parameters[4].Value = model.CreateIp;
            parameters[5].Value = model.MendSign;

            DbHelperSQL.RunProcedure("Attendance_Update", parameters, out rowsAffected);
            return(rowsAffected > 0);
        }
Пример #5
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Add(Sys.Model.Attendance model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",         SqlDbType.Int,        4),
                new SqlParameter("@ICcode",     SqlDbType.VarChar,   50),
                new SqlParameter("@SId",        SqlDbType.Int,        4),
                new SqlParameter("@CreateTime", SqlDbType.DateTime),
                new SqlParameter("@CreateIp",   SqlDbType.VarChar,   50),
                new SqlParameter("@MendSign",   SqlDbType.Int, 4)
            };
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = model.ICcode;
            parameters[2].Value     = model.SId;
            parameters[3].Value     = model.CreateTime;
            parameters[4].Value     = model.CreateIp;
            parameters[5].Value     = model.MendSign;

            DbHelperSQL.RunProcedure("Attendance_ADD", parameters, out rowsAffected);
            return((int)parameters[0].Value);
        }
Пример #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Sys.Model.Attendance model)
 {
     return(_dal.Update(model));
 }
Пример #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Sys.Model.Attendance model)
 {
     return(_dal.Add(model));
 }