示例#1
0
        private void btnPreview_Click(object sender, EventArgs e)
        {
            try
            {
                string vWhere   = string.Empty;
                string criteria = string.Empty;

                Reports.RptReportViewer vForm = new Reports.RptReportViewer();
                DataTable dt = new DataTable();
                if (!chkReturn.Checked)
                {
                    if (!string.IsNullOrEmpty(this.txtVendorID.Text))
                    {
                        vWhere = " AND Purchase.VendorID=" + this.txtVendorID.Text;
                    }

                    //if (!string.IsNullOrEmpty(this.txt_ProductID.Text))
                    //{
                    //    vWhere += " AND PurchaseBody.ProductID=" + this.txt_ProductID.Text;
                    //}

                    if (optRange.Checked == true)
                    {
                        vWhere  += " AND convert(datetime,Convert(varchar,Purchase.EntryDate,1)) Between Convert(Datetime,(convert(varchar,convert(Datetime,'" + this.dt_From.Text + " 00:00:00',102),1))) AND Convert(Datetime,(convert(varchar,convert(Datetime,'" + this.dt_ToDate.Text + " 00:00:00',102),1)))";
                        criteria = "From: " + dt_From.Value.ToString("dd-MMM-yyyy") + " To: " + dt_ToDate.Value.ToString("dd-MMM-yyyy");
                    }
                    else
                    {
                        criteria = " Till Date: " + dt_ToDate.Value.ToString("dd-MMM-yyyy");
                    }


                    dt = objDAL.getPrtyWisePur(vWhere);
                    if (dt.Rows.Count == 0)
                    {
                        MessageBox.Show("No Data To Display", "No Data");
                        return;
                    }
                    vForm.PartyWisePurchase(criteria, dt);
                    vForm.ShowDialog();
                }
                else
                {
                    if (!string.IsNullOrEmpty(this.txtVendorID.Text))
                    {
                        vWhere = " AND PurReturn.VendorID=" + this.txtVendorID.Text;
                    }

                    //if (!string.IsNullOrEmpty(this.txt_ProductID.Text))
                    //{
                    //    vWhere += " AND PurReturnBody.ProductID=" + this.txt_ProductID.Text;
                    //}

                    if (optRange.Checked == true)
                    {
                        vWhere  += " AND convert(datetime,Convert(varchar,PurReturn.EntryDate,1)) Between Convert(Datetime,(convert(varchar,convert(Datetime,'" + this.dt_From.Text + " 00:00:00',102),1))) AND Convert(Datetime,(convert(varchar,convert(Datetime,'" + this.dt_ToDate.Text + " 00:00:00',102),1)))";
                        criteria = "From: " + dt_From.Value.ToString("dd-MMM-yyyy") + " To: " + dt_ToDate.Value.ToString("dd-MMM-yyyy");
                    }
                    else
                    {
                        criteria = " Till Date: " + dt_ToDate.Value.ToString("dd-MMM-yyyy");
                    }

                    dt = objDAL.getPrtyWisePurRet(vWhere);
                    if (dt.Rows.Count == 0)
                    {
                        MessageBox.Show("No Data To Display", "No Data");
                        return;
                    }
                    vForm.PartyWisePurRet(criteria, dt);
                    vForm.ShowDialog();
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Error");
            }
        }