private void Chk_Selected_CheckedChanged(object sender, EventArgs e)
 {
     try
     {
         if (Chk_Selected.Checked)
         {
             DataSet ds = ProjectFunctions.GetDataSet("Select AccCode,AccName from ActMst ");
             if (ds.Tables[0].Rows.Count > 0)
             {
                 HelpGridCtrl.DataSource = ds.Tables[0];
                 HelpGrid.BestFitColumns();
                 HelpGridCtrl.Show();
                 HelpGridCtrl.Focus();
                 HelpGridCtrl.BringToFront();
             }
         }
         else
         {
             HelpGridCtrl.Visible = false;
         }
     }
     catch (Exception ex)
     {
         ProjectFunctions.SpeakError(ex.Message);
     }
 }
 private void ShowHelpWindow(string Query)
 {
     try
     {
         HelpGridCtrl.DataSource = null;
         HelpGrid.Columns.Clear();
         HelpGridCtrl.RefreshDataSource();
         HelpGridCtrl.Visible = true;
         HelpGridCtrl.Focus();
         HelpGridCtrl.DataSource = ProjectFunctions.GetDataSet(Query).Tables[0];
         HelpGrid.Columns[0].BestFit();
         HelpGrid.Columns[1].BestFit();
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show("Unable to fetch Data please Contact IT Department.\n" + ex.Message, "!Error");
     }
 }
        private void BtnLoad_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                StartDate      = _RangeSelector.DtFrom.DateTime.Date;
                EndDate        = _RangeSelector.DtEnd.DateTime.Date;
                DataRow Currentrow = HelpGrid.GetDataRow(HelpGrid.FocusedRowHandle);


                switch (GlobalVariables.ProgCode)
                {
                case "PROG143":
                    DataSet      Ds      = ProjectFunctions.GetDataSet(string.Format("Exec [Sp_CashBookRpt] '{0:yyyy-MM-dd}', '{1:yyyy-MM-dd}'", StartDate.Date, EndDate.Date));
                    rpt_CashBook RptDoc1 = new rpt_CashBook();
                    (RptDoc1.ReportDefinition.ReportObjects["txtCompanyName"] as TextObject).Text = GlobalVariables.CompanyName;
                    (RptDoc1.ReportDefinition.ReportObjects["txtReportHead"] as TextObject).Text  = "CASH BOOK";
                    (RptDoc1.ReportDefinition.ReportObjects["txtDateRange"] as TextObject).Text   = string.Format("From ({0} to {1}) ", StartDate.Date.ToString("dd-MM-yyyy"), EndDate.Date.ToString("dd-MM-yyyy"));
                    RptDoc1.SetDataSource(Ds.Tables[0]);
                    lbl.Text = string.Format(Title + " ({0} to {1}) ", StartDate.Date.ToString("dd-MM-yyyy"), EndDate.Date.ToString("dd-MM-yyyy"));
                    crystalReportViewer1.ReportSource = RptDoc1;
                    _RangeSelector.Hide();
                    break;

                case "PROG144":
                    HelpGrid.CloseEditor();
                    HelpGrid.UpdateCurrentRow();
                    DataSet      DsRecoBank = ProjectFunctions.GetDataSet(string.Format("Exec [SP_RecoBank] '{0:yyyy-MM-dd}', '253'", EndDate.Date));
                    rpt_BankReco RptDoc2    = new rpt_BankReco();
                    (RptDoc2.ReportDefinition.ReportObjects["txtCompanyName"] as TextObject).Text = GlobalVariables.CompanyName;
                    (RptDoc2.ReportDefinition.ReportObjects["txtReportName"] as TextObject).Text  = "Bank Reco";
                    (RptDoc2.ReportDefinition.ReportObjects["txtDateRange"] as TextObject).Text   = string.Format("From ({0} to {1}) ", StartDate.Date.ToString("dd-MM-yyyy"), EndDate.Date.ToString("dd-MM-yyyy"));
                    RptDoc2.SetDataSource(DsRecoBank.Tables[0]);
                    lbl.Text = string.Format(Title + " ({0} to {1}) ", StartDate.Date.ToString("dd-MM-yyyy"), EndDate.Date.ToString("dd-MM-yyyy"));
                    crystalReportViewer1.ReportSource = RptDoc2;
                    crystalReportViewer1.Show();
                    crystalReportViewer1.BringToFront();
                    _RangeSelector.Hide();
                    HelpGridCtrl.Hide();
                    break;

                case "PROG145":
                    DataSet     dsDayBook = ProjectFunctions.GetDataSet(string.Format("[Sp_PrepareDayBook] '{0:yyyy-MM-dd}', '{1:yyyy-MM-dd}'", StartDate.Date, EndDate.Date));
                    rpt_DayBook RptDoc3   = new rpt_DayBook();
                    (RptDoc3.ReportDefinition.ReportObjects["txtCompanyName"] as TextObject).Text = GlobalVariables.CompanyName;
                    (RptDoc3.ReportDefinition.ReportObjects["txtReportHead"] as TextObject).Text  = "Day Book";
                    (RptDoc3.ReportDefinition.ReportObjects["txtDateRange"] as TextObject).Text   = string.Format("From ({0} to {1}) ", StartDate.Date.ToString("dd-MM-yyyy"), EndDate.Date.ToString("dd-MM-yyyy"));
                    RptDoc3.SetDataSource(dsDayBook.Tables[0]);
                    lbl.Text = string.Format(Title + " ({0} to {1}) ", StartDate.Date.ToString("dd-MM-yyyy"), EndDate.Date.ToString("dd-MM-yyyy"));
                    crystalReportViewer1.ReportSource = RptDoc3;
                    crystalReportViewer1.Show();
                    crystalReportViewer1.BringToFront();
                    _RangeSelector.Hide();
                    break;

                case "PROG147":
                    DataSet      ds     = ProjectFunctions.GetDataSet(string.Format("[Sp_PrepareBankBook] '{0:yyyy-MM-dd}', '{1:yyyy-MM-dd}'", StartDate.Date, EndDate.Date));
                    Rpt_BankBook RptDoc = new Rpt_BankBook();
                    (RptDoc.Section2.ReportObjects["txtCompanyName"] as TextObject).Text = GlobalVariables.CompanyName;
                    (RptDoc.Section2.ReportObjects["txtReportName"] as TextObject).Text  = "Bank Book";
                    (RptDoc.Section2.ReportObjects["txtDateRange"] as TextObject).Text   = string.Format("From ({0} to {1}) ", StartDate.Date.ToString("dd-MM-yyyy"), EndDate.Date.ToString("dd-MM-yyyy"));
                    lbl.Text = string.Format(Title + " ({0} to {1})", StartDate.Date.ToString("dd-MM-yyyy"), EndDate.Date.ToString("dd-MM-yyyy"));
                    RptDoc.SetDataSource(ds.Tables[0]);
                    crystalReportViewer1.ReportSource = RptDoc;
                    crystalReportViewer1.Show();
                    crystalReportViewer1.BringToFront();
                    _RangeSelector.Hide();
                    break;

                case "PROG165":
                    if (Currentrow != null)
                    {
                        DataSet     dsLedger  = ProjectFunctions.GetDataSet(string.Format("[sp_ZoomPartyAct] '{0:yyyy-MM-dd}', '{1:yyyy-MM-dd}','{2}'", StartDate.Date, EndDate.Date, Currentrow["AccCode"].ToString()));
                        PartyLedger RptLedger = new PartyLedger();
                        (RptLedger.Section2.ReportObjects["txtCompanyName"] as TextObject).Text = GlobalVariables.CompanyName;
                        (RptLedger.Section2.ReportObjects["txtReportName"] as TextObject).Text  = "Party Ledger";
                        (RptLedger.Section2.ReportObjects["txtDateRange"] as TextObject).Text   = string.Format("From ({0} to {1}) ", StartDate.Date.ToString("dd-MM-yyyy"), EndDate.Date.ToString("dd-MM-yyyy"));
                        lbl.Text = string.Format(Title + " ({0} to {1})", StartDate.Date.ToString("dd-MM-yyyy"), EndDate.Date.ToString("dd-MM-yyyy"));
                        RptLedger.SetDataSource(dsLedger.Tables[0]);
                        crystalReportViewer1.ReportSource = RptLedger;
                        crystalReportViewer1.Show();
                        crystalReportViewer1.BringToFront();
                        _RangeSelector.Hide();
                    }
                    else
                    {
                        ProjectFunctions.SpeakError("Plz Select Party First");
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
        }