Example #1
0
        // ==================================================
        private void DataGVEntranceControl_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            selectedRow         = dataGridViewEntranceControl.SelectedRows[0];
            selectedOrderId     = (int)selectedRow.Cells["Nr_zamówienia"].Value;
            lblOrderIdShow.Text = selectedOrderId.ToString();
            String selectedSfCode = selectedRow.Cells["Kod_półfabrykatu"].Value.ToString();

            lblSfIdShow.Text = selectedSfCode;

            SemiFinished sfBySelectedCode = db.SemiFinisheds.Where(check => check.SfCode == selectedSfCode).First();

            selectedSfId = sfBySelectedCode.IdSemiFinished;

            if ((DateTime)selectedRow.Cells["Dostarczono"].Value < DateTime.Now)
            {
                btnApproval.Enabled = true;
                btnCheck.Enabled    = true;
                btnDone.Enabled     = true;
                if (ChangeTextBoxesDependingOnExistedSelectedControl())
                {
                    this.doControlExist = true;
                    lblDelayTime.Text   = "";
                }
                else
                {
                    this.doResultsChecked  = false;
                    this.doResultsApproved = false;
                    this.doControlExist    = false;
                    int minutesOfDelay = (int)Math.Round((DateTime.Now - (DateTime)selectedRow.Cells["Dostarczono"].Value).TotalMinutes, 0);
                    lblDelayTime.Text = minutesOfDelay > 0 ? $"{minutesOfDelay / 1440} dni, {(minutesOfDelay % 1440) / 60} godzin i {(minutesOfDelay % 1440) % 60} minut opóźnienia" : "";
                }
            }
            else
            {
                MessageBox.Show("Data dostarczenia jest wcześniejsza od chwili obecnej.", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnApproval.Enabled = false;
                btnCheck.Enabled    = false;
                btnDone.Enabled     = false;
                this.ResetAllCheckedPicBox();
                textBoxEmployeePESEL.Text    = "";
                textBoxEmployeePESEL.Enabled = false;
                txtboxThickness.Text         = "";
                txtboxThickness.Enabled      = false;
                txtboxWidth.Text             = "";
                txtboxWidth.Enabled          = false;
                txtboxMass.Text             = "";
                txtboxMass.Enabled          = false;
                txtBoxColor.Text            = "";
                txtBoxColor.Enabled         = false;
                txtBoxQuantity.Text         = "";
                txtBoxQuantity.Enabled      = false;
                checkBoxComposition.Checked = false;
                checkBoxComposition.Enabled = false;
                txtboxComment.Text          = "";
                txtboxComment.Enabled       = false;
                picBoxControlStatus.Image   = Properties.Resources.new_80px;
            }
        }
Example #2
0
        // ==================================================
        private void CheckControl()
        {
            if (lblOrderIdShow.Text == "")
            {
                MessageBox.Show("Wybierz zamówienie i półfabrykat!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                SemiFinished semiFinished = db.SemiFinisheds.FirstOrDefault(sf => sf.IdSemiFinished == selectedSfId);

                bool flagThickness = false;
                bool flagWidth     = false;
                bool flagMass      = false;
                bool flagColor     = false;
                bool flagQuantity  = false;

                if (txtboxThickness.Text.Trim() != "")
                {
                    if (decimal.TryParse(txtboxThickness.Text, out decimal thickness))
                    {
                        if ((decimal)(semiFinished.Thickness * 0.95) < thickness &&
                            thickness < (decimal)(semiFinished.Thickness * 1.05))
                        {
                            picBoxThicknessStatus.Image = Properties.Resources.ok_48px;
                            flagThickness = true;
                        }
                        else
                        {
                            picBoxThicknessStatus.Image = Properties.Resources.cancel_48px;
                        }
                    }
                    else
                    {
                        txtboxThickness.Text = "WPISZ LICZBĘ!";
                    }
                }

                if (txtboxWidth.Text.Trim() != "")
                {
                    if (decimal.TryParse(txtboxWidth.Text, out decimal width))
                    {
                        if ((decimal)(semiFinished.Width * 0.95) < width &&
                            width < (decimal)(semiFinished.Width * 1.05))
                        {
                            picBoxWidhtStatus.Image = Properties.Resources.ok_48px;
                            flagWidth = true;
                        }
                        else
                        {
                            picBoxWidhtStatus.Image = Properties.Resources.cancel_48px;
                        }
                    }
                    else
                    {
                        txtboxWidth.Text = "WPISZ LICZBĘ!";
                    }
                }

                if (txtboxMass.Text.Trim() != "")
                {
                    if (decimal.TryParse(txtboxMass.Text, out decimal mass))
                    {
                        if ((decimal)(semiFinished.SfWeight * 0.95) < mass &&
                            mass < (decimal)(semiFinished.SfWeight * 1.05))
                        {
                            picBoxMassStatus.Image = Properties.Resources.ok_48px;
                            flagMass = true;
                        }
                        else
                        {
                            picBoxMassStatus.Image = Properties.Resources.cancel_48px;
                        }
                    }
                    else
                    {
                        txtboxMass.Text = "WPISZ LICZBĘ!";
                    }
                }

                if (txtBoxColor.Text.Trim() != "")
                {
                    if (semiFinished.Color == txtBoxColor.Text)
                    {
                        picBoxColorStatus.Image = Properties.Resources.ok_48px;
                        flagColor = true;
                    }
                    else
                    {
                        picBoxColorStatus.Image = Properties.Resources.cancel_48px;
                    }
                }

                if (txtBoxQuantity.Text.Trim() != "")
                {
                    SfOrderDetail quantitySfOrder = db.SfOrderDetails
                                                    .Where(check =>
                                                           check.IdSfOrder == selectedOrderId &&
                                                           check.IdSemiFinished == selectedSfId)
                                                    .FirstOrDefault();

                    if (int.TryParse(txtBoxQuantity.Text, out int quantity))
                    {
                        if (quantitySfOrder.Quantity == quantity)
                        {
                            picBoxQuantityStatus.Image = Properties.Resources.ok_48px;
                            flagQuantity = true;
                        }
                        else
                        {
                            picBoxQuantityStatus.Image = Properties.Resources.cancel_48px;
                        }
                    }
                    else
                    {
                        txtBoxQuantity.Text = "LICZBA CAŁKOWITA!";
                    }
                }

                if (flagThickness && flagWidth && flagMass && flagColor && flagQuantity && checkBoxComposition.Checked)
                {
                    picBoxControlStatus.Image = Properties.Resources.good_quality_80px;
                    this.wholeControlStatus   = true;
                }
                else
                {
                    picBoxControlStatus.Image = Properties.Resources.poor_quality_80px;
                    this.wholeControlStatus   = false;
                }
            }
        }