Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool checkvalidate = validation();

            if (checkvalidate == false && chkNonPerformSvc.Checked == false)
            {
                return;
            }
            var       dtType       = cmbDateType.SelectedItem as DateType;
            DataTable dt           = new DataTable();
            var       ServiceName  = cmbServiceName.SelectedItem as ServiceName;
            var       ServiceTypes = cmbServiceType.SelectedItem as ServiceTypes;

            if (rdbServiceWseDonors.Checked && dtType.Id > 2 && ServiceTypes.Id == 2)
            {
                MessageBox.Show("Kindly pick English day or Telugu thidhi for Monthly Annadanam...");
                return;
            }
            // performDate = string.Format(performDate, "yyyy-mm-dd");
            string filterstring = string.Empty;

            if (rdbServiceWseDonors.Checked)
            {
                filterstring = GetFilterstring();
            }
            else
            {
                if (dtType.Id == 3)
                {
                    filterstring = GetFilterstring();
                }
                else
                {
                    filterstring = GetFilterstring() + " OR (" + GetFilterForMonthlyAnnadanam() + ")";
                }
            }
            var DonorList = oDonorRepository.GetAllasDataTable().Select(filterstring);

            if (DonorList.Count() != 0)
            {
                //string performDate = DonorList[0]["PerformDate"].ToString();
                DataView view = new DataView(DonorList.CopyToDataTable());
                dt = view.ToTable(false, "Id", "NameOn", "Gothram", "MR_No");
                DonorReportDataSet drs = new DonorReportDataSet();
                drs.Tables.Add(dt);
                DataTable DonorVals = new DataTable();
                DonorVals.Columns.Add("ServiceType");
                DonorVals.Columns.Add("ServiceName");
                DonorVals.Columns.Add("PerformDate");
                DataRow dr = DonorVals.NewRow();
                if (rdbAlldonors.Checked)
                {
                    dr["ServiceType"] = "All Donors";
                    dr["ServiceName"] = "All Donors";
                }
                else
                {
                    dr["ServiceType"] = ServiceTypes.Name;
                    dr["ServiceName"] = (ServiceName == null) ? "" : ServiceName.Name;
                }
                if (!chkNonPerformSvc.Checked)
                {
                    dr["PerformDate"] = performDate;
                }
                else
                {
                    dr["ServiceType"] = "";
                    dr["ServiceName"] = "";
                }
                DonorVals.Rows.Add(dr);
                DonorReportForm donorreportForm = new DonorReportForm(dt, DonorVals);
                donorreportForm.Show();
            }
            else
            {
                MessageBox.Show("Donors were not found for the selected filters");
            }
            //report
            //   }
        }