コード例 #1
0
ファイル: jmp_scheduling.cs プロジェクト: sunman001/dxpay
        /// <summary>
        /// 得到一个对象实体(根据值班日期查询)
        /// </summary>
        public JMP.MDL.jmp_scheduling GetModel(string startDate)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, watchid, watchstartdate, createdon, createdbyid, watchenddate  ,Type");
            strSql.Append("  from jmp_scheduling ");
            strSql.Append(" where watchstartdate=@watchstartdate");
            SqlParameter[] parameters =
            {
                new SqlParameter("@watchstartdate", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = startDate;


            JMP.MDL.jmp_scheduling model = new JMP.MDL.jmp_scheduling();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["watchid"].ToString() != "")
                {
                    model.watchid = int.Parse(ds.Tables[0].Rows[0]["watchid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["watchstartdate"].ToString() != "")
                {
                    model.watchstartdate = DateTime.Parse(ds.Tables[0].Rows[0]["watchstartdate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["createdon"].ToString() != "")
                {
                    model.createdon = DateTime.Parse(ds.Tables[0].Rows[0]["createdon"].ToString());
                }
                if (ds.Tables[0].Rows[0]["createdbyid"].ToString() != "")
                {
                    model.createdbyid = int.Parse(ds.Tables[0].Rows[0]["createdbyid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["watchenddate"].ToString() != "")
                {
                    model.watchenddate = DateTime.Parse(ds.Tables[0].Rows[0]["watchenddate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Type"].ToString() != "")
                {
                    model.Type = int.Parse(ds.Tables[0].Rows[0]["Type"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: jmp_scheduling.cs プロジェクト: sunman001/dxpay
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(JMP.MDL.jmp_scheduling model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update jmp_scheduling set ");

            strSql.Append(" watchid = @watchid , ");
            strSql.Append(" watchstartdate = @watchstartdate , ");
            strSql.Append(" createdon = @createdon , ");
            strSql.Append(" createdbyid = @createdbyid , ");
            strSql.Append(" watchenddate = @watchenddate, ");
            strSql.Append(" Type = @Type");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",             SqlDbType.Int,       4),
                new SqlParameter("@watchid",        SqlDbType.Int,       4),
                new SqlParameter("@watchstartdate", SqlDbType.DateTime),
                new SqlParameter("@createdon",      SqlDbType.DateTime),
                new SqlParameter("@createdbyid",    SqlDbType.Int,       4),
                new SqlParameter("@watchenddate",   SqlDbType.DateTime),
                new SqlParameter("@Type",           SqlDbType.Int, 4)
            };

            parameters[0].Value = model.id;
            parameters[1].Value = model.watchid;
            parameters[2].Value = model.watchstartdate;
            parameters[3].Value = model.createdon;
            parameters[4].Value = model.createdbyid;
            parameters[5].Value = model.watchenddate;
            parameters[6].Value = model.Type;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <JMP.MDL.jmp_scheduling> DataTableToList(DataTable dt)
        {
            List <JMP.MDL.jmp_scheduling> modelList = new List <JMP.MDL.jmp_scheduling>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                JMP.MDL.jmp_scheduling model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new JMP.MDL.jmp_scheduling();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    if (dt.Rows[n]["watchid"].ToString() != "")
                    {
                        model.watchid = int.Parse(dt.Rows[n]["watchid"].ToString());
                    }
                    if (dt.Rows[n]["watchstartdate"].ToString() != "")
                    {
                        model.watchstartdate = DateTime.Parse(dt.Rows[n]["watchstartdate"].ToString());
                    }
                    if (dt.Rows[n]["createdon"].ToString() != "")
                    {
                        model.createdon = DateTime.Parse(dt.Rows[n]["createdon"].ToString());
                    }
                    if (dt.Rows[n]["createdbyid"].ToString() != "")
                    {
                        model.createdbyid = int.Parse(dt.Rows[n]["createdbyid"].ToString());
                    }
                    if (dt.Rows[n]["watchenddate"].ToString() != "")
                    {
                        model.watchenddate = DateTime.Parse(dt.Rows[n]["watchenddate"].ToString());
                    }


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
コード例 #4
0
ファイル: jmp_scheduling.cs プロジェクト: sunman001/dxpay
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(JMP.MDL.jmp_scheduling model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into jmp_scheduling(");
            strSql.Append("watchid,watchstartdate,createdon,createdbyid,watchenddate,Type");
            strSql.Append(") values (");
            strSql.Append("@watchid,@watchstartdate,@createdon,@createdbyid,@watchenddate,@Type");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@watchid",        SqlDbType.Int,       4),
                new SqlParameter("@watchstartdate", SqlDbType.DateTime),
                new SqlParameter("@createdon",      SqlDbType.DateTime),
                new SqlParameter("@createdbyid",    SqlDbType.Int,       4),
                new SqlParameter("@watchenddate",   SqlDbType.DateTime),
                new SqlParameter("@Type",           SqlDbType.Int, 4)
            };

            parameters[0].Value = model.watchid;
            parameters[1].Value = model.watchstartdate;
            parameters[2].Value = model.createdon;
            parameters[3].Value = model.createdbyid;
            parameters[4].Value = model.watchenddate;
            parameters[5].Value = model.Type;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(JMP.MDL.jmp_scheduling model)
 {
     return(dal.Update(model));
 }
コード例 #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(JMP.MDL.jmp_scheduling model)
 {
     return(dal.Add(model));
 }