private void UpdateMstOrder() { using (UpdateMstQty updForm = new UpdateMstQty(currentMstOrder.LastUpdateTime, currentMstOrder.MadeQty, currentMstOrder.PcbOnMb)) { updateFormDisplayed = true; if (updForm.ShowDialog() == DialogResult.OK) { currentMstOrder.LastUpdateTime = (DateTime.Now - currentMstOrder.DateStart).TotalMinutes >= 1 ? DateTime.Now : DateTime.Now.AddMinutes(1); currentMstOrder.MadeQty = updForm.newTotalQty; UpdateMstLabels(); updateFormDisplayed = false; if (currentMstOrder.RecordId > 0) { //update SqlOperations.UpdateCurrentMstOrderQuantity(currentMstOrder.MadeQty, currentMstOrder.RecordId); } else { //insert SqlOperations.SaveRecordToDb(currentMstOrder.DateStart, DateTime.Now, smtLine, currentMstOrder.Oper, currentMstOrder.OrderNumber, currentMstOrder.Nc10, currentMstOrder.MadeQty.ToString(), "0", "0", "check", "", currentMstOrder.Stencil, "MST", 0); int lastRecordId = 0; lastRecordId = SqlOperations.GetLastRecordIdForLine(smtLine); if (lastRecordId > 0) { currentMstOrder.RecordId = lastRecordId; } } var eff = Math.Round(MstCurrentShiftEfficiency.CalculateCurrentShiftEff(currentMstOrder, dataGridViewMstOrders), 0); angularGauge1.Value = Math.Min(100, eff); labelCurrentShiftEfficiency.Text = $"Wydajność aktualnej zmiany: {eff}%"; } } }
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; } } } }