private void Form1_Load(object sender, EventArgs e) { BuildOrgStructureTree(); //ADMethodsAccountManagement ADMethods = new ADMethodsAccountManagement(); //UserPrincipal myUser = ADMethods.GetUser(@"druzhinin"); //MessageBox.Show(myUser.GivenName + " " + myUser.EmailAddress); m_TableAdapterManager = new TableAdapterManager(); m_TableAdapterManager.StaffTableAdapter = new StaffTableAdapter(); m_TableAdapterManager.stfOrgStructureTableAdapter = new stfOrgStructureTableAdapter(); m_TableAdapterManager.NewUserTableAdapter = new NewUserTableAdapter(); m_CommonQuery = new QueriesTableAdapter(); m_StaffTbl = new dsITO.StaffDataTable(); m_NewUser = new dsITO.NewUserDataTable(); m_TableAdapterManager.NewUserTableAdapter.Fill(m_NewUser); m_OrgStructure = new dsITO.stfOrgStructureDataTable(); m_TableAdapterManager.StaffTableAdapter.Fill(m_StaffTbl); m_ITOSQLCommand = new ITODAL(); m_ITOSQLCommand.OpenConnection("Data Source=10.15.140.2;Initial Catalog=ITO;Persist Security Info=True;User ID=evgeny;Password=ywfaggzu"); //Заполняем ComboBox данными из базы //Должности DataTable dt = m_ITOSQLCommand.ExecuteSQLCommand("Select PositionID, Name from stfPositions"); for (int curRow = 0; curRow < dt.Rows.Count; curRow++) { ListElement le = new ListElement(dt.Rows[curRow][0].ToString(), dt.Rows[curRow][1].ToString()); cbPosition.Items.Add(le); } //Подразделения dt = m_ITOSQLCommand.ExecuteSQLCommand("Select DepartmentID, ShortName, Name from stfOrgStructure"); for (int curRow = 0; curRow < dt.Rows.Count; curRow++) { ListElement le = new ListElement(dt.Rows[curRow][0].ToString(), dt.Rows[curRow][1].ToString() + " " + dt.Rows[curRow][2].ToString()); cbDepartment.Items.Add(le); } //Здания dt = m_ITOSQLCommand.ExecuteSQLCommand("Select BuildingID, Name from stfBuildings"); for (int curRow = 0; curRow < dt.Rows.Count; curRow++) { ListElement le = new ListElement(dt.Rows[curRow][0].ToString(), dt.Rows[curRow][1].ToString()); cbWorkPlace.Items.Add(le); } dt = m_ITOSQLCommand.ExecuteSQLCommand("Select UserID,LastName,Name,SecondName from Staff"); for (int curRow = 0; curRow < dt.Rows.Count; curRow++) { ListElement le = new ListElement(dt.Rows[curRow][0].ToString(), dt.Rows[curRow][1].ToString()+" "+dt.Rows[curRow][2].ToString()+" "+dt.Rows[curRow][3].ToString()); cmbUser.Items.Add(le); } dt = m_ITOSQLCommand.ExecuteSQLCommand("Select distinct Place from Invent"); for (int curRow = 0; curRow < dt.Rows.Count; curRow++) { cbPlace.Items.Add(dt.Rows[curRow][0].ToString()); } dt = m_ITOSQLCommand.ExecuteSQLCommand("Select distinct Room from Invent"); for (int curRow = 0; curRow < dt.Rows.Count; curRow++) { cbRoom.Items.Add(dt.Rows[curRow][0].ToString()); } }
public ChangeUserForm() { InitializeComponent(); /* m_TableAdapterManager = new TableAdapterManager(); m_TableAdapterManager.StaffTableAdapter = new StaffTableAdapter(); m_TableAdapterManager.stfOrgStructureTableAdapter = new stfOrgStructureTableAdapter(); m_TableAdapterManager.NewUserTableAdapter = new NewUserTableAdapter(); m_StaffTbl = new dsITO.StaffDataTable(); m_NewUser = new dsITO.NewUserDataTable(); m_TableAdapterManager.NewUserTableAdapter.Fill(m_NewUser); m_OrgStructure = new dsITO.stfOrgStructureDataTable(); m_TableAdapterManager.StaffTableAdapter.Fill(m_StaffTbl);*/ m_ITOSQLCommand = new ITODAL(); m_ADcon = new ADMethodsAccountManagement(); m_ITOSQLCommand.OpenConnection("Data Source=10.15.140.2;Initial Catalog=ITO;Persist Security Info=True;User ID=evgeny;Password=ywfaggzu"); //Заполняем ComboBox данными из базы //Должности DataTable dt = m_ITOSQLCommand.ExecuteSQLCommand("Select PositionID, Name from stfPositions"); for (int curRow = 0; curRow < dt.Rows.Count; curRow++) { ListElement le = new ListElement(dt.Rows[curRow][0].ToString(),dt.Rows[curRow][1].ToString()); cbPosition.Items.Add(le); } //Подразделения dt = m_ITOSQLCommand.ExecuteSQLCommand("Select ShortName, Name, DepartmentID from stfOrgStructure"); for (int curRow = 0; curRow < dt.Rows.Count; curRow++) { ListElement le = new ListElement(dt.Rows[curRow][2].ToString(), dt.Rows[curRow][0].ToString() + " " + dt.Rows[curRow][1].ToString()); cbDepartment.Items.Add(le); } //Здания dt = m_ITOSQLCommand.ExecuteSQLCommand("Select BuildingID, Name from stfBuildings"); for (int curRow = 0; curRow < dt.Rows.Count; curRow++) { ListElement le = new ListElement(dt.Rows[curRow][0].ToString(), dt.Rows[curRow][1].ToString()); cbWorkPlace.Items.Add(le); } //Типы Телефонов foreach ( Enum value in Enum.GetValues(typeof(ePhoneTypes))) { ListElement le = new ListElement(Convert.ToString((int)(ePhoneTypes)value), ITO_StringConverter.PhoneTypeToStr((ePhoneTypes)value)); cbPhoneType.Items.Add(le); } }