private void initCode() { //初始化下拉列表 string sql = "select distinct a.pline_code,b.pline_name from vw_user_role_program a left join code_product_line b on a.pline_code=b.pline_code where a.user_id='" + theUserId + "' and a.program_code='" + theProgramCode + "' and a.company_code='" + theCompanyCode + "'"; SqlCode.SelectCommand = sql; SqlCode.DataBind(); SqlCode1.SelectCommand = sql; SqlCode1.DataBind(); SqlCode2.SelectCommand = sql; SqlCode2.DataBind(); //txtPCode.SelectedIndex = txtPCode.Items.Count >= 0 ? 0 : -1; //txtPCode1.SelectedIndex = txtPCode.Items.Count >= 0 ? 0 : -1; //txtPCode2.SelectedIndex = txtPCode.Items.Count >= 0 ? 0 : -1; string Sql2 = " select pt_part from copy_pt_mstr order by pt_part"; SqlICode.SelectCommand = Sql2; SqlICode.DataBind(); string Sql3 = "select DETECT_NAME from code_detect where pline_code in ( SELECT PLINE_ID FROM VW_USER_ROLE_PROGRAM WHERE USER_ID='" + theUserId + "' and program_code='" + theProgramCode + "' and company_code='" + theCompanyCode + "') "; DataTable dt3 = dc.GetTable(Sql3); ASPxListBoxUnused.DataSource = dt3; ASPxListBoxUnused.DataBind(); }
//初始化生产线 private void initPlineCode() { string sql = "select distinct a.pline_code,b.pline_name from vw_user_role_program a left join code_product_line b on a.pline_code=b.pline_code where a.user_id='" + theUserId + "' and a.program_code='" + theProgramCode + "' and a.company_code='" + theCompanyCode + "'"; SqlCode.SelectCommand = sql; SqlCode.DataBind(); SqlCode1.SelectCommand = sql; SqlCode1.DataBind(); //对调序有影响,先不设默认值 //txtPCode.SelectedIndex = txtPCode.Items.Count >= 0 ? 0 : -1; }
private void initCode() { //初始化生产线下拉列表 string sql = "select distinct a.pline_code,b.pline_name from vw_user_role_program a left join code_product_line b on a.pline_code=b.pline_code where a.user_id='" + theUserId + "' and a.program_code='" + theProgramCode + "' and a.company_code='" + theCompanyCode + "'" + " and (A.pline_code='E' OR A.PLINE_CODE='W')"; SqlCode1.SelectCommand = sql; SqlCode1.DataBind(); SqlCode2.SelectCommand = sql; SqlCode2.DataBind(); SqlCode3.SelectCommand = sql; SqlCode3.DataBind(); SqlCode4.SelectCommand = sql; SqlCode4.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { theProgramCode = "rept3200"; userManager theUserManager = (userManager)Session["theUserManager"]; theCompanyCode = theUserManager.getCompanyCode(); theUserId = theUserManager.getUserId(); string sql = "select distinct a.pline_code,b.pline_name from vw_user_role_program a left join code_product_line b on a.pline_code=b.pline_code where a.user_id='" + theUserId + "' and a.program_code='" + theProgramCode + "' and a.company_code='" + theCompanyCode + "'"; SqlCode.SelectCommand = sql; SqlCode.DataBind(); SqlCode1.SelectCommand = sql; SqlCode1.DataBind(); if (!IsPostBack) { //第一次进入页面默认取东区 txtPCode.SelectedIndex = 0; //第一次进入页面取不到生产线,用这种方式给ASPxGridView1增加数据 //string plineSql = "select distinct a.pline_code,b.pline_name from vw_user_role_program a " //+ " left join code_product_line b on a.pline_code=b.pline_code where a.user_id='" //+ theUserId + "' and a.program_code='" + theProgramCode + "' and a.company_code='" + theCompanyCode + "'"; //DataTable dt1 = dc.GetTable(plineSql); ////注意此处用rows才能取到,用columns取不到 //string pline = dt1.Rows[0]["PLINE_CODE"].ToString(); //string inSqlTemp = ""; //inSqlTemp = " SELECT DISTINCT SN FROM DATA_STORE WHERE PLINE_CODE = '" + pline + "' "; //DataTable dt = dc.GetTable(inSqlTemp); //ASPxGridView1.DataSource = dt; //ASPxGridView1.DataBind(); } //initPlineCode(); //放在pageload里,模糊查询,分页等功能才能正常使用,因为这些事件都会来后台处理数据,所以要查询的相关数据必须要放在pageload里,否则 //无法实现正常功能 setCondition1(); setCondition(); }