예제 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Dianda.Model.Document_File GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,FolderID,FileName,FileType,Icon,Sizeof,FilePath,IsShare,DELFLAG,DATETIME,UserID,ShareID from Document_File ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            Dianda.Model.Document_File model = new Dianda.Model.Document_File();
            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]["FolderID"].ToString() != "")
                {
                    model.FolderID = int.Parse(ds.Tables[0].Rows[0]["FolderID"].ToString());
                }
                model.FileName = ds.Tables[0].Rows[0]["FileName"].ToString();
                model.FileType = ds.Tables[0].Rows[0]["FileType"].ToString();
                model.Icon     = ds.Tables[0].Rows[0]["Icon"].ToString();
                if (ds.Tables[0].Rows[0]["Sizeof"].ToString() != "")
                {
                    model.Sizeof = decimal.Parse(ds.Tables[0].Rows[0]["Sizeof"].ToString());
                }
                model.FilePath = ds.Tables[0].Rows[0]["FilePath"].ToString();
                if (ds.Tables[0].Rows[0]["IsShare"].ToString() != "")
                {
                    model.IsShare = int.Parse(ds.Tables[0].Rows[0]["IsShare"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DELFLAG"].ToString() != "")
                {
                    model.DELFLAG = int.Parse(ds.Tables[0].Rows[0]["DELFLAG"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DATETIME"].ToString() != "")
                {
                    model.DATETIME = DateTime.Parse(ds.Tables[0].Rows[0]["DATETIME"].ToString());
                }
                model.UserID = ds.Tables[0].Rows[0]["UserID"].ToString();
                if (ds.Tables[0].Rows[0]["ShareID"].ToString() != "")
                {
                    model.ShareID = int.Parse(ds.Tables[0].Rows[0]["ShareID"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Dianda.Model.Document_File model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Document_File set ");
            strSql.Append("FolderID=@FolderID,");
            strSql.Append("FileName=@FileName,");
            strSql.Append("FileType=@FileType,");
            strSql.Append("Icon=@Icon,");
            strSql.Append("Sizeof=@Sizeof,");
            strSql.Append("FilePath=@FilePath,");
            strSql.Append("IsShare=@IsShare,");
            strSql.Append("DELFLAG=@DELFLAG,");
            strSql.Append("DATETIME=@DATETIME,");
            strSql.Append("UserID=@UserID,");
            strSql.Append("ShareID=@ShareID");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",       SqlDbType.Int,         4),
                new SqlParameter("@FolderID", SqlDbType.Int,         4),
                new SqlParameter("@FileName", SqlDbType.VarChar,   100),
                new SqlParameter("@FileType", SqlDbType.VarChar,    50),
                new SqlParameter("@Icon",     SqlDbType.VarChar,   100),
                new SqlParameter("@Sizeof",   SqlDbType.Float,       8),
                new SqlParameter("@FilePath", SqlDbType.VarChar,   500),
                new SqlParameter("@IsShare",  SqlDbType.Int,         4),
                new SqlParameter("@DELFLAG",  SqlDbType.Int,         4),
                new SqlParameter("@DATETIME", SqlDbType.DateTime),
                new SqlParameter("@UserID",   SqlDbType.VarChar,    50),
                new SqlParameter("@ShareID",  SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.ID;
            parameters[1].Value  = model.FolderID;
            parameters[2].Value  = model.FileName;
            parameters[3].Value  = model.FileType;
            parameters[4].Value  = model.Icon;
            parameters[5].Value  = model.Sizeof;
            parameters[6].Value  = model.FilePath;
            parameters[7].Value  = model.IsShare;
            parameters[8].Value  = model.DELFLAG;
            parameters[9].Value  = model.DATETIME;
            parameters[10].Value = model.UserID;
            parameters[11].Value = model.ShareID;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Dianda.Model.Document_File model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Document_File(");
            strSql.Append("FolderID,FileName,FileType,Icon,Sizeof,FilePath,IsShare,DELFLAG,DATETIME,UserID,ShareID)");
            strSql.Append(" values (");
            strSql.Append("@FolderID,@FileName,@FileType,@Icon,@Sizeof,@FilePath,@IsShare,@DELFLAG,@DATETIME,@UserID,@ShareID)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FolderID", SqlDbType.Int,         4),
                new SqlParameter("@FileName", SqlDbType.VarChar,   100),
                new SqlParameter("@FileType", SqlDbType.VarChar,    50),
                new SqlParameter("@Icon",     SqlDbType.VarChar,   100),
                new SqlParameter("@Sizeof",   SqlDbType.Float,       8),
                new SqlParameter("@FilePath", SqlDbType.VarChar,   500),
                new SqlParameter("@IsShare",  SqlDbType.Int,         4),
                new SqlParameter("@DELFLAG",  SqlDbType.Int,         4),
                new SqlParameter("@DATETIME", SqlDbType.DateTime),
                new SqlParameter("@UserID",   SqlDbType.VarChar,    50),
                new SqlParameter("@ShareID",  SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.FolderID;
            parameters[1].Value  = model.FileName;
            parameters[2].Value  = model.FileType;
            parameters[3].Value  = model.Icon;
            parameters[4].Value  = model.Sizeof;
            parameters[5].Value  = model.FilePath;
            parameters[6].Value  = model.IsShare;
            parameters[7].Value  = model.DELFLAG;
            parameters[8].Value  = model.DATETIME;
            parameters[9].Value  = model.UserID;
            parameters[10].Value = model.ShareID;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #4
0
        /// <summary>
        /// 将立项申请时的上传附件保存到项目的目录中
        /// </summary>
        /// <param name="folderid"></param>
        /// <param name="filepath"></param>
        private void setAttachmentsToDocument(string userid, string folderid, string filepath)
        {
            try
            {
                if (filepath.Contains('.'))
                {
                    //
                    try
                    {
                        System.IO.FileInfo f = new FileInfo(this.Page.Server.MapPath(filepath));
                        long filesize        = f.Length;
                        if (filesize > 0)
                        {
                            filesize             = filesize / 1024;
                            mDocumentfile.Sizeof = filesize;
                        }
                    }
                    catch
                    {
                    }
                    //先要检查该项目有没有上传过文件,如果上传过,则只做替换
                    List <Model.Document_File> filelist = bDocumentfile.GetModelList("DELFLAG=0 and FolderID=" + folderid + " and filename like '项目预算表单%'");
                    if (filelist.Count > 0)
                    {
                        string[] filearray = filepath.Split('/');
                        string   types     = filearray[filearray.Length - 1].Split('.')[1];
                        mDocumentfile          = filelist[0];
                        mDocumentfile.DATETIME = DateTime.Now;
                        mDocumentfile.DELFLAG  = 0;
                        mDocumentfile.FileName = "项目预算表单." + types;
                        mDocumentfile.FilePath = filepath;
                        mDocumentfile.FileType = types;
                        mDocumentfile.FolderID = int.Parse(folderid);
                        mDocumentfile.Icon     = types;
                        mDocumentfile.IsShare  = 0;
                        mDocumentfile.UserID   = userid;

                        bDocumentfile.Update(mDocumentfile);
                    }
                    else
                    {
                        //先要检查该项目有没有上传过文件,如果上传过,则只做替换
                        string[] filearray = filepath.Split('/');
                        string   types     = filearray[filearray.Length - 1].Split('.')[1];
                        mDocumentfile.DATETIME = DateTime.Now;
                        mDocumentfile.DELFLAG  = 0;
                        mDocumentfile.FileName = "项目预算表单." + types;
                        mDocumentfile.FilePath = filepath;
                        mDocumentfile.FileType = types;
                        mDocumentfile.FolderID = int.Parse(folderid);
                        mDocumentfile.Icon     = types;
                        mDocumentfile.IsShare  = 0;
                        mDocumentfile.UserID   = userid;

                        bDocumentfile.Add(mDocumentfile);
                    }
                }
            }
            catch
            {
            }
        }