Beispiel #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Entity.BASE_ANNEX model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into BASE_ANNEX(");
            strSql.Append("ID,SRCNAME,EXTENSION,SERVERNAME,SERVERPATH,UPTIME,STATUS,UPAUTHOR,DEPTCODE");
            strSql.Append(") values (");
            strSql.Append(":ID,:SRCNAME,:EXTENSION,:SERVERNAME,:SERVERPATH,:UPTIME,:STATUS,:UPAUTHOR,:DEPTCODE");
            strSql.Append(") ");

            OracleParameter[] parameters =
            {
                new OracleParameter(":ID",         OracleType.Number,      4),
                new OracleParameter(":SRCNAME",    OracleType.VarChar,   100),
                new OracleParameter(":EXTENSION",  OracleType.VarChar,    10),
                new OracleParameter(":SERVERNAME", OracleType.VarChar,    50),
                new OracleParameter(":SERVERPATH", OracleType.VarChar,   100),
                new OracleParameter(":UPTIME",     OracleType.DateTime),
                new OracleParameter(":STATUS",     OracleType.Number,      4),
                new OracleParameter(":UPAUTHOR",   OracleType.Number,      4),
                new OracleParameter(":DEPTCODE",   OracleType.Number, 4)
            };

            parameters[0].Value = model.ID;
            parameters[1].Value = model.SRCNAME;
            parameters[2].Value = model.EXTENSION;
            parameters[3].Value = model.SERVERNAME;
            parameters[4].Value = model.SERVERPATH;
            parameters[5].Value = model.UPTIME;
            parameters[6].Value = model.STATUS;
            parameters[7].Value = model.UPAUTHOR;
            parameters[8].Value = model.DEPTCODE;
            OracleHelper.ExecuteNonQuery(strSql.ToString(), parameters);
        }
Beispiel #2
0
        public decimal Add(Entity.BASE_ANNEX model)
        {
            dal.Add(model);

            decimal id;
            string  sqlString  = string.Format("SERVERNAME='{0}'", model.SERVERNAME);
            string  serverName = dal.GetList(sqlString).Tables[0].Rows[0]["ID"].ToString();

            id = Convert.ToDecimal(serverName);

            return(id);
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Entity.BASE_ANNEX GetEntity(decimal ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID, SRCNAME, EXTENSION, SERVERNAME, SERVERPATH, UPTIME, STATUS, UPAUTHOR, DEPTCODE  ");
            strSql.Append("  from BASE_ANNEX ");
            strSql.Append(" where ID=:ID ");
            OracleParameter[] parameters =
            {
                new OracleParameter(":ID", OracleType.Number, 4)
            };
            parameters[0].Value = ID;


            Entity.BASE_ANNEX entity = new Entity.BASE_ANNEX();
            DataTable         dt     = OracleHelper.Query(CommandType.Text, strSql.ToString(), parameters);

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["ID"].ToString() != "")
                {
                    entity.ID = decimal.Parse(dt.Rows[0]["ID"].ToString());
                }
                entity.SRCNAME    = dt.Rows[0]["SRCNAME"].ToString();
                entity.EXTENSION  = dt.Rows[0]["EXTENSION"].ToString();
                entity.SERVERNAME = dt.Rows[0]["SERVERNAME"].ToString();
                entity.SERVERPATH = dt.Rows[0]["SERVERPATH"].ToString();
                if (dt.Rows[0]["UPTIME"].ToString() != "")
                {
                    entity.UPTIME = DateTime.Parse(dt.Rows[0]["UPTIME"].ToString());
                }
                if (dt.Rows[0]["STATUS"].ToString() != "")
                {
                    entity.STATUS = decimal.Parse(dt.Rows[0]["STATUS"].ToString());
                }
                if (dt.Rows[0]["UPAUTHOR"].ToString() != "")
                {
                    entity.UPAUTHOR = decimal.Parse(dt.Rows[0]["UPAUTHOR"].ToString());
                }
                if (dt.Rows[0]["DEPTCODE"].ToString() != "")
                {
                    entity.DEPTCODE = decimal.Parse(dt.Rows[0]["DEPTCODE"].ToString());
                }

                return(entity);
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Entity.BASE_ANNEX model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BASE_ANNEX set ");

            strSql.Append(" ID = :ID , ");
            strSql.Append(" SRCNAME = :SRCNAME , ");
            strSql.Append(" EXTENSION = :EXTENSION , ");
            strSql.Append(" SERVERNAME = :SERVERNAME , ");
            strSql.Append(" SERVERPATH = :SERVERPATH , ");
            strSql.Append(" UPTIME = :UPTIME , ");
            strSql.Append(" STATUS = :STATUS , ");
            strSql.Append(" UPAUTHOR = :UPAUTHOR , ");
            strSql.Append(" DEPTCODE = :DEPTCODE  ");
            strSql.Append(" where ID=:ID  ");

            OracleParameter[] parameters =
            {
                new OracleParameter(":ID",         OracleType.Number,      4),
                new OracleParameter(":SRCNAME",    OracleType.VarChar,   100),
                new OracleParameter(":EXTENSION",  OracleType.VarChar,    10),
                new OracleParameter(":SERVERNAME", OracleType.VarChar,    50),
                new OracleParameter(":SERVERPATH", OracleType.VarChar,   100),
                new OracleParameter(":UPTIME",     OracleType.DateTime),
                new OracleParameter(":STATUS",     OracleType.Number,      4),
                new OracleParameter(":UPAUTHOR",   OracleType.Number,      4),
                new OracleParameter(":DEPTCODE",   OracleType.Number, 4)
            };

            parameters[9].Value  = model.ID;
            parameters[10].Value = model.SRCNAME;
            parameters[11].Value = model.EXTENSION;
            parameters[12].Value = model.SERVERNAME;
            parameters[13].Value = model.SERVERPATH;
            parameters[14].Value = model.UPTIME;
            parameters[15].Value = model.STATUS;
            parameters[16].Value = model.UPAUTHOR;
            parameters[17].Value = model.DEPTCODE;
            int rows = OracleHelper.ExecuteNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #5
0
        private string UploadAnnex()
        {
            string resultAnnex = "";

            BLL.BASE_ANNEX bllAnnex = new BLL.BASE_ANNEX();
            for (int index = 0; index < Request.Files.Count; index++)
            {
                if (!string.IsNullOrEmpty(Request.Files[index].FileName))
                {
                    Entity.BASE_ANNEX annex = new Entity.BASE_ANNEX();
                    annex.SERVERNAME = Guid.NewGuid().ToString();                        //服务器存储文件名
                    annex.SRCNAME    = Path.GetFileName(Request.Files[index].FileName);  //原文件名称
                    annex.EXTENSION  = Path.GetExtension(Request.Files[index].FileName); //文件扩展名
                    annex.STATUS     = 0;                                                //存储状态:0正常
                    annex.UPAUTHOR   = userSession.USERID;                               //上传者用户ID
                    annex.DEPTCODE   = userSession.DEPTID;                               //部门编号
                    annex.UPTIME     = DateTime.Now;                                     //文件上传时间
                    annex.SERVERPATH = string.Format("Document/{0}/", DateTime.Now.ToString("yyyyMMdd"));

                    //判断服务器存储目录路径是否存在
                    if (!Directory.Exists(Server.MapPath("~/") + annex.SERVERPATH))
                    {
                        Directory.CreateDirectory(Server.MapPath("~/") + annex.SERVERPATH);
                    }

                    //保存附件(服务器存储路径)
                    Request.Files[index].SaveAs(Server.MapPath("~/") + annex.SERVERPATH + annex.SERVERNAME + annex.EXTENSION);

                    //加入数据库
                    decimal id = bllAnnex.Add(annex);

                    //公文附件示例:12,56,87,96,56
                    resultAnnex += id.ToString() + ",";
                }
            }

            return(resultAnnex);
        }
Beispiel #6
0
 public void Update(Entity.BASE_ANNEX model)
 {
 }