public ICertificateListView CreateCertificateList(IList <ICertificationModel> certificationModel, int UserId, string processingMessage, string certificateName, int certificateId) { var filter = certificationModel.Where(m => m.CertificationName.Contains(string.IsNullOrEmpty(certificateName) ? m.CertificationName : certificateName)).ToList(); var ViewModel = new CertificateListView { certificateModel = filter, UserId = UserId, CertificationId = certificateId, ProcessingMessage = processingMessage }; return(ViewModel); }
private void SearchCertificates() { string criteria; int certificateID = 0; string[] data; DateTime?startDate = null, endDate = null; if (!string.IsNullOrEmpty(dpStart.Value)) { startDate = DateTime.Parse(dpStart.Value); } if (!string.IsNullOrEmpty(dpEnd.Value)) { endDate = DateTime.Parse(dpEnd.Value); } if (txtSearchCertificate.Text.Length > 0) { data = txtSearchCertificate.Text.Split('|'); if (data[1] != null) { certificateID = int.Parse(data[1]); } } criteria = "Client"; SqlConnection sqlConnection1 = new SqlConnection(CertificateDataSource.ConnectionString); SqlDataAdapter da = new SqlDataAdapter(); SqlCommand cmd = new SqlCommand(); DataTable dt = new DataTable(); try { cmd.CommandText = "[transport].[sp_search_certificates]"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = sqlConnection1; cmd.Parameters.AddWithValue("@certificateID", certificateID); cmd.Parameters.AddWithValue("@criteria", criteria); cmd.Parameters.Add("@startDate", SqlDbType.DateTime).Value = startDate; cmd.Parameters.Add("@endDate", SqlDbType.DateTime).Value = endDate; da.SelectCommand = cmd; da.Fill(dt); CertificateListView.DataSourceID = string.Empty; CertificateListView.DataSource = dt; CertificateListView.DataBind(); } catch (Exception exp) { ErrorLabel.Text = "Error a ejecutar busqueda.. : " + exp.Message; ErrorLabel.Visible = true; } }