Example #1
0
 private void button7_Click(object sender, EventArgs e)
 {
     using (ReadQrForm qrForm = new ReadQrForm())
     {
         if (qrForm.ShowDialog() == DialogResult.OK)
         {
             DgvTools.AddReelToTrash(qrForm.nc12, qrForm.id, dataGridViewLedTrash, ref currentMstOrder);
             DgvTools.MarkRemovedRow(qrForm.nc12, qrForm.id, dataGridViewMstLedReels, Color.FromArgb(255, 44, 62, 80), Color.FromArgb(255, 189, 195, 199));
         }
     }
 }
Example #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            using (MstOrder mstOrderForm = new MstOrder(smtLine))
            {
                if (mstOrderForm.ShowDialog() == DialogResult.OK)
                {
                    currentMstOrder = mstOrderForm.currentMstOrderData;

                    DataTable ledInfoTable = MST.MES.SqlOperations.SparingLedInfo.GetReelsForLot(currentMstOrder.OrderNumber);

                    UpdateMstLabels();
                    DgvTools.PrepareDgvForBins(dataGridViewMstLedReels, currentMstOrder.BinQty);
                    DgvTools.PrepareDgvForBins(dataGridViewLedTrash, currentMstOrder.BinQty);
                    timerMstUpdate.Enabled = true;
                }
            }
        }
Example #3
0
        public static void AddReelToGrid(string nc12, string id, DataGridView grid, ref CurrentMstOrder currentOrder)
        {
            DataTable reelTable      = MST.MES.SqlOperations.SparingLedInfo.GetInfoFor12NC_ID(nc12, id);
            string    qty            = reelTable.Rows[0]["Ilosc"].ToString();
            string    binId          = reelTable.Rows[0]["Tara"].ToString();
            string    zlecenieString = reelTable.Rows[0]["ZlecenieString"].ToString();

            if (currentOrder.OrderNumber == zlecenieString)
            {
                int binRow = 0;
                for (int r = 0; r < grid.Rows.Count; r++)
                {
                    if (grid.Rows[r].Cells[0].Value == null)
                    {
                        continue;
                    }
                    if (grid.Rows[r].Cells[0].Value.ToString() == binId)
                    {
                        binRow = r;
                        break;
                    }
                }

                grid.Rows.Insert(binRow + 1, nc12, id, qty);
                ledReelData newReel = new ledReelData(nc12, double.Parse(qty), "", "", zlecenieString, id, binId);
                currentOrder.LedReels.Add(newReel);

                DgvTools.SumUpLedsInBins(grid);

                foreach (DataGridViewColumn col in grid.Columns)
                {
                    col.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                }
            }
            else
            {
                MessageBox.Show("Ta rolka LED przypisana jest zlecenia: " + zlecenieString);
            }
        }
Example #4
0
 private void button6_Click(object sender, EventArgs e)
 {
     using (ReadQrForm qrForm = new ReadQrForm())
     {
         bool alreadyExist = false;
         if (qrForm.ShowDialog() == DialogResult.OK)
         {
             foreach (var reel in currentMstOrder.LedReels)
             {
                 if (reel.NC12 == qrForm.nc12 & reel.ID == qrForm.id)
                 {
                     MessageBox.Show("Ta rolka została już dodana!");
                     alreadyExist = true;
                     break;
                 }
             }
             if (!alreadyExist)
             {
                 DgvTools.AddReelToGrid(qrForm.nc12, qrForm.id, dataGridViewMstLedReels, ref currentMstOrder);
             }
         }
     }
 }
Example #5
0
        private void MstSaveOrder_Click(object sender, EventArgs e)
        {
            if (currentMstOrder.OrderNumber.Trim() != "")
            {
                timerMstUpdate.Enabled = false;
                using (FinishMstOrder finishForm = new FinishMstOrder(ref currentMstOrder, smtLine))
                {
                    if (finishForm.ShowDialog() == DialogResult.OK)
                    {
                        if (currentMstOrder.RecordId > 0)
                        {
                            SqlOperations.UpdateCurrentMstOrderQuantity(currentMstOrder.MadeQty, currentMstOrder.RecordId);
                        }
                        else
                        {
                            SqlOperations.SaveRecordToDb(currentMstOrder.DateStart, DateTime.Now, smtLine, currentMstOrder.Oper, currentMstOrder.OrderNumber, currentMstOrder.Nc10, currentMstOrder.MadeQty.ToString(), "0", "0", "check", "", currentMstOrder.Stencil, "MST", 0);
                        }

                        double efficiency = Math.Round(EfficiencyCalculation.CalculateEfficiency(currentMstOrder.DateStart, DateTime.Now, currentMstOrder.Nc10, currentMstOrder.MadeQty, true) * 100, 0);

                        dataGridViewMstOrders.Rows.Insert(0, currentMstOrder.DateStart, DateTime.Now, currentMstOrder.OrderNumber, currentMstOrder.Nc10.Insert(4, " ").Insert(8, " "), currentMstOrder.MadeQty, efficiency + "%", currentMstOrder.ModelName);
                        currentMstOrder = new CurrentMstOrder("Brak", "Brak", 0, 0, DateTime.Now, "Brak", "0000000000", DateTime.Now, 0, 0, 0, 0, new List <ledReelData>(), "Brak", 0, 0);
                        dataGridViewMstLedReels.Rows.Clear();
                        dataGridViewLedTrash.Rows.Clear();
                        UpdateMstLabels();
                        DgvTools.CleanUpMstDgv(dataGridViewMstOrders);
                        var eff = Math.Round(MstCurrentShiftEfficiency.CalculateCurrentShiftEff(currentMstOrder, dataGridViewMstOrders), 0);
                        angularGauge1.Value = Math.Min(100, eff);
                        labelCurrentShiftEfficiency.Text = $"Wydajność aktualnej zmiany: {eff}%";
                    }
                    else
                    {
                        timerMstUpdate.Enabled = true;
                    }
                }
            }
        }
Example #6
0
        private void LoadMstOrdersFromDb(int recordsQuantity)
        {
            var       nc       = MST.MES.SqlOperations.ConnectDB.Nc12ToModelFullDict();
            DataTable sqlTable = SqlOperations.GetMstSmtRecordsFromDb(recordsQuantity, smtLine);
            var       smto     = MST.MES.SqlDataReaderMethods.SMT.GetOneOrder("");

            dataGridViewMstOrders.Columns["MstOrdersStart"].DefaultCellStyle.Format = "HH:mm dd-MMM";
            dataGridViewMstOrders.Columns["MstOrdersEnd"].DefaultCellStyle.Format   = "HH:mm dd-MMM";

            List <EfficiencyCalculation.OrderDataForEfficiencyStructure> ordersEff = new List <EfficiencyCalculation.OrderDataForEfficiencyStructure>();

            if (sqlTable.Rows.Count > 0)
            {
                HashSet <string> nc12ToModelList = new HashSet <string>();
                foreach (DataRow row in sqlTable.Rows)
                {
                    DateTime startDate = DateTime.Parse(row["DataCzasStart"].ToString().Trim());
                    DateTime endDate   = DateTime.Parse(row["DataCzasKoniec"].ToString().Trim());

                    string nc10       = row["Model"].ToString();
                    double qty        = 0;
                    string orderNo    = row["NrZlecenia"].ToString();
                    double efficiency = 0;

                    if (double.TryParse(row["IloscWykonana"].ToString(), out qty))
                    {
                        efficiency = Math.Round(EfficiencyCalculation.CalculateEfficiency(startDate, endDate, nc10, qty, true) * 100, 0);
                    }
                    string name = nc.ContainsKey(nc10 + "00") ? nc[nc10 + "00"] : nc10;
                    dataGridViewMstOrders.Rows.Insert(0, startDate, endDate, orderNo, nc10.Insert(4, " ").Insert(8, " "), qty, efficiency + "%", name);
                    nc12ToModelList.Add(nc10 + "00");

                    ordersEff.Add(new EfficiencyCalculation.OrderDataForEfficiencyStructure()
                    {
                        start = startDate, end = endDate, qty = qty, modelId = nc10
                    });

                    var owningShift  = DateTools.GetOrderOwningShift(startDate, endDate);
                    var currentShift = DateTools.whatDayShiftIsit(DateTime.Now);
                    //1878856
                    if (orderNo == "1878856")
                    {
                        ;
                    }
                    if (owningShift.fixedDate != currentShift.fixedDate)
                    {
                        if (owningShift.fixedDate.Date == currentShift.fixedDate.Date)
                        {
                            DgvTools.ColorDgvRow(dataGridViewMstOrders.Rows[0], Color.LightGray);
                        }
                        else
                        {
                            DgvTools.ColorDgvRow(dataGridViewMstOrders.Rows[0], Color.Silver);
                        }
                    }
                }
                //Dictionary<string, string> nc12toName = SqlOperations.nc12ToModelDict(nc12ToModelList.ToArray());

                //foreach (DataGridViewRow row in dataGridViewMstOrders.Rows)
                //{
                //    string nc12 = row.Cells["Column12NC"].Value.ToString().Replace(" ","") + "00";
                //    row.Cells["ColumnName"].Value = nc12toName[nc12];
                //}

                DgvTools.AutoSizeColumns(dataGridViewMstOrders, DataGridViewAutoSizeColumnMode.AllCells);

                EfficiencyRecordsForOrdersHistory.FillOutListView(lVMstEfficiencyRecord, ordersEff);
            }

            var eff = Math.Round(MstCurrentShiftEfficiency.CalculateCurrentShiftEff(currentMstOrder, dataGridViewMstOrders), 0);

            angularGauge1.Value = Math.Min(100, eff);
            labelCurrentShiftEfficiency.Text = $"Wydajność aktualnej zmiany: {eff}%";
        }
Example #7
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (!suspendCellVelueChangedEvent)
            {
                int ngIndex    = dataGridViewLg.Columns.IndexOf(dataGridViewLg.Columns["Ng"]);
                int scrapIndex = dataGridViewLg.Columns.IndexOf(dataGridViewLg.Columns["Scrap"]);
                // Debug.WriteLine("Cell value changed: " + e.RowIndex + " " + e.ColumnIndex);
                //calculate good qty
                if (dataGridViewLg.Rows.Count > 0 & (e.ColumnIndex == ngIndex || e.ColumnIndex == scrapIndex))
                {
                    int rowIndex = e.RowIndex;

                    DataGridViewCell ngCell    = dataGridViewLg.Rows[rowIndex].Cells["Ng"];
                    DataGridViewCell scrapCell = dataGridViewLg.Rows[rowIndex].Cells["Scrap"];

                    double ngValue    = -9999;
                    double scrapValue = -9999;

                    if (ngCell.Value != null)
                    {
                        if (!(double.TryParse(ngCell.Value.ToString(), out ngValue)))
                        {
                            dataGridViewLg.Rows[e.RowIndex].Cells[ngIndex].Value = null;
                            ngValue = -9999;
                        }
                        else
                        {
                            //ng ,0 will be 0
                            dataGridViewLg.Rows[e.RowIndex].Cells[ngIndex].Value = ngValue;
                        }
                    }

                    if (dataGridViewLg.Columns["Scrap"].Visible)
                    {
                        if (scrapCell.Value != null)
                        {
                            if (!(double.TryParse(scrapCell.Value.ToString(), out scrapValue)))
                            {
                                dataGridViewLg.Rows[e.RowIndex].Cells[scrapIndex].Value = null;
                                scrapValue = -9999;
                            }
                        }
                    }
                    else
                    {
                        scrapValue = 0;
                    }

                    if (ngValue > -9999 & scrapValue > -9999 & dataGridViewLg.Rows[e.RowIndex].Cells["ColumnQty"].Value != null)
                    {
                        double orderedQty = double.Parse(dataGridViewLg.Rows[e.RowIndex].Cells["ColumnQty"].Value.ToString());
                        double goodQty    = orderedQty - ngValue - scrapValue;
                        dataGridViewLg.Rows[e.RowIndex].Cells["goodQty"].Value = goodQty;
                    }
                    else
                    {
                        dataGridViewLg.Rows[e.RowIndex].Cells["goodQty"].Value = "";
                    }
                }

                //saving finished LOT
                foreach (DataGridViewRow row in dataGridViewLg.Rows)
                {
                    //Debug.WriteLine("Checking chkBox row:" + row.Index + " " + Convert.ToBoolean(row.Cells["ColumnSaved"].Value));
                    if (!Convert.ToBoolean(row.Cells["ColumnSaved"].Value))
                    {
                        if (IsRowReadyToBeSaved(row))
                        {
                            //Debug.WriteLine("Saving row:" + row.Index);
                            DataGridViewCheckBoxCell ch = (DataGridViewCheckBoxCell)row.Cells["ColumnSaved"];
                            suspendCellVelueChangedEvent = true;
                            lotFinished(ch, row.Index);
                            suspendCellVelueChangedEvent = false;

                            DateTime startDate       = (DateTime)row.Cells["StartDate"].Value;
                            DateTime endDate         = (DateTime)row.Cells["EndDate"].Value;
                            string   firstPieceCheck = "";

                            string stencil = Tools.getCellValue(row.Cells["Stencil"]);

                            LedLeftovers ledLeftovers  = (LedLeftovers)row.Cells["ColumnButtonLed"].Tag;
                            double       totalLedsUsed = 0;
                            string       leftovers     = ledLeftovers.RankA[0].ID + ":" + ledLeftovers.RankA[0].Nc12 + ":" + ledLeftovers.RankA[0].QtyLeft + "|" + ledLeftovers.RankB[0].ID + ":" + ledLeftovers.RankB[0].Nc12 + ":" + ledLeftovers.RankB[0].QtyLeft;
                            for (int i = 0; i < ledLeftovers.RankA.Count; i++)
                            {
                                totalLedsUsed += ledLeftovers.RankA[i].StartQty - ledLeftovers.RankA[i].QtyLeft;
                                totalLedsUsed += ledLeftovers.RankB[i].StartQty - ledLeftovers.RankB[i].QtyLeft;
                                if (i > 0)
                                {
                                    leftovers += "#" + ledLeftovers.RankA[i].ID + ":" + ledLeftovers.RankA[i].Nc12 + ":" + ledLeftovers.RankA[i].QtyLeft + "|" + ledLeftovers.RankB[i].ID + ":" + ledLeftovers.RankB[i].Nc12 + ":" + ledLeftovers.RankB[i].QtyLeft;
                                }
                            }

                            if (row.Cells["ColumnQualityCheck"].Tag != null)
                            {
                                firstPieceCheck = row.Cells["ColumnQualityCheck"].Tag.ToString();
                            }

                            string scrap = "0";
                            if (dataGridViewLg.Columns["Scrap"].Visible)
                            {
                                scrap = row.Cells["Scrap"].Value.ToString();
                            }

                            SqlOperations.SaveRecordToDb(
                                startDate,
                                endDate,
                                smtLine,
                                row.Cells["Operator"].Value.ToString(),
                                row.Cells["ColumnLot"].Value.ToString(),
                                row.Cells["ColumnModel"].Value.ToString(),
                                row.Cells["goodQty"].Value.ToString(),
                                row.Cells["Ng"].Value.ToString(),
                                scrap,
                                firstPieceCheck,
                                leftovers,
                                stencil,
                                "LG",
                                totalLedsUsed);
                            // Debug.WriteLine("Saved");
                            DgvTools.CleanUpLgiDgv(dataGridViewLg);
                        }
                    }
                }
                dataGridViewLg.HorizontalScrollingOffset = 0;
            }
        }
Example #8
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            string stencil = "";

            if (radioButtonNewStencil.Checked)
            {
                using (var dial = new ScanStencilQr(currentLotData.Model))
                {
                    dial.ShowDialog();
                    if (dial.DialogResult == DialogResult.OK)
                    {
                        stencil = dial.stencil;
                    }
                }
                //Stencil QR reading
                //    ScanStencilQr fm = new ScanStencilQr(ref stencil, currentLotData.Model);
                //fm.ShowDialog();
            }
            else
            {
                stencil = (string)radioButtonCurrentStencil.Tag;
            }



            if (buttonOK.Text == "OK" & stencil.Trim() != "")
            {
                grid.SuspendLayout();

                string       lotNo    = textBoxLotNo.Text;
                LedLeftovers ledsLeft = new LedLeftovers(new List <RankStruc>(), new List <RankStruc>(), lotNo);

                foreach (DataGridViewRow rowA in dataGridViewRankA.Rows)
                {
                    string rankA        = labelRankA.Text.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.None)[1];
                    string rankAId      = rowA.Cells["RankAId"].Value.ToString();
                    string rankA12NC    = rowA.Cells["RankANc12"].Value.ToString();
                    string iloscAString = rowA.Cells["RankAIlosc"].Value.ToString();
                    double rankAIlosc   = double.Parse(iloscAString);
                    ledsLeft.RankA.Add(new RankStruc(rankA, rankAId, rankA12NC, -1, rankAIlosc));
                }

                foreach (DataGridViewRow rowB in dataGridViewRankB.Rows)
                {
                    string rankB        = labelRankB.Text.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.None)[1];
                    string rankBId      = rowB.Cells["rankBId"].Value.ToString();
                    string rankB12NC    = rowB.Cells["RankBNc12"].Value.ToString();
                    string iloscBString = rowB.Cells["rankBIlosc"].Value.ToString();
                    double rankBIlosc   = double.Parse(iloscBString);
                    ledsLeft.RankB.Add(new RankStruc(rankB, rankBId, rankB12NC, -1, rankBIlosc));
                }

                grid.Rows.Insert(0, 1);
                int lastRow = 0;
                grid.Rows[lastRow].Cells["ColumnSaved"].Style.BackColor = Color.Red;
                grid.Rows[lastRow].Cells["ColumnLot"].Value             = textBoxLotNo.Text;
                grid.Rows[lastRow].Cells["ColumnModel"].Value           = currentLotData.Model;
                grid.Rows[lastRow].Cells["ColumnQty"].Value             = currentLotData.OrderedQty;
                grid.Rows[lastRow].Cells["ColumnRankA"].Value           = currentLotData.RankA;
                grid.Rows[lastRow].Cells["ColumnRankB"].Value           = currentLotData.RankB;
                grid.Rows[lastRow].Cells["Rank12NC"].Value                  = ledsLeft.RankA[0].Nc12;
                grid.Rows[lastRow].Cells["ColumnButtonLed"].Value           = "BRAK";
                grid.Rows[lastRow].Cells["ColumnButtonLed"].Style.BackColor = Color.Red;
                grid.Rows[lastRow].Cells["ColumnQualityCheck"].Value        = "";
                grid.Rows[lastRow].Cells["StartDate"].Value                 = DateTime.Now;
                grid.Rows[lastRow].Cells["ColumnButtonLed"].Tag             = ledsLeft;
                grid.Rows[lastRow].Cells["Operator"].Value                  = comboBoxOperator.Text;
                grid.Rows[lastRow].Cells["Stencil"].Value = stencil;
                grid.Rows[lastRow].Cells["connQty"].Value = Tools.GetNumberOfConnectors(currentLotData.Model);

                if (grid.Rows[lastRow].Cells["connQty"].Value.ToString() == "4")
                {
                    //grid.Rows[lastRow].Cells["connQty"].Style.ForeColor = System.Drawing.Color.Red;
                    grid.Rows[lastRow].Cells["connQty"].Style.ForeColor = Color.White;
                    grid.Rows[lastRow].Cells["connQty"].Style.BackColor = Color.DarkCyan;
                }

                if (grid.Rows.Count == 1)
                {
                    foreach (DataGridViewColumn col in grid.Columns)
                    {
                        col.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                    }
                    grid.Rows[lastRow].Cells["ColumnQualityCheck"].Style.BackColor = Color.Red;
                    grid.Rows[lastRow].Cells["ColumnQualityCheck"].Value           = "BRAK";
                }
                else
                {
                    if (Tools.getCellValue(grid.Rows[lastRow + 1].Cells["ColumnModel"]) != "")
                    {
                        if (grid.Rows[lastRow].Cells["ColumnModel"].Value.ToString() != grid.Rows[lastRow + 1].Cells["ColumnModel"].Value.ToString())
                        {
                            grid.Rows[lastRow].Cells["ColumnQualityCheck"].Style.BackColor = Color.Red;
                            grid.Rows[lastRow].Cells["ColumnQualityCheck"].Value           = "BRAK";
                        }
                    }
                }



                DgvTools.CleanUpLgiDgv(grid);
                grid.FirstDisplayedScrollingRowIndex = 0;
                this.Close();
                grid.ResumeLayout();
            }
            else
            {
            #if DEBUG
                grid.Columns["Stencil"].Visible = true;
                grid.Rows.Insert(0, 1);
                grid.Rows[0].Cells["StartDate"].Value             = System.DateTime.Now;
                grid.Rows[0].Cells["ColumnSaved"].Style.BackColor = Color.Red;
                ScanStencilQr fm = new ScanStencilQr(currentLotData.Model);
                fm.ShowDialog();
            #endif
            }
        }