protected void Button1_Click(object sender, EventArgs e) { DocumentTemplateTableAdapters.DocumentItemEntityTableAdapter docItemTA = new DocumentTemplateTableAdapters.DocumentItemEntityTableAdapter(); DocumentTemplateTableAdapters.DocumentSectionDetailsTableAdapter docSectionTA = new DocumentTemplateTableAdapters.DocumentSectionDetailsTableAdapter(); byte count = 1; foreach (ListItem li in CheckBoxList1.Items) { if (li.Selected) { DocumentTemplate.DocumentSectionDetailsEntityRow secDetail = DatabaseUtility.GetSectionDetail(int.Parse(lblCoId.Text), int.Parse(lblDeptId.Text),int.Parse(lblSectionId.Text),li.Text); if(secDetail != null) { docItemTA.Insert(int.Parse(lblCoId.Text), int.Parse(lblDeptId.Text), int.Parse(lblSectionId.Text), int.Parse(lblDocId.Text), li.Text, count, secDetail.section_detail_id); } } count++; } //DatabaseUtility.GetSectionDetail( }
protected void btnTransfer_Click(object sender, EventArgs e) { if (ddlTransferDeparment.SelectedValue == ddlDepartment.SelectedValue) { SetErrorMessage("Source and Target Departments are the same"); return; } int targetCoId = int.Parse(ddlTransferCompany.SelectedValue); int targetDeptId = int.Parse(ddlTransferDeparment.SelectedValue); int sourceCoId = int.Parse(ddlCompany.SelectedValue); int sourceDeptId = int.Parse(ddlDepartment.SelectedValue); bool isInserted = false; foreach (GridViewRow gr in gvDocTypes.Rows) { CheckBox cb = (CheckBox)gr.FindControl("cbSelect"); if (cb.Checked) { int docTypeId = int.Parse(((HiddenField)gr.FindControl("hfDocTypeId")).Value); DepartmentOrderDoc.DocumentTypeEntityRow documentType = DatabaseUtility.GetDocumentType(sourceCoId, sourceDeptId, docTypeId); if (documentType != null) { DepartmentOrderDocTableAdapters.DocumentTypeTableAdapter docTypeTA = new DepartmentOrderDocTableAdapters.DocumentTypeTableAdapter(); IEnumerator ie = docTypeTA.GetDocTypeByDeptId(targetDeptId, targetCoId).GetEnumerator(); bool alreadyExists = false; while (ie.MoveNext()) { DepartmentOrderDoc.DocumentTypeEntityRow targetDocType = (DepartmentOrderDoc.DocumentTypeEntityRow)ie.Current; if (targetDocType.doc_data_type_desc == documentType.doc_data_type_desc) { SetErrorMessage(WebConstants.Messages.Error.ALREAD_EXISTS); alreadyExists = true; break; } } if (alreadyExists == false) { Nullable<bool> flgLandscape = null; if (documentType.Isflg_landscapeNull() == false) flgLandscape = documentType.flg_landscape; Nullable<int> numOfSections = null; if (documentType.Isnum_of_sectionsNull() == false) numOfSections = documentType.num_of_sections; docTypeTA.DocumentTypeInsert(documentType.doc_data_type_desc, false, targetCoId, targetDeptId, documentType.sort_order, (documentType.Isfield_typeNull()) ? null : documentType.field_type, (documentType.Isgenerator_classNull()) ? null : documentType.generator_class, documentType.required, (documentType.IsstyleNull()) ? null : documentType.style, flgLandscape, numOfSections, documentType.flg_checked, (documentType.IscategoryNull()) ? null : documentType.category); isInserted = true; if (cbTransferDocs.Checked) { DepartmentOrderDoc.DocumentTypeEntityRow targetDocType = DatabaseUtility.GetDocumentType(targetCoId, targetDeptId, documentType.doc_data_type_desc); if (targetDocType != null) { //insert templates section DocumentTemplateTableAdapters.DocumentSectionTableAdapter sectionTA = new DocumentTemplateTableAdapters.DocumentSectionTableAdapter(); IEnumerator ieSections = sectionTA.GetByDocType(sourceCoId, sourceDeptId, docTypeId).GetEnumerator(); while (ieSections.MoveNext()) { DocumentTemplate.DocumentSectionEntityRow sourceSection = (DocumentTemplate.DocumentSectionEntityRow)ieSections.Current; DocumentTemplate.DocumentSectionEntityRow targetSection = DatabaseUtility.GetSection(targetCoId, targetDeptId, sourceSection.section_desc); if (targetSection == null) { sectionTA.Insert(false, targetCoId, targetDeptId, sourceSection.section_index, sourceSection.section_desc, sourceSection.section_type, targetDocType.doc_data_type_id, sourceSection.repeat_columns); targetSection = DatabaseUtility.GetSection(targetCoId, targetDeptId, sourceSection.section_desc); } //insert section details for the sections for which it exists DocumentTemplateTableAdapters.DocumentSectionDetailsTableAdapter sectionDetailTA = new DocumentTemplateTableAdapters.DocumentSectionDetailsTableAdapter(); IEnumerator ieSectionDetails = sectionDetailTA.GetBySecId(sourceCoId, sourceDeptId, sourceSection.section_id).GetEnumerator(); while (ie.MoveNext()) { DocumentTemplate.DocumentSectionDetailsEntityRow sourceSectionDetail = (DocumentTemplate.DocumentSectionDetailsEntityRow)ieSectionDetails.Current; DocumentTemplate.DocumentSectionDetailsEntityRow targetSectionDetail = DatabaseUtility.GetSectionDetail(targetCoId, targetDeptId, targetSection.section_id, sourceSectionDetail.section_detail_desc); if (targetSectionDetail == null) { sectionDetailTA.Insert(targetSection.section_id, targetCoId, targetDeptId, sourceSectionDetail.section_detail_index, sourceSectionDetail.section_detail_desc); } } } //insert docs DepartmentOrderDocTableAdapters.DocumentTableAdapter docTA = new DepartmentOrderDocTableAdapters.DocumentTableAdapter(); IEnumerator ieDocs = docTA.GetDocsByTypeId(sourceCoId, sourceDeptId, docTypeId).GetEnumerator(); { DepartmentOrderDoc.DocumentEntityRow sourceDocument = (DepartmentOrderDoc.DocumentEntityRow)ieDocs.Current; DepartmentOrderDoc.DocumentEntityRow targetDocument = DatabaseUtility.GetDocument(targetCoId, targetDeptId, targetDocType.doc_data_type_id, sourceDocument.doc_name); if (targetDocument == null) { Categories.CategoryEntityRow targetCategory = DatabaseUtility.GetCategory(targetCoId, targetDeptId, "D", sourceDocument.category_name); if (targetCategory == null) { CategoriesTableAdapters.CategoryTableAdapter catTA = new CategoriesTableAdapters.CategoryTableAdapter(); catTA.Insert(targetCoId, targetDeptId, sourceDocument.category_name, "D"); targetCategory = DatabaseUtility.GetCategory(targetCoId, targetDeptId, "D", sourceDocument.category_name); } byte[] fileContents = null; //get fille contents if they are present DepartmentOrderDocTableAdapters.DocumentContentTableAdapter docContentTA = new DepartmentOrderDocTableAdapters.DocumentContentTableAdapter(); IEnumerator iEDocContents = docContentTA.GetDocumentContentById(sourceDocument.doc_id, sourceCoId, sourceDeptId).GetEnumerator(); if (iEDocContents.MoveNext()) { fileContents = ((DepartmentOrderDoc.DocumentContentEntityRow)iEDocContents.Current).file_contents; } docTA.Insert1(targetCoId, targetDeptId, targetDocType.doc_data_type_id, sourceDocument.doc_name, sourceDocument.doc_desc, sourceDocument.doc_code, targetCategory.category_id, sourceDocument.doc_index, fileContents,sourceDocument.flg_default); } } //insert template items } } } } } } if (isInserted) { ddlCompany.SelectedValue = ddlTransferCompany.SelectedValue; ddlDepartment.DataBind(); ddlDepartment.SelectedValue = ddlTransferDeparment.SelectedValue; gvDocTypes.DataBind(); SetInfoMessage(WebConstants.Messages.Information.RECORD_SAVED); } }
public static DocumentTemplate.DocumentSectionDetailsEntityRow GetSectionDetail(int coId, int deptId,int sectionId, string sectionDetailName) { DocumentTemplate.DocumentSectionDetailsEntityRow sectionDetail = null; DocumentTemplateTableAdapters.DocumentSectionDetailsTableAdapter sectionDetailsTA = new DocumentTemplateTableAdapters.DocumentSectionDetailsTableAdapter(); IEnumerator ie = sectionDetailsTA.GetSectionDetailByName(coId, deptId, sectionId, sectionDetailName).GetEnumerator(); if (ie.MoveNext()) { sectionDetail = (DocumentTemplate.DocumentSectionDetailsEntityRow)ie.Current; } return sectionDetail; }
protected DataTable DataSource(object sectionId) { int deptId = int.Parse(Request[WebConstants.Request.DEPT_ID]); DocumentTemplateTableAdapters.DocumentSectionDetailsTableAdapter secDetTA = new DocumentTemplateTableAdapters.DocumentSectionDetailsTableAdapter(); return secDetTA.GetBySecId(loggedInUserCoId, deptId,int.Parse(sectionId.ToString())); }
private void SetSectionData(DocumentType docType) { DocumentTemplateTableAdapters.DocumentSectionTableAdapter sectionTA = new DocumentTemplateTableAdapters.DocumentSectionTableAdapter(); DocumentTemplateTableAdapters.DocumentItemEntityTableAdapter itemTA = new DocumentTemplateTableAdapters.DocumentItemEntityTableAdapter(); DocumentTemplateTableAdapters.DocumentSectionDetailsTableAdapter secDetailTA = new DocumentTemplateTableAdapters.DocumentSectionDetailsTableAdapter(); IEnumerator ieSection = sectionTA.GetByDocType(docType.CoId, docType.DeptId, docType.Id).GetEnumerator(); while (ieSection.MoveNext()) { DocumentTemplate.DocumentSectionEntityRow sectionDataRow = (DocumentTemplate.DocumentSectionEntityRow)ieSection.Current; Section section = new Section(); section.Heading = sectionDataRow.section_desc; section.Type = sectionDataRow.section_type; section.SectionId = sectionDataRow.section_id; if (sectionDataRow.Isrepeat_columnsNull() == false) { section.RepeatColumns = sectionDataRow.repeat_columns; } DataTable dtItems = itemTA.GetBySecId(docType.CoId, docType.DeptId, docType.DocId, section.SectionId); if (section.Type == WebConstants.SectionTypes.MULTIPLE_SELECT_LIST) { IEnumerator ieSecDetail = secDetailTA.GetBySecId(docType.CoId, docType.DeptId, section.SectionId).GetEnumerator(); while (ieSecDetail.MoveNext()) { DocumentTemplate.DocumentSectionDetailsEntityRow secDetailDataRow = (DocumentTemplate.DocumentSectionDetailsEntityRow)ieSecDetail.Current; SectionDetail sectionDetail = new SectionDetail(secDetailDataRow.section_detail_id, secDetailDataRow.section_detail_desc, false); foreach (DataRow itemRow in dtItems.Rows) { if (secDetailDataRow.section_detail_id == (int)itemRow["section_detail_id"]) { sectionDetail.Selected = true; break; } } section.Details.Add(sectionDetail); } } if (section.Type == WebConstants.SectionTypes.FREE_TEXT) { foreach(DataRow itemRow in dtItems.Rows) { section.Text += (string)itemRow["item_name"] + "\n"; } } sectionList.Add(section); } }