Пример #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ForKids.DB.Model.DEVICEBASE GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,NAME,FUNDING,LOSSINFO,PURCHASEPLAN,INVESTMENT,PURCHASEDATE,DESCRIPTION from DEVICEBASE ");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@ID", OleDbType.Integer, 4)
            };
            parameters[0].Value = ID;

            ForKids.DB.Model.DEVICEBASE model = new ForKids.DB.Model.DEVICEBASE();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString(), parameters);

            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]["NAME"] != null && ds.Tables[0].Rows[0]["NAME"].ToString() != "")
                {
                    model.NAME = ds.Tables[0].Rows[0]["NAME"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FUNDING"] != null && ds.Tables[0].Rows[0]["FUNDING"].ToString() != "")
                {
                    model.FUNDING = double.Parse(ds.Tables[0].Rows[0]["FUNDING"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LOSSINFO"] != null && ds.Tables[0].Rows[0]["LOSSINFO"].ToString() != "")
                {
                    model.LOSSINFO = ds.Tables[0].Rows[0]["LOSSINFO"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PURCHASEPLAN"] != null && ds.Tables[0].Rows[0]["PURCHASEPLAN"].ToString() != "")
                {
                    model.PURCHASEPLAN = ds.Tables[0].Rows[0]["PURCHASEPLAN"].ToString();
                }
                if (ds.Tables[0].Rows[0]["INVESTMENT"] != null && ds.Tables[0].Rows[0]["INVESTMENT"].ToString() != "")
                {
                    //model.INVESTMENT=ds.Tables[0].Rows[0]["INVESTMENT"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PURCHASEDATE"] != null && ds.Tables[0].Rows[0]["PURCHASEDATE"].ToString() != "")
                {
                    model.PURCHASEDATE = DateTime.Parse(ds.Tables[0].Rows[0]["PURCHASEDATE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DESCRIPTION"] != null && ds.Tables[0].Rows[0]["DESCRIPTION"].ToString() != "")
                {
                    model.DESCRIPTION = ds.Tables[0].Rows[0]["DESCRIPTION"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ForKids.DB.Model.DEVICEBASE model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update DEVICEBASE set ");
            strSql.Append("NAME=@NAME,");
            strSql.Append("FUNDING=@FUNDING,");
            strSql.Append("LOSSINFO=@LOSSINFO,");
            strSql.Append("PURCHASEPLAN=@PURCHASEPLAN,");
            strSql.Append("INVESTMENT=@INVESTMENT,");
            strSql.Append("PURCHASEDATE=@PURCHASEDATE,");
            strSql.Append("DESCRIPTION=@DESCRIPTION");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@NAME",         OleDbType.VarChar,  50),
                new OleDbParameter("@FUNDING",      OleDbType.Double),
                new OleDbParameter("@LOSSINFO",     OleDbType.VarChar, 255),
                new OleDbParameter("@PURCHASEPLAN", OleDbType.VarChar, 255),
                new OleDbParameter("@INVESTMENT",   OleDbType.Double),
                new OleDbParameter("@PURCHASEDATE", OleDbType.Date),
                new OleDbParameter("@DESCRIPTION",  OleDbType.VarChar, 255),
                new OleDbParameter("@ID",           OleDbType.Integer, 4)
            };
            parameters[0].Value = model.NAME;
            parameters[1].Value = model.FUNDING;
            parameters[2].Value = model.LOSSINFO;
            parameters[3].Value = model.PURCHASEPLAN;
            parameters[4].Value = model.INVESTMENT;
            parameters[5].Value = model.PURCHASEDATE;
            parameters[6].Value = model.DESCRIPTION;
            parameters[7].Value = model.ID;

            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ForKids.DB.Model.DEVICEBASE model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into DEVICEBASE(");
            strSql.Append("NAME,FUNDING,LOSSINFO,PURCHASEPLAN,INVESTMENT,PURCHASEDATE,DESCRIPTION)");
            strSql.Append(" values (");
            strSql.Append("@NAME,@FUNDING,@LOSSINFO,@PURCHASEPLAN,@INVESTMENT,@PURCHASEDATE,@DESCRIPTION)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@NAME",         OleDbType.VarChar,  50),
                new OleDbParameter("@FUNDING",      OleDbType.Double),
                new OleDbParameter("@LOSSINFO",     OleDbType.VarChar, 255),
                new OleDbParameter("@PURCHASEPLAN", OleDbType.VarChar, 255),
                new OleDbParameter("@INVESTMENT",   OleDbType.Double),
                new OleDbParameter("@PURCHASEDATE", OleDbType.Date),
                new OleDbParameter("@DESCRIPTION",  OleDbType.VarChar, 255)
            };
            parameters[0].Value = model.NAME;
            parameters[1].Value = model.FUNDING;
            parameters[2].Value = model.LOSSINFO;
            parameters[3].Value = model.PURCHASEPLAN;
            parameters[4].Value = model.INVESTMENT;
            parameters[5].Value = model.PURCHASEDATE;
            parameters[6].Value = model.DESCRIPTION;

            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ForKids.DB.Model.DEVICEBASE GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select ID,NAME,FUNDING,LOSSINFO,PURCHASEPLAN,INVESTMENT,PURCHASEDATE,DESCRIPTION from DEVICEBASE ");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters = {
                    new OleDbParameter("@ID", OleDbType.Integer,4)
            };
            parameters[0].Value = ID;

            ForKids.DB.Model.DEVICEBASE model=new ForKids.DB.Model.DEVICEBASE();
            DataSet ds=DbHelperOleDb.Query(strSql.ToString(),parameters);
            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]["NAME"]!=null && ds.Tables[0].Rows[0]["NAME"].ToString()!="")
                {
                    model.NAME=ds.Tables[0].Rows[0]["NAME"].ToString();
                }
                if(ds.Tables[0].Rows[0]["FUNDING"]!=null && ds.Tables[0].Rows[0]["FUNDING"].ToString()!="")
                {
                    //model.FUNDING=ds.Tables[0].Rows[0]["FUNDING"].ToString();
                }
                if(ds.Tables[0].Rows[0]["LOSSINFO"]!=null && ds.Tables[0].Rows[0]["LOSSINFO"].ToString()!="")
                {
                    model.LOSSINFO=ds.Tables[0].Rows[0]["LOSSINFO"].ToString();
                }
                if(ds.Tables[0].Rows[0]["PURCHASEPLAN"]!=null && ds.Tables[0].Rows[0]["PURCHASEPLAN"].ToString()!="")
                {
                    model.PURCHASEPLAN=ds.Tables[0].Rows[0]["PURCHASEPLAN"].ToString();
                }
                if(ds.Tables[0].Rows[0]["INVESTMENT"]!=null && ds.Tables[0].Rows[0]["INVESTMENT"].ToString()!="")
                {
                    //model.INVESTMENT=ds.Tables[0].Rows[0]["INVESTMENT"].ToString();
                }
                if(ds.Tables[0].Rows[0]["PURCHASEDATE"]!=null && ds.Tables[0].Rows[0]["PURCHASEDATE"].ToString()!="")
                {
                    model.PURCHASEDATE=DateTime.Parse(ds.Tables[0].Rows[0]["PURCHASEDATE"].ToString());
                }
                if(ds.Tables[0].Rows[0]["DESCRIPTION"]!=null && ds.Tables[0].Rows[0]["DESCRIPTION"].ToString()!="")
                {
                    model.DESCRIPTION=ds.Tables[0].Rows[0]["DESCRIPTION"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }