예제 #1
0
    public void Insert(WorkerAttachmentInfo info)
    {
        //db.Open();
        info.CreateDate = DateTime.Now;

        string query = "INSERT INTO [dbo].[WorkerAttachment] ( [WorkerID] "
                       + ",[RowNo] "
                       + ",[AttachmentType] "
                       + ",[MIME] "
                       + ",[Path] "
                       + ",[FileName] "
                       + ",[Ext] "
                       + ",[CreateUser] "
                       + ",[CreateDate] "
                       + ",[LastModifyUser] "
                       + ",[LastModifyDate] "
                       + ") "
                       + "VALUES ( @WorkerID "
                       + ",@RowNo "
                       + ",@AttachmentType "
                       + ",@MIME "
                       + ",@Path "
                       + ",@FileName "
                       + ",@Ext "
                       + ",@CreateUser "
                       + ",@CreateDate "
                       + ",@LastModifyUser "
                       + ",@LastModifyDate "
                       + ") ";


        db.Execute(query, info, this.transaction);
        //db.Close();
    }
예제 #2
0
    public bool IsExisted(WorkerAttachmentInfo info)
    {
        //db.Open();
        String query = "select count(*)  from WorkerAttachment "
                       + " where WorkerID = @WorkerID and RowNo=@RowNo ";
        var obj = (List <int>)db.Query <int>(query, info, this.transaction);

        //db.Close();
        return(obj[0] > 0);
    }
예제 #3
0
    public void Save(WorkerAttachmentInfo info)
    {
        if (this.IsExisted(info))
        {
            this.Update(info);
        }
        else
        {
            this.Insert(info);
        }

        if (!string.IsNullOrEmpty(info.Content))
        {
            GlobalSetting.SaveFile(string.Format("{0}_{1}", info.WorkerID, info.RowNo), info.Content);
        }
    }
예제 #4
0
    public void Update(WorkerAttachmentInfo info)
    {
        //db.Open();

        info.CreateDate = DateTime.Now;

        string query = " UPDATE [dbo].[WorkerAttachment] SET  "
                       + "  [MIME] = @MIME "
                       + ", [AttachmentType] = @AttachmentType "
                       + ", [Path] = @Path "
                       + ", [FileName] = @FileName "
                       + ", [Ext] = @Ext "
                       + ", [CreateUser] = @CreateUser "
                       + ", [CreateDate] = @CreateDate "
                       + ", [LastModifyUser] = @LastModifyUser "
                       + ", [LastModifyDate] = @LastModifyDate "
                       + " where WorkerID = @WorkerID and RowNo = @RowNo ";


        db.Execute(query, info, this.transaction);
        //db.Close();
    }