📄 importprice_file_1.aspx.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.IO;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class EditPrice : System.Web.UI.Page
{
#region 事件处理
protected void Page_Load(object sender, EventArgs e)
{
if ( !Page.IsPostBack )
{
DBConnector dbConn = new DBConnector();
// 更新DropDownList内容
/*
string strSQL_MakInfo = "SELECT * FROM Make";
DataSet dsMake = dbConn.Query( strSQL_MakInfo );
ddlMake.DataTextField = "MakeName";
ddlMake.DataValueField = "MakeCode";
ddlMake.DataSource = dsMake;
ddlMake.DataBind();
*/
hidVersion.Value = Request.QueryString["version"];
hidModels.Value = Request.QueryString["models"];
string strSQL_LvlInfo = "SELECT * FROM level";
DataSet dsLevel = dbConn.Query(strSQL_LvlInfo);
ddlLevel.DataTextField = "级别名称";
ddlLevel.DataValueField = "级别层次";
ddlLevel.DataSource = dsLevel;
ddlLevel.DataBind();
// 更新TextBox中的内容
string strVersion = hidVersion.Value;
if ( null==strVersion || string.Empty==strVersion )
return;
string strSQL_PrcInfo = "SELECT * FROM priceInfo WHERE 价格版本号 LIKE '" + strVersion + "'";
DataSet dsPrcInfo = dbConn.Query(strSQL_PrcInfo);
txtVersion.Text = dsPrcInfo.Tables[0].Rows[0]["价格名称"].ToString(); // 价格名称
int iStatus = Convert.ToInt32(dsPrcInfo.Tables[0].Rows[0]["状态"].ToString()); // 价格状态
if (1 == iStatus)
txtStatus.Text = "制作中";
else if (2 == iStatus)
txtStatus.Text = "已完成";
else if (3 == iStatus)
txtStatus.Text = "已发布";
else
txtStatus.Text = "已废弃";
ddlLevel.SelectedValue = dsPrcInfo.Tables[0].Rows[0]["价格层次"].ToString();
txtUpper.Text = dsPrcInfo.Tables[0].Rows[0]["波动上限"].ToString();
txtLower.Text = dsPrcInfo.Tables[0].Rows[0]["波动下限"].ToString();
txtRemark.Text = dsPrcInfo.Tables[0].Rows[0]["备注"].ToString();
txtImpUpper.Text = dsPrcInfo.Tables[0].Rows[0]["导入上限"].ToString();
txtImpLower.Text = dsPrcInfo.Tables[0].Rows[0]["导入下限"].ToString();
hidTableName.Value = dsPrcInfo.Tables[0].Rows[0]["数据表名称"].ToString();
}
}
/*
protected void btnFilterMark_1_Click(object sender, EventArgs e)
{
int iIndex = txtFilter.Text.IndexOf(btnFilterMark_1.Text);
if (iIndex < 0)
{
txtFilter.Text += btnFilterMark_1.Text + ",";
}
else
{
txtFilter.Text = txtFilter.Text.Remove(iIndex, 2);
}
}
protected void btnFilterMark_2_Click(object sender, EventArgs e)
{
int iIndex = txtFilter.Text.IndexOf(btnFilterMark_2.Text);
if (iIndex < 0)
{
txtFilter.Text += btnFilterMark_2.Text + ",";
}
else
{
txtFilter.Text = txtFilter.Text.Remove(iIndex, 2);
}
}
protected void btnFilterMark_3_Click(object sender, EventArgs e)
{
int iIndex = txtFilter.Text.IndexOf(btnFilterMark_3.Text);
if (iIndex < 0)
{
txtFilter.Text += btnFilterMark_3.Text + ",";
}
else
{
txtFilter.Text = txtFilter.Text.Remove(iIndex, 2);
}
}
protected void btnFilterMark_4_Click(object sender, EventArgs e)
{
int iIndex = txtFilter.Text.IndexOf(btnFilterMark_4.Text);
if (iIndex < 0)
{
txtFilter.Text += btnFilterMark_4.Text + ",";
}
else
{
txtFilter.Text = txtFilter.Text.Remove(iIndex, 2);
}
}
protected void btnFilterMark_5_Click(object sender, EventArgs e)
{
int iIndex = txtFilter.Text.IndexOf(btnFilterMark_5.Text);
if (iIndex < 0)
{
txtFilter.Text += btnFilterMark_5.Text + ",";
}
else
{
txtFilter.Text = txtFilter.Text.Remove(iIndex, 2);
}
}
protected void btnFilterMark_6_Click(object sender, EventArgs e)
{
int iIndex = txtFilter.Text.IndexOf(btnFilterMark_6.Text);
if (iIndex < 0)
{
txtFilter.Text += btnFilterMark_6.Text + ",";
}
else
{
txtFilter.Text = txtFilter.Text.Remove(iIndex, 2);
}
}
protected void btnFilterMark_7_Click(object sender, EventArgs e)
{
int iIndex = txtFilter.Text.IndexOf(btnFilterMark_7.Text);
if (iIndex<0)
{
txtFilter.Text += btnFilterMark_7.Text + ",";
}
else
{
txtFilter.Text = txtFilter.Text.Remove(iIndex, 2);
}
}
protected void btnFilterMark_8_Click(object sender, EventArgs e)
{
int iIndex = txtFilter.Text.IndexOf(btnFilterMark_8.Text);
if (iIndex < 0)
{
txtFilter.Text += btnFilterMark_8.Text + ",";
}
else
{
txtFilter.Text = txtFilter.Text.Remove(iIndex, 2);
}
}
protected void btnFilterMark_9_Click(object sender, EventArgs e)
{
int iIndex = txtFilter.Text.IndexOf(btnFilterMark_9.Text);
if (iIndex < 0)
{
txtFilter.Text += btnFilterMark_9.Text + ",";
}
else
{
txtFilter.Text = txtFilter.Text.Remove(iIndex, 2);
}
}
protected void btnFilterMark_10_Click(object sender, EventArgs e)
{
int iIndex = txtFilter.Text.IndexOf(btnFilterMark_10.Text);
if (iIndex < 0)
{
txtFilter.Text += btnFilterMark_10.Text + ",";
}
else
{
txtFilter.Text = txtFilter.Text.Remove(iIndex, 2);
}
}
protected void btnFilterMark_11_Click(object sender, EventArgs e)
{
int iIndex = txtFilter.Text.IndexOf(btnFilterMark_11.Text);
if (iIndex < 0)
{
txtFilter.Text += btnFilterMark_11.Text + ",";
}
else
{
txtFilter.Text = txtFilter.Text.Remove(iIndex, 2);
}
}
protected void btnFilterMark_12_Click(object sender, EventArgs e)
{
int iIndex = txtFilter.Text.IndexOf(btnFilterMark_12.Text);
if (iIndex < 0)
{
txtFilter.Text += btnFilterMark_12.Text + ",";
}
else
{
txtFilter.Text = txtFilter.Text.Remove(iIndex, 2);
}
}
protected void btnFilterMark_13_Click(object sender, EventArgs e)
{
int iIndex = txtFilter.Text.IndexOf(btnFilterMark_13.Text);
if (iIndex < 0)
{
txtFilter.Text += btnFilterMark_13.Text + ",";
}
else
{
txtFilter.Text = txtFilter.Text.Remove(iIndex, 2);
}
}
*/
/// <summary>
/// 检查文件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnCheck_Click(object sender, EventArgs e)
{
/*
/////////////////////////////////////////////////////////////////////////
// 过滤符号
const string strDefualtFilter = " -"; // 默认过滤符号
////////////////////////////////////
string strFilterCharacter = null; // 过滤符号字符串
if ( txtFilter.Text.Length > 0 )
{
strFilterCharacter = txtFilter.Text.Replace(",", "");
}
strFilterCharacter += strDefualtFilter;
/////////////////////////////////////////////////////////////////////////
*/
/////////////////////////////////////////////////////////////////////////
// 读取文件
string strFileName = fUpload.Value; // 文件路径
if (strFileName == string.Empty)
return;
DataSet dsXls = new DataSet();
try
{
string strExlConn = "provider=Microsoft.Jet.OLEDB.4.0;data source=" +
strFileName +
";Extended Properties = Excel 8.0";
OleDbConnection XlsConn = new OleDbConnection(strExlConn);
XlsConn.Open();
OleDbDataAdapter adpXls = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", XlsConn);
adpXls.Fill(dsXls, "[Sheet1$]");
XlsConn.Close();
Session["XlsData"] = dsXls; // 把数据集对象保存到Session中
}
catch (Exception ex)
{
MessageBox.Show(this, "文件打开错误.");
return;
}
txtHeader1.Visible = false;
txtHeader2.Visible = false;
txtHeader3.Visible = false;
txtHeader4.Visible = false;
txtHeader5.Visible = false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -