protected void btnGenerate_Click(object sender, EventArgs e) { DepartmentOrderDoc.DocumentTypeEntityRow docType = DatabaseUtility.GetDocumentType(loggedInUserCoId, int.Parse(ddlDepartments.SelectedValue), "Signage"); if (docType != null) { DocumentType docTypeObject = new DocumentType(); docTypeObject.CoId = loggedInUserCoId; docTypeObject.DeptId = int.Parse(ddlDepartments.SelectedValue); docTypeObject.GeneratorClass = docType.generator_class; docTypeObject.Id = docType.doc_data_type_id; docTypeObject.IncludeBlankPage = false; docTypeObject.IsLandScape = false; if (docType.Isflg_landscapeNull() == false) docTypeObject.IsLandScape = docType.flg_landscape; docTypeObject.Name = docType.doc_data_type_desc; docTypeObject.Number = 0; docTypeObject.Type = docType.field_type; foreach (GridViewRow gr in gvDocs.Rows) { CheckBox cb = (CheckBox)gr.FindControl("cbSelect"); HiddenField hfDocId = (HiddenField)gr.FindControl("hfDocId"); HiddenField hfDocName = (HiddenField)gr.FindControl("hfDocName"); if (cb.Checked) { docTypeObject.DocList.Add(int.Parse(hfDocId.Value), hfDocName.Value); } } if (docTypeObject.DocList.Count == 0) { SetErrorMessage("No document selected"); } else { List<DocumentType> docTypes = new List<DocumentType>(); docTypes.Add(docTypeObject); FolderGenerator folderGenerator = new FolderGenerator(docTypes); if (folderGenerator.Generate()) { string completePath = "~/Folders/" + folderGenerator.fileName; ClientScript.RegisterStartupScript(this.GetType(), "redirect", "window.open(\"Folders/" + folderGenerator.fileName + "\");", true); hlDoc.Visible = true; hlDoc.NavigateUrl = completePath; } else { SetErrorMessage(WebConstants.Messages.Error.DOC_NOT_GENERATED); } } } else { SetErrorMessage("Document Type not found for selected Department"); } }
private void GenerateFolder() { hlDoc.Visible = false; Image4.Visible = false; Image5.Visible = false; List<DocumentType> docTypes = new List<DocumentType>(); for (int i=0;i<rptDocTypes.Items.Count;i++) { RepeaterItem item = rptDocTypes.Items[i]; CheckBox cb = (CheckBox)item.FindControl("cbDocType"); if (cb.Checked == true) { DocumentType docType = new DocumentType(); docType.DeptOrderId = int.Parse(Request[WebConstants.Request.DEPT_ORDER_ID]); docType.Id = int.Parse(((HiddenField)item.FindControl("hfId")).Value); docType.Name = cb.Text; docType.Type = ((HiddenField)item.FindControl("hfFieldType")).Value; docType.GeneratorClass = ((HiddenField)item.FindControl("hfGeneratorClass")).Value; docType.CoId = int.Parse(((HiddenField)item.FindControl("hfCoId")).Value); docType.DeptId = int.Parse(((HiddenField)item.FindControl("hfDeptId")).Value); docType.IncludeBlankPage = cbBlankPage.Checked; HiddenField hfIsLandScape = (HiddenField)item.FindControl("hfIsLandScape"); if (hfIsLandScape.Value.Length > 0 && bool.Parse(hfIsLandScape.Value) == true) docType.IsLandScape = true; else docType.IsLandScape = false; docType.Number = null; if (docType.Type.Equals("int")) { NumericBox nb = (NumericBox)item.FindControl("nbNumOfPrints"); if (nb.Text.Length == 0) { SetErrorMessage("Number of Copies for " + docType.Name + " must be specified"); return; } else { docType.Number = int.Parse(nb.Text); } } else if (docType.Type.Equals("detail")) { DepartmentOrderDocTableAdapters.DepartmentOrderDocTableAdapter ta = new DepartmentOrderDocTableAdapters.DepartmentOrderDocTableAdapter(); IEnumerator ie = ta.GetDocsByType(loggedInUserCoId, (int)Session[WebConstants.Session.DEPT_ID], int.Parse(Request[WebConstants.Request.DEPT_ORDER_ID]), docType.Id).GetEnumerator(); bool hasData = false; while (ie.MoveNext()) { DepartmentOrderDoc.DepartmentOrderDocEntityRow dr = (DepartmentOrderDoc.DepartmentOrderDocEntityRow)ie.Current; docType.DocList.Add(dr.doc_id, dr.doc_name); hasData = true; } if (hasData == false) { SetErrorMessage("Atleast one document against document type " + docType.Name + " must be selected"); return; } } docTypes.Add(docType); } else { bool required = bool.Parse(((HiddenField)item.FindControl("hfRequired")).Value); if (required) { SetErrorMessage("Document type " + cb.Text + " must be selected"); return; } } } if (docTypes.Count == 0) { SetErrorMessage(WebConstants.Messages.Error.SELECT_ATLEAST_ONE_DOCTYPE); } else { DepartmentOrderTableAdapters.DepartmentOrderRowTableAdapter ta = new DepartmentOrderTableAdapters.DepartmentOrderRowTableAdapter(); ta.UpdateOrderDetails(null, DateTime.Parse(dtClient.Text), cbRegister.Checked, cbClosed.Checked, null, loggedInUserId, int.Parse(Request[WebConstants.Request.DEPT_ORDER_ID])); FolderGenerator folderGenerator = new FolderGenerator(docTypes); if (folderGenerator.Generate()) { string completePath = "~/Folders/" + folderGenerator.fileName; DepartmentOrderDetailTableAdapters.DepartmentOrderLogTableAdapter logTA = new DepartmentOrderDetailTableAdapters.DepartmentOrderLogTableAdapter(); logTA.Insert(int.Parse(Request[WebConstants.Request.DEPT_ORDER_ID]), loggedInUserCoId, (int)Session[WebConstants.Session.DEPT_ID], loggedInUserId, DateTime.Now, completePath, false); ClientScript.RegisterStartupScript(this.GetType(), "redirect", "window.open(\"../Folders/" + folderGenerator.fileName + "\");",true); hlDoc.Visible = true; Image4.Visible = true; Image5.Visible = true; hlDoc.NavigateUrl = completePath; } else { SetErrorMessage(WebConstants.Messages.Error.DOC_NOT_GENERATED); } } }