62,046
社区成员
发帖
与我相关
我的任务
分享
SqlConnection con = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["AMDConnectionString"].ToString());
con.Open();
String SQL;
SqlCommand cmd;
SqlDataReader rd;
//公司选项
if (CompanyCode.Items.Count == 0)
{
CompanyCode.Items.Clear();
SQL = "SELECT OrgCode + ' - ' + SaleOrg AS AA, OrgCode FROM SORG ORDER BY OrgCode";
cmd = new SqlCommand(SQL, con);
rd = cmd.ExecuteReader();
while (rd.Read())
{
ListItem Item = new ListItem();
Item.Text = rd["AA"].ToString();
Item.Value = rd["OrgCode"].ToString();
CompanyCode.Items.Add(Item);
}
rd.Close();
}
con.Close();
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
/// <summary>
/// CommonClass 的摘要说明
/// 用于页面基本功能函数
/// </summary>
public class CommonClass
{
public CommonClass()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public void ListSQL(String S, DropDownList D)
{
SqlConnection con = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["AMDConnectionString"].ToString());
con.Open();
String SQL;
SqlCommand cmd;
SqlDataReader rd;
D.Items.Clear();
SQL = S;
cmd = new SqlCommand(SQL, con);
rd = cmd.ExecuteReader();
while (rd.Read())
{
ListItem Item = new ListItem();
Item.Text = rd[0].ToString();
if (rd.FieldCount >= 2) {
Item.Value = rd[1].ToString();
} else
{
Item.Value = rd[0].ToString();
}
D.Items.Add(Item);
}
rd.Close();
con.Close();
}
}
public partial class assetedit : System.Web.UI.Page
{
CommonClass CC = new CommonClass();
protected void Page_Load(object sender, EventArgs e)
{
CC.ListSQL("SELECT DISTINCT Code + ' - ' + Factory AS FactoryName, Code FROM FCTR WHERE Entity='" + Entity + "' ORDER BY Code", Factory);
}