textcombo is not defined as cboApps.Text.
if it were then yes, but that is the problem for some reason
I can't get it to recognize what cboApps.Text is
when i typed in:
Form1 textcombo = new Form1(cboApps.Text);
textcombo.show();
It had no idea what cboApps.text is.
HERE IS CODE FROM BOTH FORMS:
--------------------FORM1 Includes cboApps------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Collections.Specialized;
using System.Configuration;
using System.Data;
namespace ServiceLevelAgreement
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
public System.Windows.Forms.ComboBox cboApps;
private SLAFunctions sla;
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.Button button1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.cboApps = new System.Windows.Forms.ComboBox();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// cboApps
//
this.cboApps.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboApps.Location = new System.Drawing.Point(48, 32);
this.cboApps.Name = "cboApps";
this.cboApps.Size = new System.Drawing.Size(184, 21);
this.cboApps.TabIndex = 0;
this.cboApps.SelectedIndexChanged += new System.EventHandler(this.cboApps_SelectedIndexChanged);
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(280, 16);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(312, 328);
this.dataGrid1.TabIndex = 1;
//
// button1
//
this.button1.Location = new System.Drawing.Point(160, 64);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(608, 373);
this.Controls.Add(this.button1);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.cboApps);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
NameValueCollection nvcApplications = (NameValueCollection) ConfigurationSettings.GetConfig("SLAApplications/Applications");
for (int i=0;i<nvcApplications.Count;i++)
{
cboApps.Items.Add(nvcApplications.Keys);
}
sla = new SLAFunctions();
}
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("This May Take A Few Moments. Thank You.");
DataSet lstDataSet = new DataSet();
sla.HRDataSet(lstDataSet, cboApps.Text);
dataGrid1.DataSource = lstDataSet.Tables[0];
}
private void cboApps_SelectedIndexChanged(object sender, System.EventArgs e)
{
return;{}
}
}
}
-------------------------SLAFunctions.cs--------------------
using System;
using PinnacleWest.CommonBaseServices.APSDSA;
using System.DirectoryServices;
using System.Collections;
using System.Data.SqlClient;
using System.Data;
namespace ServiceLevelAgreement
{
/// <summary>
/// Summary description for SLAFunctions.
/// </summary>
public class SLAFunctions
{
internal Hashtable h_Logins = new Hashtable();
public SLAFunctions()
{
}
internal string Init_DSAHR()
{
string s_Tranname = System.Configuration.ConfigurationSettings.AppSettings["dsa_HRData"] ;
string sDatabase = System.Configuration.ConfigurationSettings.AppSettings["HRDATABASE"];
DSACheck od = new DSACheck();
od.DSA_tran_name = s_Tranname;
od.GetConnectInfo();
string s_Password = od.DSA_tran_ticket;//+ "123";;
string s_Username = od.DSA_tran_id;// + "123";
string sServer = od.DSA_server_name;
SqlConnection HRCONN = new SqlConnection();
return GetConnectionHR(s_Username,s_Password, sServer, sDatabase);
}
internal string GetConnectionHR(string sUser, string sPass, string sServer, string sDatabase)
{
return "Server=" + sServer + ";database=" + sDatabase + ";User ID=" +
sUser + ";Password=" + sPass + ";";
}
public void HRDataSet(DataSet ds, string sGroup)
{
h_Logins.Clear();
LoadAppMembers(sGroup);
SqlConnection conn = new SqlConnection(Init_DSAHR());
conn.Open();
ds.Tables.Add();
ds.Tables[0].Columns.Add("Application",System.Type.GetType("System.String"));
ds.Tables[0].Columns.Add("Last Name",System.Type.GetType("System.String"));
ds.Tables[0].Columns.Add("First Name", System.Type.GetType("System.String"));
ds.Tables[0].Columns.Add("User ID", System.Type.GetType("System.String"));
ds.Tables[0].Columns.Add("Financial Unit", System.Type.GetType("System.String"));
ds.Tables[0].Columns.Add("Manager ID", System.Type.GetType("System.String"));
ds.Tables[0].Columns.Add("Line Of Business", System.Type.GetType("System.String"));
ds.Tables[0].Columns.Add("Employee Status", System.Type.GetType("System.String"));
string sSQL = "SELECT textcombo, last_name, first_name, fin_unit_no, rpt_to_user_id, line_of_business, emp_status from nonsensitive_hr_general_use WHERE user_id = @userid";
SqlCommand cmd = new SqlCommand(sSQL, conn);
cmd.CommandType = CommandType.Text;
SqlParameter param = new SqlParameter("@userid", SqlDbType.VarChar, 6, "user_id");
cmd.Parameters.Add(param);
// SqlDataAdapter da = new SqlDataAdapter(cmd);
foreach (DictionaryEntry myDE in h_Logins)
{
SqlDataReader rdr = null;
cmd.Parameters["@userid"].Value = myDE.Value;
try
{
rdr = cmd.ExecuteReader();
}
catch (Exception ex)
{
int icount = 5;
}
while (rdr.Read())
{
DataRowCollection drc = ds.Tables[0].Rows;
DataRow dr;
object[] mynewrow = new object[7];
mynewrow[0] = rdr["last_name"].ToString();
mynewrow[1] = rdr["first_name"].ToString();
mynewrow[2] = myDE.Value;
mynewrow[3] = rdr["fin_unit_no"].ToString();
mynewrow[4] = rdr["rpt_to_user_id"].ToString();
mynewrow[5] = rdr["line_of_business"].ToString();
mynewrow[6] = rdr["emp_status"].ToString();
dr = drc.Add(mynewrow);
}
rdr.Close();
}
}
private void LoadAppMembers(string sGroup)
{
ActiveDs.IADsMembers MembersCollection = null;
DirectoryEntry groupEntry = new DirectoryEntry("LDAP://cn=" + sGroup + ",cn=Users,dc=apsc,dc=com");
System.DirectoryServices.PropertyCollection pcoll = groupEntry.Properties;
MembersCollection = groupEntry.Invoke("Members") as ActiveDs.IADsMembers;
object[] filter = {"user"};
foreach (ActiveDs.IADsUser member in MembersCollection)
{
if (member.FullName.IndexOf("(") != -1)
{
string userid = member.FullName.Substring(member.FullName.IndexOf("("));
userid = userid.Substring(1, userid.Length - 2);
if (userid.Length == 7) userid = userid.Substring(0, userid.Length-1);
h_Logins.Add(userid, userid);
}
}
return;
}
}
}
I Removed Everything Reccommended To Have A Clean Start...