public override void DoInit()
 {
     if (!string.IsNullOrEmpty(_conn_str))
     {
         sqlmgr = new MSSQL_Manager();
         sqlmgr.Connect(_conn_str);
         sqlmgr.Disconnect();
     }
 }
        public override void DoInit()
        {
            if (!string.IsNullOrEmpty(_conn_str))
            {
                sqlmgr = new MSSQL_Manager();
                sqlmgr.Connect(_conn_str);
                _streets = sqlmgr.GetStreets();
                _sotrudniki = sqlmgr.GetSotrudniki(false);
                _sotrudniki2 = sqlmgr.GetSotrudniki(false);
                _sotrudniki3 = sqlmgr.GetSotrudniki(true);
                //_pom_sotrudniki = sqlmgr.GetSotrudniki();
                _agents = sqlmgr.GetAgentsDict();
                _raions = sqlmgr.GetMicroraionsDict(false);
                _offices = sqlmgr.GetOfficesDict(false);
                _transport = sqlmgr.GetTransportDict(false);
                _linkcompanies = sqlmgr.GetLinkCompanyDict(false);
                //_shift_id = sqlmgr.GetShiftIdByUserId(_currentUser.Id);
                sqlmgr.Disconnect();
            }

            //--адрес
            (view_controls[0] as TextBox).KeyUp += AddressEd_KeyUp;
            var cbox = (view_controls[11] as ComboBox);
            cbox.DataSource = _streets;
            cbox.SelectionChangeCommitted += StreetCB_SelectedMouseClick;

            //--Родственники
            _lviews[0].ContextMenuStrip = RelativesCMS;
            _lviews[0].DataSource = Relatives_NullDataSource();
            _lviews[0].DoubleClick += RelativesLV_DoubleClick;

            _lviews[1].ContextMenuStrip = InformatorsCMS;
            view_controls[3].ContextMenuStrip = AgentsCMS;

            (view_controls[7] as ComboBox).DataSource = _sotrudniki;
            (view_controls[7] as ComboBox).DisplayMember = "Name";
            (view_controls[8] as ComboBox).DataSource = _sotrudniki2;
            (view_controls[8] as ComboBox).DisplayMember = "Name";
            (view_controls[12] as ComboBox).DataSource = _raions;
            (view_controls[12] as ComboBox).DisplayMember = "Name";
            (view_controls[13] as ComboBox).DataSource = _sotrudniki3;
            (view_controls[13] as ComboBox).DisplayMember = "Name";
            var offcb = (GetControlByName("OfficeCB", true) as ComboBox);
            if (offcb != null)
            {
                offcb.DataSource = _offices;
                offcb.DisplayMember = "Name";
            }
            var trans = GetControlByName("TransportCB", true) as ComboBox;
            if (trans != null)
            {
                trans.DataSource = _transport;
                trans.DisplayMember = "Name";
                trans.SelectedIndex = 0;
                trans.SelectedIndexChanged += TransportItemchanged;
                (GetControlByName("DocLinkerVisibilityCB", true) as CheckBox).Enabled = true;
            }
            var lcompcb = (GetControlByName("LinkCompanyCB", true) as ComboBox);
            if (lcompcb != null)
            {
                lcompcb.DataSource = _linkcompanies;
                lcompcb.DisplayMember = "Name";
            }
        }
 public void SetDBManager(BaseDbManager manager)
 {
     sqlmgr = (manager as MSSQL_Manager);
 }
Esempio n. 4
0
        public override void DoInit()
        {
            //_conn_str = anvlib.Base.BaseMSSQLManager.GetConnectionString("ankushin", "", "", "UBureau", true);
            sqlmgr = new MSSQL_Manager();
            sqlmgr.Connect(_conn_str);
            _currentUser = new UserInfo();
            _currentUser = sqlmgr.GetCurrentUserInfo();
            _shiftInfo = new ShiftsInformation();
            _shiftInfo.CurrentShiftId = sqlmgr.GetShiftIdByUserId(_currentUser.Id);
            _shiftInfo = sqlmgr.GetShiftsInformation(_shiftInfo.CurrentShiftId);
            _cdp.Value = _shiftInfo.CurrentShiftDate;
            _cdp.ValueChanged += _cdp_ValueChanged;
            sqlmgr.Disconnect();
            if (_currentUser.Id == -1)
            {
                MessageBox.Show("Отсутствуют права доступа к программе!", "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _is_application_exit = true;
                if (OnApplicationExit != null)
                    OnApplicationExit(this, new EventArgs());
            }

            if (_currentUser.Role != RoleType.Admin && _main_menu != null)
            {
                _main_menu.Items[1].Visible = false;
                _main_menu.Items[2].Visible = false;
            }

            if (_currentUser.Role != RoleType.Buhgalter && _main_menu != null)
            {
                //_main_menu.Items[1].Visible = true;
                _main_menu.Items[2].Visible = true;
            }

            if ((_currentUser.Role != RoleType.Dipetcher ||
                _currentUser.Role != RoleType.DipetcherHelper && _main_menu != null)
                && _currentUser.Role != RoleType.Admin)
            {
                _main_menu.Items[1].Visible = true;
                var dict = (_main_menu.Items[1] as ToolStripMenuItem);
                dict.DropDownItems[0].Visible = false;
                dict.DropDownItems[5].Visible = false;
                dict.DropDownItems[6].Visible = false;
            }

            if (_prevshiftb != null && _nextshiftb != null)
            {
                CheckShiftsButtons();

                _prevshiftb.Click += PrevShiftB_Click;
                _nextshiftb.Click += NextShiftB_Click;
            }

            if (_currentUser.Role != RoleType.Admin && _mainCMS != null)
                _mainCMS.Items[2].Visible = false;

            maintabletimer = new Timer();
            maintabletimer.Interval = 60000*3;
            maintabletimer.Tick += MainTableTimerElapsed;
            maintabletimer.Start();
            _isMainTableRefreshNeeded = true;
        }