private void ShowCartridgeInformation(string code) { CartridgeInfo cartridgeInfo = DatabaseHelper.GetCartridgeInfo(code); if (cartridgeInfo == null) { GuiController.CreateMessage("Картридж с таким номером не найден", true); return; } ModelBox.Text = cartridgeInfo.ModelName; LocationBox.Text = cartridgeInfo.Location; InitiatorBox.Text = cartridgeInfo.InitiatorLastName; DataBox.Text = cartridgeInfo.TransferDate.ToString("dd.MM.yyyy"); StateBox.Text = cartridgeInfo.State; List <ListViewItem> items = new List <ListViewItem>(); foreach (ServiceOperation operation in cartridgeInfo.Operations) { ListViewItem item = new ListViewItem(operation.OperationDate.ToString("dd.MM.yyyy")); item.SubItems.Add(operation.OperationType); item.SubItems.Add(operation.PartName); item.SubItems.Add(operation.PartsCount.ToString()); item.SubItems.Add(operation.WorkerLastName); item.SubItems.Add(operation.Comment); items.Add(item); } OpertionsBox.Items.AddRange(items.ToArray()); }
public UserSelect() { try { InitializeComponent(); GuiController.IsMainActionsAllowed = false; CloseTabButton.Barcode = CloseTabButton.RegisterControl((c) => this.NavigateToMainPage()); GuiController.ControlCallback SessionCallback = delegate(string code) { string workerName = GuiController.GetAssociatedControl(code).GetCustomData <string>(); if (SessionManager.CreateNewSession(workerName)) { GuiController.CreateMessage("Смена открыта под пользователем " + workerName, false); } else { GuiController.CreateMessage("Не удалось открыть смену. Проверьте конфигурационный файл", true); } this.NavigateToMainPage(); }; List <LinearButton> buttons = new List <LinearButton>(); int index = 0; foreach (string user in AppHelper.Configuration.Users) { LinearButton button = new LinearButton(); button.ButtonText = user; button.ButtonBackColor = Color.DimGray; button.Image = Properties.Resources.sad_64; button.Barcode = button.RegisterControl(SessionCallback); button.Anchor = AnchorStyles.Left | AnchorStyles.Top; button.Height = ContentHeight; button.Width = ContentWidth; button.TabIndex = index; button.Margin = new Padding(ContentMargins, ContentMargins, 0, 0); button.SetCustomData(user); buttons.Add(button); index++; } ContentLayoutPanel.Controls.AddRange(buttons.ToArray()); } catch (Exception ex) { GuiController.IsMainActionsAllowed = true; MessageBox.Show(ex.ToString(), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public MainControl() { InitializeComponent(); // Открытие смены NewSessionButton.Barcode = NewSessionButton.RegisterControl(((long)ActionsHelper.MainActions.NewSession), delegate(string code) { if (SessionManager.IsSessionCreated) { GuiController.CreateMessage("Смена уже открыта под пользователем " + SessionManager.WorkerName, true); return; } else { UserSelect userSelect = new UserSelect(); userSelect.ShowThisPage(); } }); ServiceButton.Barcode = ServiceButton.RegisterControl(((long)ActionsHelper.MainActions.ServiceCartridge), delegate(string code) { if (SessionManager.IsSessionCreated) { ServiceCartridge serviceCartridge = new ServiceCartridge(); serviceCartridge.ShowThisPage(); } else { GuiController.CreateMessage("Смена не открыта", true); } }); AddNewCartridgeButton.Barcode = AddNewCartridgeButton.RegisterControl(((long)ActionsHelper.MainActions.AddNewCartridge), delegate(string code) { if (SessionManager.IsSessionCreated) { AddNewCartridge addNewCartridge = new AddNewCartridge(); addNewCartridge.ShowThisPage(); } else { GuiController.CreateMessage("Смена не открыта", true); } }); ViewInfoButton.Barcode = ViewInfoButton.RegisterControl(((long)ActionsHelper.MainActions.CartridgeInfo), delegate(string code) { ShowCartridgeInfo showCartridgeInfo = new ShowCartridgeInfo(); showCartridgeInfo.ShowThisPage(); }); ViewCartridgesButton.Barcode = ((long)ActionsHelper.MainActions.PostOfficeInfo).ToString(); ViewCartridgesButton.ButtonClick += delegate(ICodeButton s, EventArgs e) { // Просмотр картриджей отделения здесь }; // Закрытие смены CloseSessionButton.Barcode = CloseSessionButton.RegisterControl(((long)ActionsHelper.MainActions.CloseSession), delegate(string code) { if (SessionManager.IsSessionCreated) { SessionManager.CloseSession(); GuiController.CreateMessage("Закрытие смены выполнено", false); } else { GuiController.CreateMessage("Смена не открыта", true); } }); // Переключение полноэкранного режима FullScreenButton.Barcode = FullScreenButton.RegisterControl(((long)ActionsHelper.MainActions.FullScreen), (c) => GuiController.MainForm.SwitchFullScreenMode()); // Выход из программы ExitButton.Barcode = ExitButton.RegisterControl(((long)ActionsHelper.MainActions.ExitApplication), (c) => GuiController.ExitApplication()); }