///////////////////////////////////////////////////////////////////////////////
        // Methods for doing main class job                                          //
        ///////////////////////////////////////////////////////////////////////////////
        #region METHODS

        #region IDataGridViewEditingControlInterfaceImplementation

        /// <summary>
        /// Method called by the grid before the editing control is shown so it can adapt to the
        /// provided cell style.
        /// Changes the control's user interface (UI) to be consistent with the specified cell style.
        /// </summary>
        /// <param name="dataGridViewCellStyle">The <see cref="DataGridViewCellStyle"/> to use
        /// as the model for the UI.</param>
        public virtual void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
        {
            this.Font = dataGridViewCellStyle.Font;
            if (dataGridViewCellStyle.BackColor.A < 255)
            {
                // The NumericUpDown control does not support transparent back colors
                Color opaqueBackColor = Color.FromArgb(255, dataGridViewCellStyle.BackColor);
                this.BackColor = opaqueBackColor;
                this.dataGridView.EditingPanel.BackColor = opaqueBackColor;
            }
            else
            {
                this.BackColor = dataGridViewCellStyle.BackColor;
            }
            this.ForeColor = dataGridViewCellStyle.ForeColor;
            this.TextAlign = DataGridViewNumericUpDownCell.TranslateAlignment(dataGridViewCellStyle.Alignment);
        }
Пример #2
0
        private void BuildInputDataGrid()
        {
            double[] neuronWeights = _programLogic.ExaminedNeuron.Weights;
            int      colCount      = neuronWeights.Length + 1;

            for (int i = 0; i < colCount; i++)
            {
                uiInputData.Columns.Add("", "");
            }
            foreach (DataGridViewColumn col in uiInputData.Columns)
            {
                col.MinimumWidth = 60;
            }
            DataGridViewColumn firstColumn = uiInputData.Columns[0];

            firstColumn.ReadOnly = true;
            DataGridViewCellStyle firstColumnStyle = firstColumn.DefaultCellStyle;

            firstColumnStyle.BackColor = firstColumnStyle.SelectionBackColor =
                SystemColors.Control;
            firstColumnStyle.ForeColor = firstColumnStyle.SelectionForeColor =
                SystemColors.ControlText;
            uiInputData.Rows.Add(3);
            uiInputData.Rows[0].Cells[0].Value = "Input number (i)";
            uiInputData.Rows[1].Cells[0].Value = "Input weight (w(i))";
            uiInputData.Rows[2].Cells[0].Value = "Input signal (x(i))";
            uiInputData.Rows[0].ReadOnly       = true;
            uiInputData.Rows[1].ReadOnly       = true;
            for (int i = 0; i < neuronWeights.Length; i++)
            {
                uiInputData.Rows[0].Cells[i + 1].Value        = i + 1;
                uiInputData.Rows[1].Cells[i + 1].Value        = neuronWeights[i];
                uiInputData.Rows[1].Cells[i + 1].Style.Format = "+0.000;-0.000";
                DataGridViewNumericUpDownCell inputCell =
                    new DataGridViewNumericUpDownCell();
                inputCell.Minimum                = -10m;
                inputCell.Maximum                = 10m;
                inputCell.Increment              = 0.1m;
                inputCell.DecimalPlaces          = 1;
                inputCell.Value                  = 0.0m;
                inputCell.ReadOnly               = false;
                uiInputData.Rows[2].Cells[i + 1] = inputCell;
            }
        }
Пример #3
0
 private void calcButton_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in dataGridView.Rows)
     {
         row.Cells[_nameColumn.Name].Style.BackColor = Color.White;
         DataGridViewTextBoxCell gradeCell = (DataGridViewTextBoxCell)row.Cells[_gradeColumn.Name];
         try
         {
             Expression ex         = new Expression(algorithmBox.Text);
             decimal    maxScore   = 0;
             decimal    totalScore = 0;
             _taskColumns.ForEach(s =>
             {
                 DataGridViewNumericUpDownCell cell = (DataGridViewNumericUpDownCell)row.Cells[s.Name];
                 if (string.IsNullOrWhiteSpace((string)cell.FormattedValue))
                 {
                     return;
                 }
                 maxScore                 += cell.Maximum;
                 totalScore               += decimal.Parse((string)cell.FormattedValue);
                 ex.Parameters["score"]    = decimal.Parse((string)cell.FormattedValue);
                 ex.Parameters["maxScore"] = cell.Maximum;
                 cell.Style.BackColor      = GetColor((float)NCalcDoubleParser.Parse(ex.Evaluate()), 1);
             });
             ex.Parameters["score"]    = (double)totalScore;
             ex.Parameters["maxScore"] = (double)maxScore;
             double grade = 6 - (NCalcDoubleParser.Parse(ex.Evaluate()) * 5);
             gradeCell.Value = (grade.ToString(CultureInfo.InvariantCulture).Length > 13
                                   ? grade.ToString(CultureInfo.InvariantCulture).Remove(13)
                                   : grade.ToString(CultureInfo.InvariantCulture)) +
                               " " + TexGrade(grade);
             gradeCell.Style.BackColor = GetColor(grade - 1, 5);
         }
         catch (Exception)
         {
             gradeCell.Value = "";
         }
     }
     dataGridView.Sort(_nameColumn, ListSortDirection.Ascending);
 }
Пример #4
0
        private void PreencherMultiplo()
        {
            foreach (DataGridViewRow item in GridCarrinho.Rows)
            {
                for (int i = 0; i < item.Cells.Count; i++)
                {
                    var tipo = item.Cells[i].GetType().Name;
                    if (tipo == "DataGridViewNumericUpDownCell")
                    {
                        DataGridViewNumericUpDownCell ContactCombo = (DataGridViewNumericUpDownCell)item.Cells[i];

                        EmitirPedidoItemDto EmitirPeididoList = TabemitirPedidoList.Where(p => p.Id.ToString() == item.Cells["Iditem"].Value.ToString()).FirstOrDefault();

                        ContactCombo.Minimum = EmitirPeididoList.multiplo;

                        ContactCombo.Increment = EmitirPeididoList.multiplo;

                        ContactCombo.Value = EmitirPeididoList.QuantidadeDesejada;

                        ContactCombo.Maximum = 10000;
                        //Dese_Tonelagem
                        if (EmitirPeididoList.QuantidadeDesejada > decimal.Parse(item.Cells["Dese_Tonelagem"].Value.ToString()))
                        {
                            ContactCombo.Style.BackColor = Color.Aquamarine;
                        }
                        else if (EmitirPeididoList.QuantidadeDesejada < decimal.Parse(item.Cells["Dese_Tonelagem"].Value.ToString()))
                        {
                            ContactCombo.Style.BackColor = Color.OrangeRed;
                        }
                        else
                        {
                            ContactCombo.Style.BackColor = Color.White;
                        }
                    }
                }
            }
        }
Пример #5
0
        private void UpdateInformation()
        {
            //заполнение списка деталей, выбранных для перемещения
            if (_currentComponentsList == null || _currentComponentsList.Length == 0)
            {
                MessageBox.Show("Can't find selected details");
                return;
            }

            var personnel = GlobalObjects.CasEnvironment.NewLoader.GetObjectListAll <SpecialistDTO, Specialist>();

            comboBoxReleased.Items.Clear();
            comboBoxReleased.Items.AddRange(personnel.ToArray());

            comboBoxRecived.Items.Clear();
            comboBoxRecived.Items.AddRange(personnel.ToArray());

            comboBoxReason.Items.Clear();
            comboBoxReason.Items.AddRange(InitialReason.Items.ToArray());
            dataGridViewComponents.Rows.Clear();

            comboBoxSupplier.Items.Clear();
            comboBoxSupplier.Items.AddRange(GlobalObjects.CasEnvironment.NewLoader.GetObjectListAll <SupplierDTO, Supplier>().ToArray());
            comboBoxSupplier.SelectedIndex = 0;
            comboBoxSupplier.Enabled       = false;

            comboBoxStaff.Items.Clear();
            comboBoxStaff.Items.AddRange(personnel.ToArray());
            comboBoxStaff.SelectedIndex = 0;
            comboBoxStaff.Enabled       = false;

            ReceiptDatedateTimePicker.Enabled = false;
            ReceiptDatedateTimePicker.Value   = DateTime.Today;
            NotifylifelengthViewer.Enabled    = false;

            foreach (Component detail in _currentComponentsList)
            {
                var row = new DataGridViewRow {
                    Tag = detail
                };

                double replacedValue;
                if (_currentStore != null && _currentWorkPackage != null)
                {
                    replacedValue = detail.NeedWpQuantity;
                }
                else
                {
                    replacedValue = detail.Quantity <= 1 ? 1 : detail.Quantity;
                }

                DataGridViewCell compntCell = new DataGridViewCheckBoxCell {
                    Value = false
                };
                DataGridViewCell descCell = new DataGridViewTextBoxCell {
                    Value = detail.ToString()
                };
                DataGridViewCell all = new DataGridViewNumericUpDownCell
                {
                    Minimum       = ColumnAll.Minimum,
                    Maximum       = (decimal)(detail.Quantity <= 1 ? 1 : detail.Quantity),
                    Value         = detail.Quantity <= 1 ? 1 : detail.Quantity,
                    DecimalPlaces = 2
                };
                DataGridViewCell replace = new DataGridViewNumericUpDownCell
                {
                    Minimum       = ColumnReplace.Minimum,
                    Maximum       = (decimal)(detail.Quantity <= 1 ? 1 : detail.Quantity),
                    Value         = replacedValue,
                    DecimalPlaces = 2
                };

                row.Cells.AddRange(compntCell, descCell, all, replace);

                descCell.ReadOnly = true;
                all.ReadOnly      = true;
                replace.ReadOnly  = detail.Quantity <= 1;

                dataGridViewComponents.Rows.Add(row);
            }

            _stores    = GlobalObjects.CasEnvironment.Stores.ToArray();
            _aircrafts = GlobalObjects.AircraftsCore.GetAllAircrafts().ToArray();
            if (_stores.Length == 0 &&
                _aircrafts.Length == 0)
            {
                return;
            }

            //          заполнение списка складов        //
            ///////////////////////////////////////////////
            if (_currentStore != null)
            {
                if (_stores == null || _stores.Length == 0)
                {
                    MessageBox.Show("Can't find store list");
                    return;
                }
                if (_stores.Length == 1)
                {
                    //в системе только один склад
                    radioButtonAircraft.Checked = true;
                    radioButtonAircraft.Enabled = false;
                    radioButtonStore.Enabled    = false;
                }
                else
                {
                    comboBoxStore.Items.Clear();
                    foreach (Store store in _stores)
                    {
                        if (store.ItemId != _currentStore.ItemId)
                        {
                            comboBoxStore.Items.Add(store);
                        }
                    }
                    comboBoxStore.SelectedIndex = 0;
                }
            }
            else
            {
                if (_stores == null || _stores.Length == 0)
                {
                    radioButtonAircraft.Checked = true;
                    radioButtonAircraft.Enabled = false;
                    radioButtonStore.Enabled    = false;
                }
                else
                {
                    comboBoxStore.Items.Clear();
                    comboBoxStore.Items.AddRange(_stores);
                    comboBoxStore.SelectedIndex = 0;
                }
            }
            //////////////////////////////////////////////

            //заполнение списка самолетов
            if (_currentAircraft != null)
            {
                if (_aircrafts == null || _aircrafts.Length == 0)
                {
                    MessageBox.Show("Can't find aircraft list");
                    return;
                }

                if (_stores != null && _stores.Length > 0)
                {
                    radioButtonStore.Enabled    = true;
                    radioButtonAircraft.Enabled = true;
                }
                else
                {
                    radioButtonStore.Enabled    = false;
                    radioButtonAircraft.Enabled = false;
                }

                comboBoxAircraft.Items.Clear();
                comboBoxAircraft.Items.AddRange(_aircrafts);
                comboBoxAircraft.SelectedIndex = 0;
            }
            else
            {
                if (_aircrafts == null || _aircrafts.Length == 0)
                {
                    radioButtonStore.Checked    = true;
                    radioButtonStore.Enabled    = false;
                    radioButtonAircraft.Enabled = false;
                }
                else
                {
                    comboBoxAircraft.Items.Clear();
                    comboBoxAircraft.Items.AddRange(_aircrafts.ToArray());
                    comboBoxAircraft.SelectedIndex = 0;
                }
            }

            if (_aircrafts != null && _aircrafts.Length != 0)
            {
                //заполнение списка базовых деталей выбранного самолета
                _currentBaseDetailsList =
                    new List <BaseComponent>(
                        GlobalObjects.ComponentCore.GetAicraftBaseComponents(((Aircraft)comboBoxAircraft.SelectedItem).ItemId));

                if (_currentBaseDetailsList.Count == 0)
                {
                    MessageBox.Show("Can't find base detail list for aircraft " +
                                    ((Aircraft)comboBoxAircraft.SelectedItem).RegistrationNumber);
                    return;
                }

                //bool haveBaseDetailsToReplace = false;
                //for (int i = 0; i < _currentDetailsList.Length; i++)
                //{
                //    //имеется ли в списке базовая деталь
                //    if (_currentDetailsList[i] is BaseDetail)
                //    {
                //        haveBaseDetailsToReplace = true;
                //        break;
                //    }
                //}
                //if (haveBaseDetailsToReplace)
                //{
                //    comboBoxBaseDetail.Items.Clear();
                //    comboBoxBaseDetail.Items.Add("Replace to aircraft (base details only)");
                //    comboBoxBaseDetail.Items.AddRange(currentBaseDetailsList.ToArray());
                //    comboBoxBaseDetail.SelectedIndex = 1;
                //}
                //else
                //{
                comboBoxBaseComponent.Items.Clear();
                comboBoxBaseComponent.Items.AddRange(_currentBaseDetailsList.ToArray());
                comboBoxBaseComponent.SelectedIndex = 0;
                //}
            }
            else
            {
                comboBoxAircraft.Enabled      = false;
                comboBoxBaseComponent.Enabled = false;
            }

            if (radioButtonStore.Checked)
            {
                comboBoxStore.Enabled         = true;
                comboBoxAircraft.Enabled      = false;
                comboBoxBaseComponent.Enabled = false;
            }
            else
            {
                comboBoxStore.Enabled         = false;
                comboBoxAircraft.Enabled      = true;
                comboBoxBaseComponent.Enabled = true;
            }

            radioButtonStore.Checked = true;
        }
Пример #6
0
        ///<summary>
        ///</summary>
        ///<returns></returns>
        public TransferRecord GetTransferData()
        {
            if (_currentWorkPackage == null)
            {
                return(null);
            }
            var destinationBaseComponent = (BaseComponent)comboBoxBaseComponent.SelectedItem;
            var destinationStore         = (Store)comboBoxStore.SelectedItem;

            var transferDate = dateTimePickerDate.Value;
            var remarks      = textBoxRemarks.Text;

            TransferRecord transfer = null;

            foreach (DataGridViewRow row in dataGridViewComponents.Rows)
            {
                if (!(row.Tag is Component) ||
                    !(row.Cells[0] is DataGridViewCheckBoxCell) ||
                    !(bool)row.Cells[0].Value)
                {
                    continue;
                }

                DataGridViewNumericUpDownCell all     = (DataGridViewNumericUpDownCell)row.Cells[2];
                DataGridViewNumericUpDownCell replace = (DataGridViewNumericUpDownCell)row.Cells[3];
                Component component = row.Tag as Component;
                transfer = new TransferRecord
                {
                    AttachedFile      = fileControl.AttachedFile,
                    ParentComponent   = component,
                    ParentId          = component.ItemId,
                    FromAircraftId    = component.ParentAircraftId,
                    FromStoreId       = component.ParentStoreId,
                    TransferDate      = transferDate,
                    StartTransferDate = transferDate,
                    Position          = "",
                    BeforeReplace     = ((double)all.Value) >= 1 ? (double)all.Value : 1,
                    Replaced          = ((double)replace.Value) >= 1 ? (double)replace.Value : 1,
                    Remarks           = remarks
                };

                if (component is BaseComponent)
                {
                    transfer.OnLifelength =
                        GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay((BaseComponent)component, transferDate);
                }
                else
                {
                    transfer.OnLifelength =
                        GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(component, transferDate);
                    transfer.FromBaseComponentId =
                        component.ParentBaseComponent != null
                            ? component.ParentBaseComponent.ItemId//TODO:(Evgenii Babak) заменить на использование ComponentCore
                                                        : 0;
                }
                if (radioButtonStore.Checked)
                {
                    transfer.DestinationObjectId   = destinationStore.ItemId;
                    transfer.DestinationObjectType = destinationStore.SmartCoreObjectType;
                }
                else
                {
                    transfer.DestinationObjectId   = destinationBaseComponent.ItemId;
                    transfer.DestinationObjectType = destinationBaseComponent.SmartCoreObjectType;
                }
            }
            return(transfer);
        }