using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
System.Collections;
using
System.IO;
using
System.Runtime.InteropServices;
using
System.Net;
using
System.Data.SqlClient;
using
CrystalDecisions.Shared;
using
CrystalDecisions.CrystalReports.Engine;
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
namespace
CrystalReport
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
public partial class Main : Form
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
public Main()
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
InitializeComponent();
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//当前选中的报表路径
public string Path_Str = "";
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//TabPage序列
public int FI = 0;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//RadioButton序列
public int FISUB = 0;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//RadioButton宽度
public int FWidth = 0;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//RadioButton高度
public int FHeight = 0;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//RadioButton行数
public int FLines = 0;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//当前应用程序执行路径
public string FExePath = "";
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//IP地址
public string FIP;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//连接字符串
public string FConStr;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//主机名Hostname
public string FHostname;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//数据库Dbname
public string FDbname;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//username
public string FUsername;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//password
public string FPassword;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//创建TabPage
public TabPage[] mTabPage = new TabPage[500];
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//创建GroupBox
public GroupBox[] mGroupBox = new GroupBox[500];
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//创建RadioButton
public RadioButton[] mRadioButton = new RadioButton[500];
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public void CreateAll(DirectoryInfo source)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//判断rpt路径是否存在
if (Directory.Exists(source.FullName) == false)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
MessageBox.Show(source.FullName + " 不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
Application.Exit();
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//遍历目录
foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//MessageBox.Show(diSourceSubDir.Name, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//实例TabPage
mTabPage[FI] = new TabPage();
mTabPage[FI].Parent = tabControl1;
mTabPage[FI].Text = diSourceSubDir.Name;
mTabPage[FI].TabIndex = FI;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//实例GroupBox
mGroupBox[FI] = new GroupBox();
mGroupBox[FI].Parent = mTabPage[FI];
mGroupBox[FI].Dock = DockStyle.Fill;
mGroupBox[FI].Text = "选择报表";
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//行次
int MI = 0;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
int x = mGroupBox[FI].Location.X;
int y = mGroupBox[FI].Location.Y;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//遍历文件
foreach (FileInfo fi in diSourceSubDir.GetFiles())
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//换列显示
if (MI % FLines == 0)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (MI != 0)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
x = x + FWidth;
y = 0;
MI = 0;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//实例RadioButton
mRadioButton[FISUB] = new RadioButton();
mRadioButton[FISUB].Parent = mGroupBox[FI];
mRadioButton[FISUB].Location = new System.Drawing.Point(x + 25, y + 15 + MI * FHeight);
mRadioButton[FISUB].Text = fi.Name;
mRadioButton[FISUB].AutoSize = true;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//默认选择第一个
if (mRadioButton[FISUB].Location.Y == 15)
if (mRadioButton[FISUB].Location.X == 25)
mRadioButton[FISUB].Checked = true;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//行次累加
MI = MI + 1;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//当前的RadioButton总Id累加
FISUB = FISUB + 1;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//当前的TabPage总Id累加
FI = FI + 1;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//递归
CreateAll(diSourceSubDir);
}
}
catch
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//调用kernel32.dll读写ini文件信息
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//写ini
public void IniWriteValue(string Section, string Key, string Value, string filepath)//对ini文件进行写操作的函数
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
WritePrivateProfileString(Section, Key, Value, filepath);
}
catch
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//读ini
public string IniReadValue(string Section, string Key, string filepath) //对ini文件进行读操作的函数
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section, Key, "无法读取对应的值", temp, 255, filepath);
return temp.ToString();
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//字符串转换为整型
public static int IntParse(string objValue, int defaultValue)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
int returnValue = defaultValue;
if (!string.IsNullOrEmpty(objValue))
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
returnValue = int.Parse(objValue);
}
catch
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
returnValue = defaultValue;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return returnValue;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//reportDocument conn to DB
private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Tables tables = reportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
TableLogOnInfo tableLogonInfo = table.LogOnInfo;
tableLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogonInfo);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
}
catch
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void Main_Load(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//取得当前路径
FExePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Replace("file:\\", "").Replace("\\", @"\");
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//从ini读取RPT存放路径
Path_Str = IniReadValue("PathInfo", "Path", FExePath + "\\CrystalReport.ini");
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//DBInfo
FHostname = IniReadValue("DBInfo", "Host", FExePath + "\\CrystalReport.ini");
FDbname = IniReadValue("DBInfo", "Dbname", FExePath + "\\CrystalReport.ini");
FUsername = IniReadValue("DBInfo", "User", FExePath + "\\CrystalReport.ini");
FPassword = IniReadValue("DBInfo", "Pass", FExePath + "\\CrystalReport.ini");
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//从ini读取RPT显示信息
FWidth = IntParse(IniReadValue("ViewInfo", "Width", FExePath + "\\CrystalReport.ini"), 160);
FHeight = IntParse(IniReadValue("ViewInfo", "Height", FExePath + "\\CrystalReport.ini"), 25);
FLines = IntParse(IniReadValue("ViewInfo", "Lines", FExePath + "\\CrystalReport.ini"), 8);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//IP地址
IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
FIP = ips[0].ToString();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//连接字符串
FConStr = @"Data Source=" + FHostname + ";Database=" + FDbname + ";User ID=" + FUsername + ";Password=" + FPassword;
}
catch (Exception)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
MessageBox.Show("CrystalReport.ini配置错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
Application.Exit();
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void Main_Shown(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//判断rpt路径是否存在
if (Directory.Exists(Path_Str) == false)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
MessageBox.Show(Path_Str + " 不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
Application.Exit();
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//窗体定位
Main.ActiveForm.Width = IntParse(IniReadValue("FormInfo", "Width", FExePath + "\\CrystalReport.ini"), 540); ;
Main.ActiveForm.Height = IntParse(IniReadValue("FormInfo", "Height", FExePath + "\\CrystalReport.ini"), 310);
Main.ActiveForm.Left = IntParse(IniReadValue("FormInfo", "Left", FExePath + "\\CrystalReport.ini"), 310);
Main.ActiveForm.Top = IntParse(IniReadValue("FormInfo", "Top", FExePath + "\\CrystalReport.ini"), 310);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//delpage1
tabControl1.TabPages.Clear();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//遍历RPT路径并动态新增页签及radio报表名称
DirectoryInfo diSource = new DirectoryInfo(Path_Str);
CreateAll(diSource);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//addpage1
tabControl1.Controls.Add(mtabPageX);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//条件一 --------------------------------------------------------------------------
cbo10.SelectedIndex = 0;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
DataSet DataSet1 = new DataSet();
SqlDataAdapter SqlDataAdapter1 = new SqlDataAdapter();
SqlCommand sqlSelectCommand1 = new SqlCommand();
SqlConnection sqlConnection1 = new SqlConnection();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//Set the variables.
sqlSelectCommand1.CommandText = @"SELECT MA001,RTRIM(MA001)+'-'+RTRIM(MA002) AS MA001C FROM COPMA ORDER BY MA001";
sqlSelectCommand1.Connection = sqlConnection1;
sqlConnection1.ConnectionString = FConStr;
SqlDataAdapter1.SelectCommand = sqlSelectCommand1;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// Fill the data set with the result of the query.
// The results are stored in the data set called "Table1".
SqlDataAdapter1.Fill(DataSet1, "Table1");
SqlDataAdapter1.Fill(DataSet1, "Table2");
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//绑定
cbo11.DataSource = DataSet1.Tables["Table1"];
cbo11.DisplayMember = "MA001C";
cbo11.ValueMember = "MA001";
cbo12.DataSource = DataSet1.Tables["Table2"];
cbo12.DisplayMember = "MA001C";
cbo12.ValueMember = "MA001";
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//条件二 --------------------------------------------------------------------------
cbo13.SelectedIndex = 0;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
DataSet DataSet2 = new DataSet();
SqlDataAdapter SqlDataAdapter2 = new SqlDataAdapter();
SqlCommand sqlSelectCommand2 = new SqlCommand();
SqlConnection sqlConnection2 = new SqlConnection();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//Set the variables.
sqlSelectCommand2.CommandText = @"SELECT MA001,RTRIM(MA001)+'-'+RTRIM(MA002) AS MA001C FROM COPMA ORDER BY MA001";
sqlSelectCommand2.Connection = sqlConnection2;
sqlConnection2.ConnectionString = FConStr;
SqlDataAdapter2.SelectCommand = sqlSelectCommand2;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// Fill the data set with the result of the query.
// The results are stored in the data set called "Table1".
SqlDataAdapter2.Fill(DataSet2, "Table1");
SqlDataAdapter2.Fill(DataSet2, "Table2");
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//绑定
cbo14.DataSource = DataSet2.Tables["Table1"];
cbo14.DisplayMember = "MA001C";
cbo14.ValueMember = "MA001";
cbo15.DataSource = DataSet2.Tables["Table2"];
cbo15.DisplayMember = "MA001C";
cbo15.ValueMember = "MA001";
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//依据 --------------------------------------------------------------------------
cbo07.SelectedIndex = 0;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
DataSet DataSet3 = new DataSet();
SqlDataAdapter SqlDataAdapter3 = new SqlDataAdapter();
SqlCommand sqlSelectCommand3 = new SqlCommand();
SqlConnection sqlConnection3 = new SqlConnection();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//Set the variables.
sqlSelectCommand3.CommandText = @"SELECT MA001,RTRIM(MA001)+'-'+RTRIM(MA002) AS MA001C FROM COPMA ORDER BY MA001";
sqlSelectCommand3.Connection = sqlConnection3;
sqlConnection3.ConnectionString = FConStr;
SqlDataAdapter3.SelectCommand = sqlSelectCommand3;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// Fill the data set with the result of the query.
// The results are stored in the data set called "Table1".
SqlDataAdapter3.Fill(DataSet3, "Table1");
SqlDataAdapter3.Fill(DataSet3, "Table2");
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//绑定
cbo08.DataSource = DataSet3.Tables["Table1"];
cbo08.DisplayMember = "MA001C";
cbo08.ValueMember = "MA001";
cbo09.DataSource = DataSet3.Tables["Table2"];
cbo09.DisplayMember = "MA001C";
cbo09.ValueMember = "MA001";
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
catch
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void button1_Click(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//获取当前页签及当前页签选中的报表
string mClass = tabControl1.SelectedTab.Text;
string mRpt = "";
string mRTPPath = "";
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (mClass == "动态环比同比报表")
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//执行存储过程
String mTYPE, mTIME1_BEGIN, mTIME1_END, mTIME2_BEGIN, mTIME2_END, mBASE;
int mCBO07;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (rdo01.Checked == true)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
mTYPE = "1";
}
else
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
mTYPE = "2";
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
mTIME1_BEGIN = ed03.Text;
mTIME1_END = ed04.Text;
mTIME2_BEGIN = ed05.Text;
mTIME2_END = ed06.Text;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
mCBO07 = cbo07.SelectedIndex + 1;
mBASE = mCBO07.ToString();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
try
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
SqlConnection sqlConnection1 = new SqlConnection(FConStr);
sqlConnection1.Open();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
SqlCommand SqlCommand1 = new SqlCommand();
SqlCommand1.CommandText = "SALE_SEARCH_TWO_TIMES";
SqlCommand1.CommandType = CommandType.StoredProcedure;
SqlCommand1.Connection = sqlConnection1;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
SqlCommand1.Parameters.Add("@TYPE", SqlDbType.VarChar);
SqlCommand1.Parameters.Add("@TIME1_BEGIN", SqlDbType.VarChar);
SqlCommand1.Parameters.Add("@TIME1_END", SqlDbType.VarChar);
SqlCommand1.Parameters.Add("@TIME2_BEGIN", SqlDbType.VarChar);
SqlCommand1.Parameters.Add("@TIME2_END", SqlDbType.VarChar);
SqlCommand1.Parameters.Add("@WHERE1", SqlDbType.VarChar);
SqlCommand1.Parameters.Add("@WHERE1_BEGIN", SqlDbType.VarChar);
SqlCommand1.Parameters.Add("@WHERE1_END", SqlDbType.VarChar);
SqlCommand1.Parameters.Add("@WHERE2", SqlDbType.VarChar);
SqlCommand1.Parameters.Add("@WHERE2_BEGIN", SqlDbType.VarChar);
SqlCommand1.Parameters.Add("@WHERE2_END", SqlDbType.VarChar);
SqlCommand1.Parameters.Add("@BASE", SqlDbType.VarChar);
SqlCommand1.Parameters.Add("@IP", SqlDbType.VarChar);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
SqlCommand1.Parameters[0].Value = mTYPE;
SqlCommand1.Parameters[1].Value = mTIME1_BEGIN;
SqlCommand1.Parameters[2].Value = mTIME1_END;
SqlCommand1.Parameters[3].Value = mTIME2_BEGIN;
SqlCommand1.Parameters[4].Value = mTIME2_END;
SqlCommand1.Parameters[5].Value = Convert.ToString(cbo10.SelectedIndex + 1);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (cbo11.SelectedValue == null)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
SqlCommand1.Parameters[6].Value = "";
}
else
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
SqlCommand1.Parameters[6].Value = cbo11.SelectedValue;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (cbo12.SelectedValue == null)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
SqlCommand1.Parameters[7].Value = "";
}
else
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
SqlCommand1.Parameters[7].Value = cbo12.SelectedValue;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
SqlCommand1.Parameters[8].Value = Convert.ToString(cbo13.SelectedIndex + 1);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (cbo14.SelectedValue == null)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
SqlCommand1.Parameters[9].Value = "";
}
else
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
SqlCommand1.Parameters[9].Value = cbo14.SelectedValue;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (cbo15.SelectedValue == null)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
SqlCommand1.Parameters[10].Value = "";
}
else
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
SqlCommand1.Parameters[10].Value = cbo15.SelectedValue;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
SqlCommand1.Parameters[11].Value = mBASE;
SqlCommand1.Parameters[12].Value = FIP;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
Int32 mRowsAffected = SqlCommand1.ExecuteNonQuery();
sqlConnection1.Close();
}
catch (Exception)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
MessageBox.Show("SALE_SEARCH_TWO_TIMES执行失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//新建实例
Report_View RPT = new Report_View();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//获得RPT文件路径
if (mClass == "动态环比同比报表")
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
mRpt = "动态环比同比报表.rpt";
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
mRTPPath = Path_Str + "\\" + "动态环比同比报表.rpt";
}
else
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
for (int MI = 0; MI <= FISUB - 1; MI++)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (mRadioButton[MI].Parent.Parent.Text == mClass)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (mRadioButton[MI].Checked == true)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
mRpt = mRadioButton[MI].Text;
break;
}
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
mRTPPath = Path_Str + "\\" + mClass + "\\" + mRpt;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//预览窗口显示
RPT.Text = "预览_" + mRpt;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
RPT.Show();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//Load rpt
RPT.RDT1.Load(mRTPPath);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//trans Param
if (mClass == "动态环比同比报表")
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ParameterField paramField = new ParameterField();
ParameterFields paramFields = new ParameterFields();
ParameterRangeValue rangeVal = new ParameterRangeValue();
ParameterDiscreteValue discreteVal = new ParameterDiscreteValue();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//1
paramField = new ParameterField();
paramField.ParameterFieldName = "依据编号";
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (Convert.ToInt32(cbo08.SelectedValue.ToString()) < Convert.ToInt32(cbo09.SelectedValue.ToString()))
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
rangeVal.StartValue = cbo08.SelectedValue;
rangeVal.EndValue = cbo09.SelectedValue;
}
else
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
rangeVal.StartValue = cbo09.SelectedValue;
rangeVal.EndValue = cbo08.SelectedValue;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
paramField.CurrentValues.Add(rangeVal);
paramFields.Add(paramField);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//2
paramField = new ParameterField();
paramField.ParameterFieldName = "IP";
discreteVal.Value = FIP;
paramField.CurrentValues.Add(discreteVal);
paramFields.Add(paramField);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
RPT.RPT1.ParameterFieldInfo = paramFields;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//conn to DB
ConnectionInfo ConnectionInfo1 = new ConnectionInfo();
ConnectionInfo1.DatabaseName = FDbname;
ConnectionInfo1.UserID = FUsername;
ConnectionInfo1.Password = FPassword;
ConnectionInfo1.ServerName = FHostname;
SetDBLogonForReport(ConnectionInfo1, RPT.RDT1);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//Add to Report View
RPT.RPT1.ReportSource = RPT.RDT1;
}
catch
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void cbo07_SelectedIndexChanged(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//开始、结束两下拉框填值
DataSet DataSet1 = new DataSet();
SqlDataAdapter SqlDataAdapter1 = new SqlDataAdapter();
SqlCommand sqlSelectCommand1 = new SqlCommand();
SqlConnection sqlConnection1 = new SqlConnection();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//Set the variables.
if (cbo07.SelectedIndex == 0)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MA001 AS MA001,RTRIM(MA001)+'-'+RTRIM(MA002) AS MA001C FROM COPMA ORDER BY MA001";
}
else if (cbo07.SelectedIndex == 1)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MR002 AS MA001,RTRIM(MR002)+'-'+RTRIM(MR003) AS MA001C FROM CMSMR WHERE MR001='1' ORDER BY MR002";
}
else if (cbo07.SelectedIndex == 2)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MR002 AS MA001,RTRIM(MR002)+'-'+RTRIM(MR003) AS MA001C FROM CMSMR WHERE MR001='3' ORDER BY MR002";
}
else if (cbo07.SelectedIndex == 3)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MR002 AS MA001,RTRIM(MR002)+'-'+RTRIM(MR003) AS MA001C FROM CMSMR WHERE MR001='4' ORDER BY MR002";
}
else if (cbo07.SelectedIndex == 4)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT ME001 AS MA001,RTRIM(ME001)+'-'+RTRIM(ME002) AS MA001C FROM CMSME ORDER BY ME001";
}
else if (cbo07.SelectedIndex == 5)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MV001 AS MA001,RTRIM(MV001)+'-'+RTRIM(MV002) AS MA001C FROM CMSMV ORDER BY MV001";
}
else if (cbo07.SelectedIndex == 6)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MV001 AS MA001,RTRIM(MV001)+'-'+RTRIM(MV002) AS MA001C FROM CMSMV ORDER BY MV001";
}
else if (cbo07.SelectedIndex == 7)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MB001 AS MA001,RTRIM(MB001)+'-'+RTRIM(MB002) AS MA001C FROM INVMB ORDER BY MB001";
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
sqlSelectCommand1.Connection = sqlConnection1;
sqlConnection1.ConnectionString = FConStr;
SqlDataAdapter1.SelectCommand = sqlSelectCommand1;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// Fill the data set with the result of the query.
// The results are stored in the data set called "Table1".
SqlDataAdapter1.Fill(DataSet1, "Table1");
SqlDataAdapter1.Fill(DataSet1, "Table2");
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//绑定
cbo08.DataSource = DataSet1.Tables["Table1"];
cbo08.DisplayMember = "MA001C";
cbo08.ValueMember = "MA001";
cbo09.DataSource = DataSet1.Tables["Table2"];
cbo09.DisplayMember = "MA001C";
cbo09.ValueMember = "MA001";
}
catch
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void cbo10_SelectedIndexChanged(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//开始、结束两下拉框填值
if (cbo10.SelectedIndex != 8)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DataSet DataSet1 = new DataSet();
SqlDataAdapter SqlDataAdapter1 = new SqlDataAdapter();
SqlCommand sqlSelectCommand1 = new SqlCommand();
SqlConnection sqlConnection1 = new SqlConnection();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//Set the variables.
if (cbo10.SelectedIndex == 0)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MA001 AS MA001,RTRIM(MA001)+'-'+RTRIM(MA002) AS MA001C FROM COPMA ORDER BY MA001";
}
else if (cbo10.SelectedIndex == 1)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MR002 AS MA001,RTRIM(MR002)+'-'+RTRIM(MR003) AS MA001C FROM CMSMR WHERE MR001='1' ORDER BY MR002";
}
else if (cbo10.SelectedIndex == 2)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MR002 AS MA001,RTRIM(MR002)+'-'+RTRIM(MR003) AS MA001C FROM CMSMR WHERE MR001='3' ORDER BY MR002";
}
else if (cbo10.SelectedIndex == 3)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MR002 AS MA001,RTRIM(MR002)+'-'+RTRIM(MR003) AS MA001C FROM CMSMR WHERE MR001='4' ORDER BY MR002";
}
else if (cbo10.SelectedIndex == 4)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT ME001 AS MA001,RTRIM(ME001)+'-'+RTRIM(ME002) AS MA001C FROM CMSME ORDER BY ME001";
}
else if (cbo10.SelectedIndex == 5)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MV001 AS MA001,RTRIM(MV001)+'-'+RTRIM(MV002) AS MA001C FROM CMSMV ORDER BY MV001";
}
else if (cbo10.SelectedIndex == 6)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MV001 AS MA001,RTRIM(MV001)+'-'+RTRIM(MV002) AS MA001C FROM CMSMV ORDER BY MV001";
}
else if (cbo10.SelectedIndex == 7)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MB001 AS MA001,RTRIM(MB001)+'-'+RTRIM(MB002) AS MA001C FROM INVMB ORDER BY MB001";
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
sqlSelectCommand1.Connection = sqlConnection1;
sqlConnection1.ConnectionString = FConStr;
SqlDataAdapter1.SelectCommand = sqlSelectCommand1;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// Fill the data set with the result of the query.
// The results are stored in the data set called "Table1".
SqlDataAdapter1.Fill(DataSet1, "Table1");
SqlDataAdapter1.Fill(DataSet1, "Table2");
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//绑定
cbo11.DataSource = DataSet1.Tables["Table1"];
cbo11.DisplayMember = "MA001C";
cbo11.ValueMember = "MA001";
cbo12.DataSource = DataSet1.Tables["Table2"];
cbo12.DisplayMember = "MA001C";
cbo12.ValueMember = "MA001";
}
else
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
cbo11.DataSource = null;
cbo11.DisplayMember = "";
cbo11.ValueMember = "";
cbo12.DataSource = null;
cbo12.DisplayMember = "";
cbo12.ValueMember = "";
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
catch
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void cbo13_SelectedIndexChanged(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//开始、结束两下拉框填值
if (cbo13.SelectedIndex != 8)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DataSet DataSet1 = new DataSet();
SqlDataAdapter SqlDataAdapter1 = new SqlDataAdapter();
SqlCommand sqlSelectCommand1 = new SqlCommand();
SqlConnection sqlConnection1 = new SqlConnection();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//Set the variables.
if (cbo13.SelectedIndex == 0)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MA001 AS MA001,RTRIM(MA001)+'-'+RTRIM(MA002) AS MA001C FROM COPMA ORDER BY MA001";
}
else if (cbo13.SelectedIndex == 1)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MR002 AS MA001,RTRIM(MR002)+'-'+RTRIM(MR003) AS MA001C FROM CMSMR WHERE MR001='1' ORDER BY MR002";
}
else if (cbo13.SelectedIndex == 2)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MR002 AS MA001,RTRIM(MR002)+'-'+RTRIM(MR003) AS MA001C FROM CMSMR WHERE MR001='3' ORDER BY MR002";
}
else if (cbo13.SelectedIndex == 3)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MR002 AS MA001,RTRIM(MR002)+'-'+RTRIM(MR003) AS MA001C FROM CMSMR WHERE MR001='4' ORDER BY MR002";
}
else if (cbo13.SelectedIndex == 4)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT ME001 AS MA001,RTRIM(ME001)+'-'+RTRIM(ME002) AS MA001C FROM CMSME ORDER BY ME001";
}
else if (cbo13.SelectedIndex == 5)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MV001 AS MA001,RTRIM(MV001)+'-'+RTRIM(MV002) AS MA001C FROM CMSMV ORDER BY MV001";
}
else if (cbo13.SelectedIndex == 6)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MV001 AS MA001,RTRIM(MV001)+'-'+RTRIM(MV002) AS MA001C FROM CMSMV ORDER BY MV001";
}
else if (cbo13.SelectedIndex == 7)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
sqlSelectCommand1.CommandText = @"SELECT MB001 AS MA001,RTRIM(MB001)+'-'+RTRIM(MB002) AS MA001C FROM INVMB ORDER BY MB001";
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
sqlSelectCommand1.Connection = sqlConnection1;
sqlConnection1.ConnectionString = FConStr;
SqlDataAdapter1.SelectCommand = sqlSelectCommand1;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// Fill the data set with the result of the query.
// The results are stored in the data set called "Table1".
SqlDataAdapter1.Fill(DataSet1, "Table1");
SqlDataAdapter1.Fill(DataSet1, "Table2");
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//绑定
cbo14.DataSource = DataSet1.Tables["Table1"];
cbo14.DisplayMember = "MA001C";
cbo14.ValueMember = "MA001";
cbo15.DataSource = DataSet1.Tables["Table2"];
cbo15.DisplayMember = "MA001C";
cbo15.ValueMember = "MA001";
}
else
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
cbo14.DataSource = null;
cbo14.DisplayMember = "";
cbo14.ValueMember = "";
cbo15.DataSource = null;
cbo15.DisplayMember = "";
cbo15.ValueMember = "";
}
}
catch
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void button2_Click(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.Close();//关闭
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void Main_FormClosed(object sender, FormClosedEventArgs e)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//保存当前窗口宽高
string mWidth = Main.ActiveForm.Width.ToString();
string mHeight = Main.ActiveForm.Height.ToString();
string mLeft = Main.ActiveForm.Left.ToString();
string mTop = Main.ActiveForm.Top.ToString();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
IniWriteValue("FormInfo", "Width", mWidth, FExePath + "\\CrystalReport.ini");
IniWriteValue("FormInfo", "Height", mHeight, FExePath + "\\CrystalReport.ini");
IniWriteValue("FormInfo", "Left", mLeft, FExePath + "\\CrystalReport.ini");
IniWriteValue("FormInfo", "Top", mTop, FExePath + "\\CrystalReport.ini");
}
catch
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
}
C
转载于:https://www.cnblogs.com/safezone/articles/1251142.html