private void rpt_BGroup() { try { if (cmbSearch.Text == "") { MessageBox.Show("Please Fill in the Field!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { string X = cmbSearch.Text; SqlConnection conn = new SqlConnection(Community.DBLayer.con_String); conn.Open(); SqlCommand cmd = new SqlCommand("Select *,tblFamily.Sign,tblFamily.Nukh,tblFamily.City,tblFamily.Area,tblFamily.Country from tblFamilyMember INNER JOIN tblFamily ON tblFamilyMember.FCardNo = tblFamily.FCardNo WHERE tblFamilyMember.BloodGroup = '" + X + "' Order By tblFamily.FCardNo asc", conn); DataTable dt = new DataTable(); cmd.CommandType = CommandType.Text; //SqlParameter paraID = cmd.Parameters.Add("@FCardNo",SqlDbType.VarChar , 50); //paraID.Value = X; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; da.Fill(dt); Reports.Members.frmViewer frm = new frmViewer(); Reports.Members.rptType_Members rpt = new rptType_Members(); frm.crystalReportViewer1.ReportSource = rpt; rpt.SetDataSource(dt); rpt.SetParameterValue("Filter", cmbSearch.Text + " Blood Group Members"); frm.Show(); conn.Close(); } } catch (Exception ex) { MessageBox.Show("AN unknown error occured \n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void rpt_Card() { string Query = ""; try { if (cmbSearch.Text == "") { MessageBox.Show("Please Fill in the Field!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { string X = cmbSearch.Text; SqlConnection conn = new SqlConnection(Community.DBLayer.con_String); conn.Open(); //SqlCommand cmd = new SqlCommand("Select *,tblFamily.Sign,tblFamily.Nukh,tblFamily.City,tblFamily.Area,tblFamily.Country from tblFamilyMember INNER JOIN tblFamily ON tblFamilyMember.FCardNo = tblFamily.FCardNo WHERE tblFamilyMember.FCardNo = '" + X + "' Order By tblFamily.FCardNo asc", conn); //SqlCommand cmd = new SqlCommand("Select * from tblFamilyMember INNER JOIN tblFamily ON tblFamilyMember.FCardNo = tblFamily.FCardNo WHERE tblFamilyMember.FCardNo = '" + X + "' Order By tblFamily.FCardNo asc", conn); Query += "Select case when tblfamilymember.Gender='Male' then MemberName+' '+FatherName "; Query += "when tblfamilymember.gender='Female' then "; Query += "Case When tblfamilymember.Active=1 and (MaritalStatus='Married' or MaritalStatus='Widow') "; Query += " then MemberName+' '+HusbandName else MemberName+' '+FatherName end "; Query += "else "; Query += " Case when MaritalStatus='Married' then MemberName+' '+HusbandName when MaritalStatus='Single' then MemberName+' '+FatherName end "; Query += "end "; Query += "MemberName,CNIC,NIC,tblfamilyMember.Gender,AgeGroup,LeaderRelation,TempDOB as DOB,AcademicEducation,MaritalStatus,tblfamilymember.Reason,tblfamilymember.Active, "; Query += "tblfamily.FamilyName,tblfamily.FamilyLeader,tblfamily.Nukh,tblfamily.Sign,tblfamily.Mobile,tblfamily.ResidentAddress,tblfamily.FCardNo,OutOf "; Query += "from tblFamilyMember "; Query += "INNER JOIN tblFamily ON tblFamilyMember.FCardNo = tblFamily.FCardNo "; Query += "WHERE tblFamilyMember.FCardNo ='" + X + "' Order By tblFamily.FCardNo asc "; SqlCommand cmd = new SqlCommand(Query, conn); DataTable dt = new DataTable(); cmd.CommandType = CommandType.Text; //SqlParameter paraID = cmd.Parameters.Add("@FCardNo",SqlDbType.VarChar , 50); //paraID.Value = X; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; da.Fill(dt); Reports.Members.frmViewer frm = new frmViewer(); Reports.Members.rptMembers_Card rpt = new rptMembers_Card(); frm.crystalReportViewer1.ReportSource = rpt; rpt.SetDataSource(dt); frm.Show(); conn.Close(); } } catch (Exception ex) { MessageBox.Show("AN unknown error occured \n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }