private void btnSearch_Click(object sender, EventArgs e) { bool status = true; if (txtDocumentName.Text == String.Empty || txtDocumentName.Text == "Document Name") { pnlError.Visible = true; pnlError.Location = new Point((this.Width - pnlError.ClientSize.Width) / 2, 12); pnlError.BackColor = System.Drawing.ColorTranslator.FromHtml("#f5b7b7"); lblErrorMsg.Text = "Document Name is required"; lblErrorMsg.Location = new Point((pnlError.Width - lblErrorMsg.ClientSize.Width) / 2, (pnlError.Height - lblErrorMsg.ClientSize.Height) / 2); status = false; txtDocumentName.Focus(); return; } if (!status) { MessageBox.Show("Please Enter required data"); } else { ShowDocumentsManager objShowDocumentsManager = new ShowDocumentsManager(); NandanaResult dsgetScannedDocumentResultsdetails = objShowDocumentsManager.ShowScannedDocuments(); DataTable dtFinalResult = new DataTable(); if (dsgetScannedDocumentResultsdetails.resultDS != null && dsgetScannedDocumentResultsdetails.resultDS.Tables[0].Rows.Count > 0) { if (txtDocumentName.Text != "") { DataRow[] drResult = dsgetScannedDocumentResultsdetails.resultDS.Tables[0].Select("File_Name like '%" + txtDocumentName.Text.Trim() + "%'"); if (drResult.Count() != 0) { dtFinalResult = drResult.CopyToDataTable(); } } else { dtFinalResult = dsgetScannedDocumentResultsdetails.resultDS.Tables[0]; } if (dtFinalResult.Rows.Count > 0) { foreach (DataRow dr in dtFinalResult.Rows) { if (dr["Date"].ToString() != "") { dr["Date"] = DateTime.Parse(dr["Date"].ToString(), System.Globalization.CultureInfo.InvariantCulture).ToString(); } } dgvDocuments.DataSource = dtFinalResult; } else { pnlError.Visible = true; pnlError.Location = new Point((this.Width - pnlError.ClientSize.Width) / 2, 12); pnlError.BackColor = System.Drawing.ColorTranslator.FromHtml("#f5b7b7"); lblErrorMsg.Text = "No results found, try a new search."; lblErrorMsg.Location = new Point((pnlError.Width - lblErrorMsg.ClientSize.Width) / 2, (pnlError.Height - lblErrorMsg.ClientSize.Height) / 2); dgvDocuments.DataSource = null; } } else { pnlError.Visible = true; pnlError.Location = new Point((this.Width - pnlError.ClientSize.Width) / 2, 12); pnlError.BackColor = System.Drawing.ColorTranslator.FromHtml("#f5b7b7"); lblErrorMsg.Text = "No results found, try a new search."; lblErrorMsg.Location = new Point((pnlError.Width - lblErrorMsg.ClientSize.Width) / 2, (pnlError.Height - lblErrorMsg.ClientSize.Height) / 2); dgvDocuments.DataSource = null; } } }
//public void BindCategories() //{ // try // { // CategoryManager objCategoryManager = new CategoryManager(); // NandanaResult dsCategorydetails = objCategoryManager.GetCategoryDetails(); // if (dsCategorydetails.resultDS != null && dsCategorydetails.resultDS.Tables[0].Rows.Count > 0) // { // // cmbCategoryName.Items.Clear(); // cmbCategoryName.DisplayMember = "Category_Name"; // cmbCategoryName.ValueMember = "Category_ID"; // cmbCategoryName.DataSource = GetComboBoxedDataTable(dsCategorydetails.resultDS.Tables[0], "Category_ID", "Category_Name", "0", "-Select Category-"); // } // } // catch (Exception ex) // { // MessageBox.Show(ex.Message, "Error While retriving data from Category table"); // } //} public void GetDocumentDetails() { dgvDocuments.Columns.Clear(); dgvDocuments.AutoGenerateColumns = false; dgvDocuments.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dgvDocuments.ColumnHeadersDefaultCellStyle.ForeColor = System.Drawing.ColorTranslator.FromHtml("#444444"); this.dgvDocuments.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("Segoe UI", 11.00F); DataGridViewColumn clnDocumentID = new DataGridViewTextBoxColumn(); clnDocumentID.DataPropertyName = "Document_ID"; clnDocumentID.Name = "Document_ID"; dgvDocuments.Columns.Add(clnDocumentID); clnDocumentID.Visible = false; DataGridViewLinkColumn clnDocumentName = new DataGridViewLinkColumn(); clnDocumentName.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline; clnDocumentName.LinkColor = Color.Blue; clnDocumentName.DataPropertyName = "File_Name"; clnDocumentName.Name = "Document Name"; dgvDocuments.Columns.Add(clnDocumentName); dgvDocuments.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable; //dgvDocuments.Columns[2].DefaultCellStyle.WrapMode = DataGridViewTriState.True; DataGridViewColumn clnDocumentPath = new DataGridViewTextBoxColumn(); clnDocumentPath.DataPropertyName = "File_Path"; clnDocumentPath.Name = "Document Path"; dgvDocuments.Columns.Add(clnDocumentPath); clnDocumentPath.Visible = false; DataGridViewColumn clnKeywordID = new DataGridViewTextBoxColumn(); clnKeywordID.DataPropertyName = "Keyword_ID"; clnKeywordID.Name = "Keyword_ID"; dgvDocuments.Columns.Add(clnKeywordID); clnKeywordID.Visible = false; DataGridViewColumn clnKeyword = new DataGridViewTextBoxColumn(); clnKeyword.DataPropertyName = "Keyword"; clnKeyword.Name = "Folder"; dgvDocuments.Columns.Add(clnKeyword); dgvDocuments.Columns[4].HeaderCell.SortGlyphDirection = SortOrder.None; //dgvDocuments.Columns[2].DefaultCellStyle.WrapMode = DataGridViewTriState.True; DataGridViewColumn clnProcesstype = new DataGridViewTextBoxColumn(); clnProcesstype.DataPropertyName = "ProcessType"; clnProcesstype.Name = "Import By"; dgvDocuments.Columns.Add(clnProcesstype); DataGridViewColumn clnDate = new DataGridViewTextBoxColumn(); clnDate.DataPropertyName = "Date"; clnDate.Name = "Date"; dgvDocuments.Columns.Add(clnDate); dgvDocuments.Columns[5].HeaderCell.SortGlyphDirection = SortOrder.None; try { ShowDocumentsManager objShowDocumentsManager = new ShowDocumentsManager(); NandanaResult dsgetScannedDocumentResultsdetails = objShowDocumentsManager.ShowScannedDocuments(); if (dsgetScannedDocumentResultsdetails.resultDS != null && dsgetScannedDocumentResultsdetails.resultDS.Tables[0].Rows.Count > 0) { foreach (DataRow dr in dsgetScannedDocumentResultsdetails.resultDS.Tables[0].Rows) { if (dr["Date"].ToString() != "") { dr["Date"] = DateTime.Parse(dr["Date"].ToString(), System.Globalization.CultureInfo.InvariantCulture).ToString(); } } dgvDocuments.DataSource = dsgetScannedDocumentResultsdetails.resultDS.Tables[0]; } else { //pnlError.Visible = true; //pnlError.Location = new Point((this.Width - pnlError.ClientSize.Width) / 2, 12); //pnlError.BackColor = System.Drawing.ColorTranslator.FromHtml("#f5b7b7"); //lblErrorMsg.Text = "No records to display"; //lblErrorMsg.Location = new Point((pnlError.Width - lblErrorMsg.ClientSize.Width) / 2, (pnlError.Height - lblErrorMsg.ClientSize.Height) / 2); dgvDocuments.DataSource = null; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error While retriving data from ScannedDocumentresuls table"); } }