public string documentTableSelectByDocNameForGroupDoc(string docName, string gId)
        {
            gtemp = context.GroupTables.SingleOrDefault(x => x.group_id == gId);
            int noofdoc = gtemp.total_document;

            docgroupid = 0;

            for (int i = 0; i < noofdoc; i++)
            {
                dgtemp     = context2.DocumentAndGroupTables.First(x => x.group_id == gId && x.doc_group_id > docgroupid);
                docgroupid = dgtemp.doc_group_id;
                string docId = dgtemp.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);
        }
        public string documentAndGroupTableSelectAndReturnDocName(string gId)
        {
            dgtemp     = context2.DocumentAndGroupTables.First(x => x.group_id == gId && x.doc_group_id > docgroupid);
            docgroupid = dgtemp.doc_group_id;
            string docId = dgtemp.doc_id;

            dtemp = context.DocumentTables.SingleOrDefault(x => x.doc_id == docId);
            return(dtemp.doc_name);
        }
        //Deleting from DocumentAndGroupTable

        public void deleteFromDocumentAndGroupTableAndNoOfDocDecreaseInGroupTable(string docId, string gId)
        {
            dgtemp = context2.DocumentAndGroupTables.SingleOrDefault(x => x.doc_id == docId && x.group_id == gId);
            context2.DocumentAndGroupTables.DeleteOnSubmit(dgtemp);
            context2.SubmitChanges();
            gtemp = context.GroupTables.Single(x => x.group_id == gId);
            gtemp.total_document--;
            context.SubmitChanges();
        }
        public void documentAndGroupTableInsert(string dId, string gId, string docRight)
        {
            DocumentAndGroupTable ob = new DocumentAndGroupTable();

            ob.group_id  = gId;
            ob.doc_id    = dId;
            ob.doc_right = docRight;
            //LinqToSqlDataContext context = new LinqToSqlDataContext();
            context2.DocumentAndGroupTables.InsertOnSubmit(ob);
            context2.SubmitChanges();
        }
        public void deleteFromDocumentAndGroupTableByDocId(string docId)
        {
            dgtemp = context2.DocumentAndGroupTables.First(x => x.doc_id == docId);
            string gId = dgtemp.group_id;

            context2.DocumentAndGroupTables.DeleteOnSubmit(dgtemp);
            context2.SubmitChanges();
            gtemp = context.GroupTables.Single(x => x.group_id == gId);
            gtemp.total_document = gtemp.total_document - 1;
            context.SubmitChanges();
        }
 public string documentAndGroupTableSelect(string gId)
 {
     try
     {
         // LinqToSqlDataContext context = new LinqToSqlDataContext();
         dgtemp     = context2.DocumentAndGroupTables.First(x => x.group_id == gId && x.doc_group_id > docgroupid);
         docgroupid = dgtemp.doc_group_id;
         return(dgtemp.doc_id);
     }
     catch (Exception)
     { return("You Are Not Connected To Any Group"); }
 }
 partial void DeleteDocumentAndGroupTable(DocumentAndGroupTable instance);
 partial void UpdateDocumentAndGroupTable(DocumentAndGroupTable instance);
 partial void InsertDocumentAndGroupTable(DocumentAndGroupTable instance);
 public int LastRowDocumentAndGroupTable()
 {
     dgtemp = context2.DocumentAndGroupTables.AsEnumerable().Last();
     return(dgtemp.doc_group_id);
 }
 public int firstRowDocumentAndGroupTable()
 {
     dgtemp = context2.DocumentAndGroupTables.First();
     return(dgtemp.doc_group_id);
 }
 public void deleteFromdocumentAndGroupTable(string groupId)
 {
     dgtemp = context2.DocumentAndGroupTables.FirstOrDefault(x => x.group_id == groupId);
     context2.DocumentAndGroupTables.DeleteOnSubmit(dgtemp);
     context2.SubmitChanges();
 }