////////////////////////////////////////////////////////////////////////////////////
//
// By: Shahab Fatemi
// Date: 2006/10/06
//
// Message: IRAN and IRANIAN never need nuclear BOMB.
// All the world right know that we need NUCLEAR ENERGY.
// Our oil enery will be finished, and just nuclear energy can help us.
// All the world must know that IRANIAN love them and respect to them.
// Why our world mustn't have peace? Why the birds cann't sing?
// Why the fish cann't swim?
// War or not war? Which one is better?
// (I.LOVE.U) SHAHAB FATEMI.
////////////////////////////////////////////////////////////////////////////////////
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace ShopReport
{
public class Form1 : System.Windows.Forms.Form
{
#region Objects
private ReportViewer frm_Viewer;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button btn_Search;
private System.Data.SqlClient.SqlConnection sqlConn;
private System.Windows.Forms.DataGrid dg_Search;
private System.Windows.Forms.TextBox txt_From;
private System.Windows.Forms.TextBox txt_To;
private System.Windows.Forms.ComboBox cb_Sort;
private System.Windows.Forms.Button btn_Print;
private ShopReport.Report1 rpt_Report1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txt_Name;
private System.Windows.Forms.TextBox txt_Family;
private System.Data.SqlClient.SqlCommand sqlSelectCommand2;
private System.Data.SqlClient.SqlDataAdapter da_Search;
private ShopReport.Ds_Search ds_Search;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn2;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn3;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn4;
private ShopReport.Reports.GroupReport rpt_GroupReport;
private ShopReport.Reports.ChartReport rpt_ChartReport;
private System.ComponentModel.Container components = null;
#endregion
public Form1()
{
InitializeComponent();
Application.EnableVisualStyles();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.panel1 = new System.Windows.Forms.Panel();
this.txt_Family = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.btn_Search = new System.Windows.Forms.Button();
this.cb_Sort = new System.Windows.Forms.ComboBox();
this.label4 = new System.Windows.Forms.Label();
this.txt_To = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.txt_From = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.txt_Name = new System.Windows.Forms.TextBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.btn_Print = new System.Windows.Forms.Button();
this.dg_Search = new System.Windows.Forms.DataGrid();
this.ds_Search = new ShopReport.Ds_Search();
this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn();
this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridTextBoxColumn();
this.dataGridTextBoxColumn3 = new System.Windows.Forms.DataGridTextBoxColumn();
this.dataGridTextBoxColumn4 = new System.Windows.Forms.DataGridTextBoxColumn();
this.sqlConn = new System.Data.SqlClient.SqlConnection();
this.rpt_Report1 = new ShopReport.Report1();
this.sqlSelectCommand2 = new System.Data.SqlClient.SqlCommand();
this.da_Search = new System.Data.SqlClient.SqlDataAdapter();
this.rpt_GroupReport = new ShopReport.Reports.GroupReport();
this.rpt_ChartReport = new ShopReport.Reports.ChartReport();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dg_Search)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.ds_Search)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.White;
this.panel1.Controls.Add(this.txt_Family);
this.panel1.Controls.Add(this.label5);
this.panel1.Controls.Add(this.btn_Search);
this.panel1.Controls.Add(this.cb_Sort);
this.panel1.Controls.Add(this.label4);
this.panel1.Controls.Add(this.txt_To);
this.panel1.Controls.Add(this.label3);
this.panel1.Controls.Add(this.txt_From);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.txt_Name);
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Controls.Add(this.label1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(496, 112);
this.panel1.TabIndex = 0;
//
// txt_Family
//
this.txt_Family.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txt_Family.Location = new System.Drawing.Point(152, 32);
this.txt_Family.MaxLength = 30;
this.txt_Family.Name = "txt_Family";
this.txt_Family.Size = new System.Drawing.Size(236, 21);
this.txt_Family.TabIndex = 3;
this.txt_Family.Text = "";
//
// label5
//
this.label5.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(178)));
this.label5.Location = new System.Drawing.Point(99, 34);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(46, 16);
this.label5.TabIndex = 2;
this.label5.Text = "Family:";
//
// btn_Search
//
this.btn_Search.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(178)));
this.btn_Search.Image = ((System.Drawing.Image)(resources.GetObject("btn_Search.Image")));
this.btn_Search.Location = new System.Drawing.Point(408, 23);
this.btn_Search.Name = "btn_Search";
this.btn_Search.Size = new System.Drawing.Size(72, 67);
this.btn_Search.TabIndex = 10;
this.btn_Search.Text = "Search";
this.btn_Search.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
this.btn_Search.Click += new System.EventHandler(this.btn_Search_Click);
//
// cb_Sort
//
this.cb_Sort.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cb_Sort.Items.AddRange(new object[] {
"Family, Pay Date",
"Pay Date, Family",
"Family, Salary"});
this.cb_Sort.Location = new System.Drawing.Point(152, 80);
this.cb_Sort.Name = "cb_Sort";
this.cb_Sort.Size = new System.Drawing.Size(236, 21);
this.cb_Sort.TabIndex = 9;
//
// label4
//
this.label4.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(178)));
this.label4.Location = new System.Drawing.Point(95, 82);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(50, 16);
this.label4.TabIndex = 8;
this.label4.Text = "Sort By:";
//
// txt_To
//
this.txt_To.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txt_To.Location = new System.Drawing.Point(312, 56);
this.txt_To.MaxLength = 10;
this.txt_To.Name = "txt_To";
this.txt_To.Size = new System.Drawing.Size(76, 21);
this.txt_To.TabIndex = 7;
this.txt_To.Text = "";
//
// label3
//
this.label3.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(178)));
this.label3.Location = new System.Drawing.Point(256, 58);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(52, 16);
this.label3.TabIndex = 6;
this.label3.Text = "To Date:";
//
// txt_From
//
this.txt_From.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txt_From.Location = new System.Drawing.Point(152, 56);
this.txt_From.MaxLength = 10;
this.txt_From.Name = "txt_From";
this.txt_From.Size = new System.Drawing.Size(76, 21);
this.txt_From.TabIndex = 5;
this.txt_From.Text = "";
//
// label2
//
this.label2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(178)));
this.label2.Location = new System.Drawing.Point(77, 58);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(68, 16);
this.label2.TabIndex = 4;
this.label2.Text = "From Date:";
//
// txt_Name
//
this.txt_Name.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txt_Name.Location = new System.Drawing.Point(152, 8);
this.txt_Name.MaxLength = 20;
this.txt_Name.Name = "txt_Name";
this.txt_Name.Size = new System.Drawing.Size(236, 21);
this.txt_Name.TabIndex = 1;
this.txt_Name.Text = "";
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(16, 15);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(56, 51);
this.pictureBox1.TabIndex = 4;
this.pictureBox1.TabStop = false;
//
// label1
//
this.label1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(178)));
this.label1.Location = new System.Drawing.Point(104, 10);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Name:";
//
// panel2
//
this.panel2.BackColor = System.Drawing.Color.White;
this.panel2.Controls.Add(this.btn_Print);
this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel2.Location = new System.Drawing.Point(0, 382);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(496, 48);
this.panel2.TabIndex = 2;
//
// btn_Print
//
this.btn_Print.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(178)));
this.btn_Print.Image = ((System.Drawing.Image)(resources.GetObject("btn_Print.Image")));
this.btn_Print.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btn_Print.Location = new System.Drawing.Point(204, 6);
this.btn_Print.Name = "btn_Print";
this.btn_Print.Size = new System.Drawing.Size(81, 34);
this.btn_Print.TabIndex = 0;
this.btn_Print.Text = "Print";
this.btn_Print.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.btn_Print.Click += new System.EventHandler(this.btn_Print_Click);
//
// dg_Search
//
this.dg_Search.BackgroundColor = System.Drawing.Color.Silver;
this.dg_Search.CaptionText = "Search Result";
this.dg_Search.DataMember = "Salary";
this.dg_Search.DataSource = this.ds_Search;
this.dg_Search.Dock = System.Windows.Forms.DockStyle.Fill;
this.dg_Search.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dg_Search.Location = new System.Drawing.Point(0, 112);
this.dg_Search.Name = "dg_Search";
this.dg_Search.ReadOnly = true;
this.dg_Search.Size = new System.Drawing.Size(496, 270);
this.dg_Search.TabIndex = 1;
this.dg_Search.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
//
// ds_Search
//
this.ds_Search.DataSetName = "Ds_Search";
this.ds_Search.Locale = new System.Globalization.CultureInfo("fa-IR");
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.AlternatingBackColor = System.Drawing.Color.WhiteSmoke;
this.dataGridTableStyle1.DataGrid = this.dg_Search;
this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] {
this.dataGridTextBoxColumn1,
this.dataGridTextBoxColumn2,
this.dataGridTextBoxColumn3,
this.dataGridTextBoxColumn4});
this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle1.MappingName = "Salary";
//
// dataGridTextBoxColumn1
//
this.dataGridTextBoxColumn1.Format = "";
this.dataGridTextBoxColumn1.FormatInfo = null;
this.dataGridTextBoxColumn1.HeaderText = "Family";
this.dataGridTextBoxColumn1.MappingName = "e_Family";
this.dataGridTextBoxColumn1.NullText = "";
this.dataGridTextBoxColumn1.Width = 120;
//
// dataGridTextBoxColumn2
//
this.dataGridTextBoxColumn2.Format = "";
this.dataGridTextBoxColumn2.FormatInfo = null;
this.dataGridTextBoxColumn2.HeaderText = "Name";
this.dataGridTextBoxColumn2.MappingName = "e_Name";
this.dataGridTextBoxColumn2.NullText = "";
this.dataGridTextBoxColumn2.Width = 85;
//
// dataGridTextBoxColumn3
//
this.dataGridTextBoxColumn3.Format = "";
this.dataGridTextBoxColumn3.FormatInfo = null;
this.dataGridTextBoxColumn3.HeaderText = "Pay Date";
this.dataGridTextBoxColumn3.MappingName = "s_Date";
this.dataGridTextBoxColumn3.NullText = "";
this.dataGridTextBoxColumn3.Width = 75;
//
// dataGridTextBoxColumn4
//
this.dataGridTextBoxColumn4.Format = "C";
this.dataGridTextBoxColumn4.FormatInfo = null;
this.dataGridTextBoxColumn4.HeaderText = "Salary ($)";
this.dataGridTextBoxColumn4.MappingName = "s_Salary";
this.dataGridTextBoxColumn4.NullText = "";
this.dataGridTextBoxColumn4.Width = 75;
//
// sqlConn
//
this.sqlConn.ConnectionString = "workstation id=NT;packet size=4096;integrated security=SSPI;data source=NT;persis" +
"t security info=True;initial catalog=Shop";
//
// rpt_Report1
//
this.rpt_Report1.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.DefaultPaperOrientation;
this.rpt_Report1.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize;
this.rpt_Report1.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Upper;
this.rpt_Report1.PrintOptions.PrinterDuplex = CrystalDecisions.Shared.PrinterDuplex.Default;
//
// sqlSelectCommand2
//
this.sqlSelectCommand2.CommandText = "[SP_Search]";
this.sqlSelectCommand2.CommandType = System.Data.CommandType.StoredProcedure;
this.sqlSelectCommand2.Connection = this.sqlConn;
this.sqlSelectCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
this.sqlSelectCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@e_Name", System.Data.SqlDbType.NVarChar, 20));
this.sqlSelectCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@e_Family", System.Data.SqlDbType.NVarChar, 30));
this.sqlSelectCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@From_Date", System.Data.SqlDbType.NVarChar, 10));
this.sqlSelectCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@To_Date", System.Data.SqlDbType.NVarChar, 10));
this.sqlSelectCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@SortOrder", System.Data.SqlDbType.Int, 4));
//
// da_Search
//
this.da_Search.SelectCommand = this.sqlSelectCommand2;
this.da_Search.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Salary", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("s_ID", "s_ID"),
new System.Data.Common.DataColumnMapping("s_eID", "s_eID"),
new System.Data.Common.DataColumnMapping("s_Date", "s_Date"),
new System.Data.Common.DataColumnMapping("s_Salary", "s_Salary")})});
//
// rpt_GroupReport
//
this.rpt_GroupReport.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.DefaultPaperOrientation;
this.rpt_GroupReport.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize;
this.rpt_GroupReport.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Upper;
this.rpt_GroupReport.PrintOptions.PrinterDuplex = CrystalDecisions.Shared.PrinterDuplex.Default;
//
// rpt_ChartReport
//
this.rpt_ChartReport.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.DefaultPaperOrientation;
this.rpt_ChartReport.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize;
this.rpt_ChartReport.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Upper;
this.rpt_ChartReport.PrintOptions.PrinterDuplex = CrystalDecisions.Shared.PrinterDuplex.Default;
//
// Form1
//
this.AcceptButton = this.btn_Search;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
this.ClientSize = new System.Drawing.Size(496, 430);
this.Controls.Add(this.dg_Search);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(178)));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Shop Report";
this.Load += new System.EventHandler(this.Form1_Load);
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dg_Search)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.ds_Search)).EndInit();
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
//Select the first item as default.
cb_Sort.SelectedIndex = 0;
}
private void btn_Search_Click(object sender, System.EventArgs e)
{
try
{
//Clear dataset.
ds_Search.Salary.Clear();
//Set Sql parameters.
da_Search.SelectCommand.Parameters["@e_Name"] .Value = txt_Name.Text.Trim();
da_Search.SelectCommand.Parameters["@e_Family"] .Value = txt_Family.Text.Trim();
da_Search.SelectCommand.Parameters["@From_Date"].Value = txt_From.Text.Trim();
da_Search.SelectCommand.Parameters["@To_Date"] .Value = txt_To.Text.Trim();
da_Search.SelectCommand.Parameters["@SortOrder"].Value = cb_Sort.SelectedIndex;
//Fill data in dataset.
da_Search.Fill(ds_Search.Salary);
}
catch(SqlException ex)
{
MessageBox.Show(ex.Message , "Error:"+ex.Number.ToString());
}
finally
{
//Do Nothing.
}
}
private void btn_Print_Click(object sender, System.EventArgs e)
{
#region Problem 2
/*Line 1*/ //rpt_Report1.SetDataSource(ds_Search.DailySelling);
/*Line 2*/ //rpt_Report1.PrintToPrinter(1 , true , 0 , 65500);
#endregion
#region Problem 2
/*
frm_Viewer = new ReportViewer();
rpt_Report1.SetDataSource(ds_Search.Salary);
frm_Viewer.crv_Viewer.ReportSource = rpt_Report1;
frm_Viewer.ShowDialog();
*/
#endregion
#region Problem 3
/*
frm_Viewer = new ReportViewer();
rpt_GroupReport.SetDataSource(ds_Search.Salary);
frm_Viewer.crv_Viewer.ReportSource = rpt_GroupReport;
frm_Viewer.ShowDialog();
*/
#endregion
#region Ex1
frm_Viewer = new ReportViewer();
rpt_ChartReport.SetDataSource(ds_Search.Salary);
rpt_ChartReport.SetParameterValue("StringParameter" , "This is a test!");
frm_Viewer.crv_Viewer.ReportSource = rpt_ChartReport;
frm_Viewer.ShowDialog();
#endregion
}
}
}
////////////////////////////////////////////////////////////////////////////////////
//
// By: Shahab Fatemi
// Date: 2006/10/06
//
// Message: IRAN and IRANIAN never need nuclear BOMB.
// All the world right know that we need NUCLEAR ENERGY.
// Our oil enery will be finished, and just nuclear energy can help us.
// All the world must know that IRANIAN love them and respect to them.
// Why our world mustn't have peace? Why the birds cann't sing?
// Why the fish cann't swim?
// War or not war? Which one is better?
// (I.LOVE.U) SHAHAB FATEMI.
////////////////////////////////////////////////////////////////////////////////////