//Deleting from UserAndDocumentTable

        public void deleteFromUserAndDocumentTable(string userId, string docId)
        {
            //LinqToSqlDataContext context = new LinqToSqlDataContext();
            udtemp = context2.UserAndDocumentTables.FirstOrDefault(x => x.user_id == userId && x.doc_id == docId);
            context2.UserAndDocumentTables.DeleteOnSubmit(udtemp);
            context2.SubmitChanges();
        }
        public string deleteFromUserAndDocumentTableByDocId(string docId)
        {
            udtemp = context2.UserAndDocumentTables.First(x => x.doc_id == docId);
            string userId = udtemp.user_id;

            context2.UserAndDocumentTables.DeleteOnSubmit(udtemp);
            context2.SubmitChanges();
            return(userId);
        }
 public string userAndDocumentTableSelectByListBoxIndex(string tempuser, int index)
 {
     for (int i = 0; i <= index; i++)
     {
         udtemp = context2.UserAndDocumentTables.FirstOrDefault(x => x.user_id == tempuser && x.user_doc_id > userdocidforsharelist);
         userdocidforsharelist = udtemp.user_doc_id;
         dtemp = context.DocumentTables.SingleOrDefault(x => x.doc_id == udtemp.doc_id);
     }
     return(dtemp.doc_id);
 }
        //Insert into UserAndDocumentTable

        public void userAndDocumentTableInsert(string userId, string docId, string docRight)
        {
            UserAndDocumentTable ob = new UserAndDocumentTable();

            ob.doc_id    = docId;
            ob.user_id   = userId;
            ob.doc_right = docRight;
            //LinqToSqlDataContext context = new LinqToSqlDataContext();
            context2.UserAndDocumentTables.InsertOnSubmit(ob);
            context2.SubmitChanges();
        }
        //Enter into userAndDocumentTable

        public string userAndDocumentTableSelect(string tempuser)
        {
            try
            {
                //LinqToSqlDataContext context = new LinqToSqlDataContext();
                udtemp    = context2.UserAndDocumentTables.FirstOrDefault(x => x.user_id == tempuser && x.user_doc_id > userdocid);
                userdocid = udtemp.user_doc_id;
                return(udtemp.doc_id);
            }
            catch (Exception)
            {
                string message = "Not Found";
                return(message);
            }
        }
        public string userAndDocumentTableSelectAndReturnDocName(string tempuser)
        {
            try
            {
                udtemp = context2.UserAndDocumentTables.FirstOrDefault(x => x.user_id == tempuser && x.user_doc_id > userdocidforsharelist);
                userdocidforsharelist = udtemp.user_doc_id;
                dtemp = context.DocumentTables.SingleOrDefault(x => x.doc_id == udtemp.doc_id);
                return(dtemp.doc_name);
            }

            catch (Exception)
            {
                string message = "Not Found";
                return(message);
            }
        }
        public string documentTableSelectByDocName(string docName, string user)
        {
            utemp = context.UserTables.SingleOrDefault(x => x.user_id == user);
            int noofdoc = utemp.no_of_document;

            userdocid = 0;
            for (int i = 0; i < noofdoc; i++)
            {
                udtemp    = context2.UserAndDocumentTables.First(x => x.user_id == user && x.user_doc_id > userdocid);
                userdocid = udtemp.user_doc_id;
                string docId = udtemp.doc_id;
                dtemp = context.DocumentTables.SingleOrDefault(x => x.doc_id == docId);
                string name = dtemp.doc_name;
                if (name.Equals(docName))
                {
                    break;
                }
                else
                {
                    continue;
                }
            }
            return(dtemp.doc_id);
        }
 partial void DeleteUserAndDocumentTable(UserAndDocumentTable instance);
 partial void UpdateUserAndDocumentTable(UserAndDocumentTable instance);
 partial void InsertUserAndDocumentTable(UserAndDocumentTable instance);
 public int LastRowUserAndDocumentTable()
 {
     udtemp = context2.UserAndDocumentTables.AsEnumerable().Last();
     return(udtemp.user_doc_id);
 }
 public int firstRowUserAndDocumentTable()
 {
     udtemp = context2.UserAndDocumentTables.First();
     return(udtemp.user_doc_id);
 }
 public string docRight(string userId, string docId)
 {
     //LinqToSqlDataContext context = new LinqToSqlDataContext();
     udtemp = context2.UserAndDocumentTables.SingleOrDefault(x => x.user_id == userId && x.doc_id == docId);
     return(udtemp.doc_right);
 }