Tuesday, February 10, 2009

Crystal Reports with Selection formula

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WEIGHBRIDGE1
{
public partial class MonthReport : Form
{
SqlConnection scn = new SqlConnection("Data Source=.;Initial Catalog=Weighingbridge;Integrated Security=True");
public MonthReport()
{
InitializeComponent();
}
private static string mth;
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.Text == "January")
{
mth = "January";
}
if (comboBox1.Text == "February")
{
mth = "February";
}
if (comboBox1.Text == "March")
{
mth = "March";
}
if (comboBox1.Text == "April")
{
mth = "April";
}
if (comboBox1.Text == "May")
{
mth = "May";
}
if (comboBox1.Text == "June")
{
mth = "June";
}
if (comboBox1.Text == "July")
{
mth = "July";
}
if (comboBox1.Text == "August")
{
mth = "August";
}
if (comboBox1.Text == "September")
{
mth = "September";
}
if (comboBox1.Text == "October")
{
mth = "October";
}
if (comboBox1.Text == "November")
{
mth = "November";
}
if (comboBox1.Text == "December")
{
mth = "December";
}
//-------------------------------------------------------------------------------------------- if (mth == "January")
{
Class1.month = "{Transaction.Dateoftransaction} in '1/1/2007' to ' 1/31/2007' ";
}
if (mth == "February")
{
Class1.month = "{Transaction.Dateoftransaction} in ' 1/2/2007' to ' 28/2/2007' ";
}
if (mth == "March")
{
Class1.month = "{Transaction.Dateoftransaction} in ' 1/3/2007' to '31/3/2007' ";
}
if (mth == "April")
{
Class1.month = "{Transaction.Dateoftransaction} in ' 1/4/2007' to '30/4/2007' ";

}
if (mth == "May")
{
Class1.month = "{Transaction.Dateoftransaction} in ' 1/5/2007' to ' 31/5/2007' ";
}
if (mth == "June")
{
Class1.month = "{Transaction.Dateoftransaction} in ' 1/6/2007' to ' 30/6/2007' ";
}
if (mth == "July")
{
Class1.month = "{Transaction.Dateoftransaction} in ' 1/7/2007' to ' 31/7/2007' ";
}
if (mth == "August")
{
Class1.month = "{Transaction.Dateoftransaction} in '1/8/2007' to '31/8/2007' ";
}
if (mth == "September")
{
Class1.month = "{Transaction.Dateoftransaction} in '1/9/2007' to '30/9/2007' ";
}
if (mth == "October")
{
Class1.month = "{Transaction.Dateoftransaction} in '1/10/2007' to '31/10/2007' ";
}
if (mth == "November")
{
Class1.month = "{Transaction.Dateoftransaction} in '1/11/2007' to '30/11/2007' ";
}
if (mth == "December")
{
Class1.month = "{Transaction.Dateoftransaction} in '1/12/2007' to '31/12/2007' ";

}
MonthlyReportPrint mr = new MonthlyReportPrint();
mr.Show();
}
}
}==============================================================================================using System;
using System.Collections.Generic;
using System.Text;using System.Data;
namespace WEIGHBRIDGE1
{
public class Class1
{
public Class1()
{
}
public static string strno;
public static string date;
public static string fdate;
public static string tdate;
public static string month;
public static string billno;
public static string cname;
//public string strno { get; set; }

}
}

========================================================================================using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WEIGHBRIDGE1
{
public partial class MonthlyReportPrint : Form
{
SqlConnection scn = new SqlConnection("Data Source=.;Initial Catalog=Weighingbridge;Integrated Security=True");
public MonthlyReportPrint()
{
InitializeComponent();
}
private void MonthlyReportPrint_Load(object sender, EventArgs e)
{
//scn.Open();
//SqlDataAdapter da = new SqlDataAdapter("select * from [Transaction] ", scn);
//DataSet ds = new DataSet();
//da.Fill(ds);
//CrystalmonthReport cm = new CrystalmonthReport();
//cm.SetDataSource(ds);
//crystalReportViewer1.ReportSource = cm;
crystalReportViewer1.SelectionFormula = Class1.month;
}
}
}=========================================================================================

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...