protected void BTN_Search(object sender, DirectEventArgs e) { DataSet ds = DIMERCO.SDK.Utilities.LSDK.getUserDataBYStationCodeNUser(TXTStation.Text.ToString(), TXTUserID.Text.Trim(), TXTUserName.Text.Trim()); //SqlConnection cn = new SqlConnection("Data Source=10.130.40.20;Initial Catalog=ReSM;User ID=sa;Password=dim1rc0@"); //string sql = "select UserID,fullname from SMUser inner join SMstation on SMUser.stationid=SMstation.stationid where StationCode='" + TXTStation.Text + "'"; //if(TXTUserID.Text.Trim()!="") //{ //sql=sql+" and UserID='"+TXTUserID.Text.Trim()+"'"; //} //if(TXTUserName.Text.Trim()!="") //{ // sql = sql + " and fullname like '%" + TXTUserName.Text.Trim() + "%'"; //} //SqlDataAdapter da = new SqlDataAdapter(sql, cn); //DataSet ds = new DataSet(); //da.Fill(ds); DataTable tb = ds.Tables[0]; SVUser.DataSource = tb; SVUser.DataBind(); ds.Dispose(); }
protected void BTN_Search(object sender, DirectEventArgs e) { if (DLStation.Value == null) { X.Msg.Show(new MessageBoxConfig { Title = "Message", Message = "Please select station", Buttons = MessageBox.Button.OK, Width = 320, Icon = MessageBox.Icon.INFO }); } else { DataSet ds = DIMERCO.SDK.Utilities.LSDK.getUserDataBYStationCodeNUser(DLStation.Value.ToString().ToString(), TXTUserID.Text.Trim(), TXTUserName.Text.Trim()); // SqlConnection cn = new SqlConnection("Data Source=10.130.40.20;Initial Catalog=ReSM;User ID=sa;Password=dim1rc0@"); //string sql="select UserID,fullname from SMUser inner join SMstation on SMUser.stationid=SMstation.stationid where StationCode='"+DLStation.Value+"'"; // if(TXTUserID.Text.Trim()!="") // { // sql=sql+" and UserID='"+TXTUserID.Text.Trim()+"'"; // } // if(TXTUserName.Text.Trim()!="") // { // sql = sql + " and fullname like '%" + TXTUserName.Text.Trim() + "%'"; // } // SqlDataAdapter da = new SqlDataAdapter(sql, cn); // DataSet ds = new DataSet(); // da.Fill(ds); DataTable tb = ds.Tables[0]; DataSet dss = dbs.GetSqlDataSet("select UserID,UserName,Stations,ModuleID from StationRole where station='" + DLStation.Value + "'"); DataTable tb1 = dss.Tables[0]; DataTable ttb = new DataTable(); ttb.Columns.Add("UserID"); ttb.Columns.Add("FullName"); ttb.Columns.Add("station"); ttb.Columns.Add("ModuleName"); foreach (DataRow dr in tb.Rows) { DataRow[] drn = tb1.Select("UserID='" + dr["UserID"].ToString() + "'"); if (drn.Length > 0) { DataRow newDr = ttb.NewRow(); newDr["UserID"] = drn[0]["UserID"]; newDr["FullName"] = drn[0]["UserName"]; newDr["station"] = drn[0]["Stations"]; newDr["ModuleName"] = GetModuleName(drn[0]["ModuleID"].ToString()); ttb.Rows.Add(newDr); } else { DataRow newDr = ttb.NewRow(); newDr["UserID"] = dr["UserID"]; newDr["FullName"] = dr["fullname"]; newDr["station"] = ""; newDr["ModuleName"] = ""; ttb.Rows.Add(newDr); } } if (Session["TSQL"] != null && DLStation.Value == null) { ttb = (DataTable)Session["TSQL"]; } SVUser.DataSource = ttb; SVUser.DataBind(); Session["TSQL"] = ttb; ds.Dispose(); } }