Beispiel #1
0
		public  void  DbUpdate()
		{
			UserIdentity user = UserIdentity.Current;

			Validate();
			System.Data.OleDb.OleDbConnection con = Db.Connection;
		
			OleDbTransaction trans = con.BeginTransaction();			
			OleDbCommand cmd = con.CreateCommand();
			cmd.Transaction = trans;
			try
			{
				CmdParams cp = new CmdParams(cmd, false);
				m_CreationTime = DateTime.Now;
				cmd.CommandText =   @"
				update documents
				set	FileType = " + cp.Add(m_FileTypeId) + 
					", [FileName] = " + cp.Add(m_FileName) +
					", DateReceived = " + cp.Add(m_DateReceived) +
					", DocumentDate = " + cp.Add(m_DocumentDate) +
					", IncomingNumber = " +cp.Add(m_IncomingNumber) +
					", OutgoingNumber = " +cp.Add(m_OutgoingNumber) +
					", Subject = " +cp.Add(m_Subject) + 
					", Header = " + cp.Add(m_Header) + 
					", ArchiveFileNames = " + cp.Add(m_ArchiveFileNames) + 
					", DocTypeId = " + cp.Add(m_DocTypeId) + 
					", DocSourceId = " + cp.Add(m_DocSourceId) + 
					", DocCategoryId = " + cp.Add(m_DocCategoryId) + 
					", ParentId = " + cp.Add(m_ParentId) +
					", PreviousVersionId = " + cp.Add(m_PreviousVersionId) + 
					", IsPublic = " + cp.Add(m_IsPublic) +
					", StorageFileName = '" + StorageFileName + "' " + 
					" where id = " + m_Id.ToString();
				cmd.ExecuteNonQuery();

				StoreDocRefs(trans, "DocGroups", "GroupId", Groups);
				StoreDocRefs(trans, "DocRefRelated", "RelatedDocId", RefDocuments);

				cmd.Parameters.Clear();
				cmd.CommandText = "delete from UserReadDocs where DocId=" + m_Id.ToString() + " and UserId=" + user.UserId.ToString();
				cmd.ExecuteNonQuery();
				cmd.CommandText = "delete from UserFavoriteDocs where DocId=" + m_Id.ToString() + " and UserId=" + user.UserId.ToString();
				cmd.ExecuteNonQuery();
				if(IsRead)
				{
					cmd.CommandText = "insert into UserReadDocs (DocId, UserId) values (" + m_Id.ToString() + ", " + user.UserId.ToString() + " ) ";
					cmd.ExecuteNonQuery();
				}

				if(IsFavorite)
				{
					cmd.CommandText = "insert into UserFavoriteDocs (DocId, UserId) values (" + m_Id.ToString() + ", " + user.UserId.ToString() +" ) ";
					cmd.ExecuteNonQuery();
				}

				trans.Commit();
			}
			catch(Exception ex)
			{
				trans.Rollback();
				throw ex;
			}
		}
        public void  DbUpdate()
        {
            UserIdentity user = UserIdentity.Current;

            Validate();
            System.Data.OleDb.OleDbConnection con = Db.Connection;

            OleDbTransaction trans = con.BeginTransaction();
            OleDbCommand     cmd   = con.CreateCommand();

            cmd.Transaction = trans;
            try
            {
                CmdParams cp = new CmdParams(cmd, false);
                m_CreationTime  = DateTime.Now;
                cmd.CommandText = @"
				update documents
				set	FileType = "                     + cp.Add(m_FileTypeId) +
                                  ", [FileName] = " + cp.Add(m_FileName) +
                                  ", DateReceived = " + cp.Add(m_DateReceived) +
                                  ", DocumentDate = " + cp.Add(m_DocumentDate) +
                                  ", IncomingNumber = " + cp.Add(m_IncomingNumber) +
                                  ", OutgoingNumber = " + cp.Add(m_OutgoingNumber) +
                                  ", Subject = " + cp.Add(m_Subject) +
                                  ", Header = " + cp.Add(m_Header) +
                                  ", ArchiveFileNames = " + cp.Add(m_ArchiveFileNames) +
                                  ", DocTypeId = " + cp.Add(m_DocTypeId) +
                                  ", DocSourceId = " + cp.Add(m_DocSourceId) +
                                  ", DocCategoryId = " + cp.Add(m_DocCategoryId) +
                                  ", ParentId = " + cp.Add(m_ParentId) +
                                  ", PreviousVersionId = " + cp.Add(m_PreviousVersionId) +
                                  ", IsPublic = " + cp.Add(m_IsPublic) +
                                  ", StorageFileName = '" + StorageFileName + "' " +
                                  " where id = " + m_Id.ToString();
                cmd.ExecuteNonQuery();

                StoreDocRefs(trans, "DocGroups", "GroupId", Groups);
                StoreDocRefs(trans, "DocRefRelated", "RelatedDocId", RefDocuments);

                cmd.Parameters.Clear();
                cmd.CommandText = "delete from UserReadDocs where DocId=" + m_Id.ToString() + " and UserId=" + user.UserId.ToString();
                cmd.ExecuteNonQuery();
                cmd.CommandText = "delete from UserFavoriteDocs where DocId=" + m_Id.ToString() + " and UserId=" + user.UserId.ToString();
                cmd.ExecuteNonQuery();
                if (IsRead)
                {
                    cmd.CommandText = "insert into UserReadDocs (DocId, UserId) values (" + m_Id.ToString() + ", " + user.UserId.ToString() + " ) ";
                    cmd.ExecuteNonQuery();
                }

                if (IsFavorite)
                {
                    cmd.CommandText = "insert into UserFavoriteDocs (DocId, UserId) values (" + m_Id.ToString() + ", " + user.UserId.ToString() + " ) ";
                    cmd.ExecuteNonQuery();
                }

                trans.Commit();
            }
            catch (Exception ex)
            {
                trans.Rollback();
                throw ex;
            }
        }
Beispiel #3
0
		public  int  DbCreate(out OleDbTransaction trans)
		{
			Validate();
			System.Data.OleDb.OleDbConnection con = Db.Connection;
		
			trans = con.BeginTransaction();			
			OleDbCommand cmd = con.CreateCommand();
			cmd.Transaction = trans;
			try
			{
				CmdParams cp = new CmdParams(cmd);
				m_CreationTime = DateTime.Now;
				cmd.CommandText =   @"
				insert into documents
				(
					CreationTime,
					FileType, 
					[FileName],
					DateReceived, 
					DocumentDate, 
					IncomingNumber, 
					OutgoingNumber,
					Subject, 
					Header, 
					ArchiveFileNames, 
					DocTypeId, 
					DocSourceId, 
					DocCategoryId, 
					ParentId, 
					PreviousVersionId, 
					OwnerUserId, 
					IsPublic
				)values ( "	+ 
					cp.Add(m_CreationTime) + 
					cp.Add(m_FileTypeId) + 
					cp.Add(m_FileName) +
					cp.Add(m_DateReceived) +
					cp.Add(m_DocumentDate) +
					cp.Add(m_IncomingNumber) +
					cp.Add(m_OutgoingNumber) +
					cp.Add(m_Subject) + 
					cp.Add(m_Header) + 
					cp.Add(m_ArchiveFileNames) + 
					cp.Add(m_DocTypeId) + 
					cp.Add(m_DocSourceId) + 
					cp.Add(m_DocCategoryId) + 
					cp.Add(m_ParentId) +
					cp.Add(m_PreviousVersionId) + 
					cp.Add(m_OwnerUserId) +
					cp.Add(m_IsPublic) + " ) ";


				cmd.ExecuteNonQuery();
				cmd.CommandText="select @@identity";
				Decimal oid =  (Decimal) cmd.ExecuteScalar();
				m_Id = Convert.ToInt32(oid);

				StoreDocRefs(trans, "DocGroups", "GroupId", Groups);
				StoreDocRefs(trans, "DocRefRelated", "RelatedDocId", RefDocuments);
				cmd.Parameters.Clear();
				cmd.CommandText = "update Documents set StorageFileName = '" + StorageFileName + "' where Id = " + m_Id.ToString();
				cmd.ExecuteNonQuery();
				//trans.Commit();

				//.DEV. isRead
			}
			catch(Exception ex)
			{
				trans.Rollback();
				trans = null;
				throw ex;
			}
			
			MarkAsRead();
			
			return m_Id;
		}
        public int  DbCreate(out OleDbTransaction trans)
        {
            Validate();
            System.Data.OleDb.OleDbConnection con = Db.Connection;

            trans = con.BeginTransaction();
            OleDbCommand cmd = con.CreateCommand();

            cmd.Transaction = trans;
            try
            {
                CmdParams cp = new CmdParams(cmd);
                m_CreationTime  = DateTime.Now;
                cmd.CommandText = @"
				insert into documents
				(
					CreationTime,
					FileType, 
					[FileName],
					DateReceived, 
					DocumentDate, 
					IncomingNumber, 
					OutgoingNumber,
					Subject, 
					Header, 
					ArchiveFileNames, 
					DocTypeId, 
					DocSourceId, 
					DocCategoryId, 
					ParentId, 
					PreviousVersionId, 
					OwnerUserId, 
					IsPublic
				)values ( "                 +
                                  cp.Add(m_CreationTime) +
                                  cp.Add(m_FileTypeId) +
                                  cp.Add(m_FileName) +
                                  cp.Add(m_DateReceived) +
                                  cp.Add(m_DocumentDate) +
                                  cp.Add(m_IncomingNumber) +
                                  cp.Add(m_OutgoingNumber) +
                                  cp.Add(m_Subject) +
                                  cp.Add(m_Header) +
                                  cp.Add(m_ArchiveFileNames) +
                                  cp.Add(m_DocTypeId) +
                                  cp.Add(m_DocSourceId) +
                                  cp.Add(m_DocCategoryId) +
                                  cp.Add(m_ParentId) +
                                  cp.Add(m_PreviousVersionId) +
                                  cp.Add(m_OwnerUserId) +
                                  cp.Add(m_IsPublic) + " ) ";


                cmd.ExecuteNonQuery();
                cmd.CommandText = "select @@identity";
                Decimal oid = (Decimal)cmd.ExecuteScalar();
                m_Id = Convert.ToInt32(oid);

                StoreDocRefs(trans, "DocGroups", "GroupId", Groups);
                StoreDocRefs(trans, "DocRefRelated", "RelatedDocId", RefDocuments);
                cmd.Parameters.Clear();
                cmd.CommandText = "update Documents set StorageFileName = '" + StorageFileName + "' where Id = " + m_Id.ToString();
                cmd.ExecuteNonQuery();
                //trans.Commit();

                //.DEV. isRead
            }
            catch (Exception ex)
            {
                trans.Rollback();
                trans = null;
                throw ex;
            }

            MarkAsRead();

            return(m_Id);
        }