private void btnDelete_Click(object sender, EventArgs e) { int DepId = Conversions.ToInteger(dgvEmployees.CurrentRow.Cells[9].Value); int IdUser = My.MyProject.Forms.FrmLoginWindow._userID; if (DocumentsStoredUserDepartmentService.VerifySecurityDepartmentUser(DepId, IdUser) == false) { My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("Viewing a document restricted to the department." + Constants.vbCrLf + "If you need access, contact the IT department.!", "Restricted access", this); return; } int DocId = Conversions.ToInteger(dgvEmployees.CurrentRow.Cells[0].Value); string FileOrigin = dgvEmployees.CurrentRow.Cells[6].Value.ToString(); var result = My.MyProject.Forms.MessageBoxCeresYesNo.ShowDialog("Delete this document ?", "Are you sure you want to delete this document ID #" + DocId.ToString(), My.Resources.Resources.caution, this); if (result == DialogResult.Yes) { if (ftpser.DeleteSFTPFile(FileOrigin)) { if (DocumentsStoredService.Delete(DocId)) { My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("Document deleted successfully!", "Message", this); SearchDocs(); } else { My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("Check if you are using WTC VPN or if your computer is connected to the WTC Network." + Constants.vbCrLf + "If this error persists, contact the IT Department!", "Error Message", this); } } else { My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("Check if you are using WTC VPN or if your computer is connected to the WTC Network." + Constants.vbCrLf + "If this error persists, contact the IT Department!", "Error Message", this); } } }
public string ReturnFileName() { int Id = Conversions.ToInteger(dgvEmployees.CurrentRow.Cells[0].Value); string a = ""; var Docs = DocumentsStoredService.GetById(Id); foreach (var item in Docs) { a = item.FileName; } return(a); }
private void OpneFile() { int Id = Conversions.ToInteger(dgvEmployees.CurrentRow.Cells[0].Value); var a = default(string); var Docs = DocumentsStoredService.GetById(Id); foreach (var item in Docs) { a = item.ServerPath; } Process.Start(a); }
/* TODO ERROR: Skipped EndRegionDirectiveTrivia */ /* TODO ERROR: Skipped RegionDirectiveTrivia */ public void LoadForm() { EmployeeNameBindingSource.DataSource = EmployeeService.GetFirstNameLastNameForDropBox(); ddlEmployee.SelectedValue = 0; DocumentsStoredDepartmentBindingSource.DataSource = DocumentsStoredDepartmentService.GetAllForDropBox(); ddlArea.SelectedValue = 0; DocumentsStoredTypeBindingSource.DataSource = DocumentsStoredTypeService.GetByDeparmentIdForDropBox(Conversions.ToInteger(ddlArea.SelectedValue), false); DocumentsStoredBindingSource.DataSource = DocumentsStoredService.GetByFilters(txtFileType.Text, txtDecription.Text, "", "", 0, "", "", true); txtStartDate.CustomFormat = " "; txtEndDate.CustomFormat = " "; ConfigLayoutForUserPerfil(); }
public bool VerifyDepartmentUser() { bool isDepOK = false; int DocId = Conversions.ToInteger(dgvEmployees.CurrentRow.Cells[0].Value); // Department code: // HR - 17 // SAFETY_AND_RISK - 18 // Verifica se usuario pode excluir documentos do departamento. int IdUser = My.MyProject.Forms.FrmLoginWindow._userID; switch (IdUser) { // 54 - JORDAN // 63 - LYNDON // 70 - MAY // 124 - Vania // 135 - Roger // 163 - Emilio case 135: { if (DocumentsStoredService.VerifiDocByDepartment(DocId, 18)) { isDepOK = true; } break; } case 70: { if (DocumentsStoredService.VerifiDocByDepartment(DocId, 17)) { isDepOK = true; } break; } } return(isDepOK); }
public void SearchDocs() { waitForm.Show(this); string StartDate = ""; string EndDate = ""; string Department = ddlArea.Text; string DocType = ddlType.Text; if (ckbDate.Checked) { StartDate = txtStartDate.Value.ToShortDateString(); EndDate = txtEndDate.Value.ToShortDateString(); } if (string.IsNullOrEmpty(Department) | Department == "ALL") { Department = ""; } if (string.IsNullOrEmpty(DocType) | DocType == "ALL") { DocType = ""; } if (rbIssueDate.Checked) { DocumentsStoredBindingSource.DataSource = DocumentsStoredService.GetByFilters(txtFileType.Text, txtDecription.Text, Department, DocType, Conversions.ToInteger(ddlEmployee.SelectedValue), StartDate, EndDate, true); // DocumentsStoredBindingSource.DataSource = DocumentsStoredService.GetByTypeDocEmployeeIssueExpire(txtFileType.Text, txtDecription.Text, ddlArea.SelectedValue, ddlType.SelectedValue, ddlEmployee.SelectedValue, StartDate, EndDate, True) dgvEmployees.Refresh(); } else { DocumentsStoredBindingSource.DataSource = DocumentsStoredService.GetByFilters(txtFileType.Text, txtDecription.Text, Department, DocType, Conversions.ToInteger(ddlEmployee.SelectedValue), StartDate, EndDate, false); // DocumentsStoredBindingSource.DataSource = DocumentsStoredService.GetByTypeDocEmployeeIssueExpire(txtFileType.Text, txtDecription.Text, ddlArea.SelectedValue, ddlType.SelectedValue, ddlEmployee.SelectedValue, StartDate, EndDate, False) dgvEmployees.Refresh(); } ConfigLayoutForUserPerfil(); waitForm.Close(); }
/* TODO ERROR: Skipped EndRegionDirectiveTrivia */ /* TODO ERROR: Skipped RegionDirectiveTrivia */ private void UploadFile() { // Verify max if (txtFileTitle.TextLength > 50) { My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("The maximum characters for the File Title field is 50.", "File Title", this); return; } if (txtDescription.TextLength > 250) { My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("The maximum characters for the description field is 250..", "File Title", this); return; } // 0 - Handles possible errors if (string.IsNullOrEmpty(ddlArea.Text)) { My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("Choose a department.", "Department", this); return; } if (string.IsNullOrEmpty(ddlType.Text)) { My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("Choose a Document Type.", "Document Type", this); return; } if (string.IsNullOrEmpty(txtFile.Text)) { My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("Invalid file", "Enter the name and path of the destination file", this); return; } // 1 - Check Form Date Format if (txtIssueDate.CustomFormat == "MMM dd, yyyy") { IssueDate = Conversions.ToString(txtIssueDate.Value); } if (txtExpireDate.CustomFormat == "MMM dd, yyyy") { ExpireDate = Conversions.ToString(txtExpireDate.Value); } // 2 - Name the file DateDoc = DateTime.Now.ToString("dd/MMM/yyyy") + "_" + DateTime.Now.ToString("HH") + "h_" + DateTime.Now.ToString("mm") + "m"; if (string.IsNullOrEmpty(ddlEmployee.Text)) { filename = ddlType.Text.Trim().Replace(" ", "_") + "_" + DateDoc.Replace("/", "_") + ".PDF"; } else { filename = ddlType.Text.Trim() + "_" + ddlEmployee.Text.Trim().Replace("(", "").Replace(")", "_").Replace(" ", "").Replace(",", "_") + "_" + DateDoc.Replace("/", "_") + ".PDF"; } // 3 - Select the file for a specific directory fileOrigin = txtFile.Text; // 4 - file destiny fileDestiny = "documentstorage/" + ddlArea.Text + "/" + ddlType.Text + "/"; waitForm.Show(); // 4.1 - Insert file on server and save to database if (ftpser.uploadSFTPFile(fileOrigin, fileDestiny, filename)) { if (DocumentsStoredService.Insert(txtFileTitle.Text, txtDescription.Text, fileDestiny + filename, IssueDate, ExpireDate, filename, Conversions.ToInteger(ddlEmployee.SelectedValue), Conversions.ToInteger(ddlType.SelectedValue), Conversions.ToInteger(ddlArea.SelectedValue))) { waitForm.Close(); My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("File copied successfully.", "Success", this); DocumentsStoredTypeBindingSource.DataSource = DocumentsStoredTypeService.GetByDeparmentId(Conversions.ToInteger(ddlArea.SelectedValue)); Close(); My.MyProject.Forms.frmStoreFiles.SearchDocs(); } else { My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("If the Error persists contact the IT department. Error Code# DB120", "Error sending file", this); ftpser.DeleteSFTPFile(fileDestiny + filename); } } else { My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("If the Error persists contact the IT department. Error Code #FTB120", "Error sending file", this); } waitForm.Close(); }