Exemple #1
0
        private void RefreshForm(EDataGridType type)
        {
            switch (type)
            {
            case EDataGridType.Clients:
            {
                clientBindingSource.DataSource = null;
                clientBindingSource.DataSource = SerwisContext.GetContext().Clients.ToList();
                break;
            }

            case EDataGridType.Devices:
            {
                deviceBindingSource.DataSource = null;
                deviceBindingSource.DataSource = SerwisContext.GetContext().Devices.ToList();
                break;
            }

            case EDataGridType.Repairs:
            {
                repairBindingSource.DataSource = null;
                repairBindingSource.DataSource = SerwisContext.GetContext().Repairs.ToList();
                break;
            }
            }
        }
        public DeviceHistoryForm(int deviceId)
        {
            InitializeComponent();

            var repairsHistory = SerwisContext.GetContext().Repairs.Where(x => x.Device.DeviceId == deviceId).ToList();

            repairBindingSource.DataSource = repairsHistory;
        }
        public ClientHistoryForm(int clientId)
        {
            InitializeComponent();

            var repairsHistory = SerwisContext.GetContext().Repairs.Where(x => x.Client.ClientId == clientId).ToList();

            repairBindingSource.DataSource = repairsHistory;
        }
 private void DeviceHistoryForm_HistoryDataGrid_SelectionChanged(object sender, System.EventArgs e)
 {
     if (DeviceHistoryForm_HistoryDataGrid.SelectedRows.Count > 0)
     {
         int    selectedRepairId = (int)DeviceHistoryForm_HistoryDataGrid.SelectedRows[0].Cells[0].Value;
         Repair selectedRepair   = SerwisContext.GetContext().Repairs.FirstOrDefault(x => x.RepairId == selectedRepairId);
         repairPositionBindingSource.DataSource   = selectedRepair.RepairPositions;
         DeviceHistoryForm_ClientIdNameLabel.Text = selectedRepair.Client.ClientId.ToString() + " | " + selectedRepair.Client.Name;
     }
 }
Exemple #5
0
 private void AddRepairForm_PositionsPanel_DeleteButton_Click(object sender, EventArgs e)
 {
     if (RepairAddEditForm_PositionsDataGrid.SelectedRows.Count > 0)
     {
         var position = RepairAddEditForm_PositionsDataGrid.SelectedRows[0].DataBoundItem as RepairPosition;
         SerwisContext.GetContext().RepairPosition.Remove(position);
         RefreshPositionsGridData();
         SerwisContext.GetContext().SaveChanges();
     }
     else
     {
         MessageBox.Show(Messages.RepairAddEditForm_NoPosition);
     }
 }
Exemple #6
0
        private void SaveChanges()
        {
            if (RepairAddEditForm_ClientDataGrid.Rows.Count > 0)
            {
                if (RepairAddEditForm_DevicesDataGrid.Rows.Count > 0)
                {
                    int income = 0;

                    foreach (DataGridViewRow row in RepairAddEditForm_PositionsDataGrid.Rows)
                    {
                        income = income + (int)row.Cells[4].Value;
                    }

                    int    clientId = (int)RepairAddEditForm_ClientDataGrid.SelectedRows[0].Cells[0].Value;
                    Client client   = SerwisContext.GetContext().Clients.FirstOrDefault(x => x.ClientId == clientId);

                    int    deviceId = (int)RepairAddEditForm_DevicesDataGrid.SelectedRows[0].Cells[0].Value;
                    Device device   = SerwisContext.GetContext().Devices.FirstOrDefault(x => x.DeviceId == deviceId);

                    if (_formMode == EFormMode.Add)
                    {
                        _repair.Device    = device;
                        _repair.Client    = client;
                        _repair.Income    = income;
                        _repair.StartDate = DateTime.Now;

                        _repairsManagement.AddRepair(_repair);
                    }
                    else
                    {
                        _repair.Device = device;
                        _repair.Client = client;
                        SerwisContext.GetContext().SaveChanges();
                    }

                    Close();
                }
                else
                {
                    MessageBox.Show(Messages.RepairAddEditForm_NoDevice);
                }
            }
            else
            {
                MessageBox.Show(Messages.RepairAddEditForm_NoClient);
            }
        }
Exemple #7
0
        private void MainForm_RepairsTab_DataGrid_SelectionChanged(object sender, EventArgs e)
        {
            if (focus == true)
            {
                if (MainForm_RepairsTab_DataGrid.SelectedRows.Count > 0)
                {
                    if (MainForm_RepairsTab_DataGrid.SelectedRows[0] != null)
                    {
                        int selectedRepairId = (int)MainForm_RepairsTab_DataGrid.SelectedRows[0].Cells[0].Value;

                        Repair selectedRepair = SerwisContext.GetContext().Repairs.FirstOrDefault(x => x.RepairId == selectedRepairId);
                        repairPositionBindingSource.DataSource     = selectedRepair.RepairPositions;
                        MainForm_RepairsTab_DeviceIdNameLabel.Text = selectedRepair.Device.DeviceId.ToString() + " | " + selectedRepair.Device.Name;
                        MainForm_RepairsTab_ClientIdNameLabel.Text = selectedRepair.Client.ClientId.ToString() + " | " + selectedRepair.Client.Name;
                    }
                }
            }
        }
Exemple #8
0
        public MainForm()
        {
            InitializeComponent();

            MessageBoxManager.Yes = Messages.Yes;
            MessageBoxManager.No  = Messages.No;
            MessageBoxManager.Register();

            _client = ClientsManagement.GetInstance();
            _device = DevicesManagement.GetInstance();
            _repair = RepairsManagement.GetInstance();

            clientBindingSource.DataSource = SerwisContext.GetContext().Clients.ToList();

            deviceBindingSource.DataSource = SerwisContext.GetContext().Devices.ToList();

            repairBindingSource.DataSource = SerwisContext.GetContext().Repairs.ToList();
        }
Exemple #9
0
        public RepairAddEditForm(Repair repair)
        {
            InitializeComponent();
            _repair = repair ?? new Repair();

            _repairPosition    = RepairPositionsManagement.GetInstance();
            _repairsManagement = RepairsManagement.GetInstance();

            SerwisContext.GetContext().Clients.Load();
            clientBindingSource.DataSource = SerwisContext.GetContext().Clients.ToList();

            SerwisContext.GetContext().Devices.Load();
            deviceBindingSource.DataSource = SerwisContext.GetContext().Devices.ToList();


            if (repair != null)
            {
                _formMode = EFormMode.Edit;
                Text      = Messages.RepairAddEditForm_EditFormText;
                RefreshPositionsGridData();
            }
        }