private async void btnDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGVPart.RowCount < 1)
                {
                    MessageBox.Show("삭제할 항목이 없습니다.", "삭제오류", MessageBoxButtons.OK);
                    return;
                }
                string ID = DGVPart.SelectedRows[0].Cells[0].Value.ToString();
                using (GEN2_MEASUREDBEntities db = new GEN2_MEASUREDBEntities())
                {
                    TB_FrontSetting partcode = db.TB_FrontSetting.Find(ID);
                    if (partcode != null)
                    {
                        db.TB_FrontSetting.Remove(partcode);

                        int ir = await db.SaveChangesAsync();

                        lblResult.Text = ir.ToString();

                        DGVPart.DataSource = db.TB_FrontSetting.ToList();
                        ClearText();
                    }
                }
            }
            catch (Exception ex)
            {
                StackTrace trace      = new StackTrace(ex, true);
                StackFrame stackFrame = trace.GetFrame(trace.FrameCount - 1);
                int        lineNumber = stackFrame.GetFileLineNumber();

                I_Part.ErrorLog($"{Share.GetNow_ms()} ({lineNumber}) : {ex.ToString()}");
            }
        }
        private void InfoSetting()
        {
            try
            {
                string ID = DGVPart.SelectedRows[0].Cells[0].Value.ToString();
                using (GEN2_MEASUREDBEntities db = new GEN2_MEASUREDBEntities())
                {
                    TB_FrontSetting partcode = db.TB_FrontSetting.Find(ID);
                    if (partcode != null)
                    {
                        txtAlcCode.Text   = partcode.ALC_Code;
                        txtPartName.Text  = partcode.Part_Name;
                        numStandDis.Value = Convert.ToDecimal(partcode.StandardVal);

                        num_G4_Offset.Value = Convert.ToDecimal(partcode.Gain_G4);
                        num_G4_Min.Value    = Convert.ToDecimal(partcode.Shim_G4_Min);
                        num_G4_Max.Value    = Convert.ToDecimal(partcode.Shim_G4_Max);
                        num_G4_Range.Value  = Convert.ToDecimal(partcode.Shim_G4_Range);
                    }
                }
            }
            catch (Exception ex)
            {
                StackTrace trace      = new StackTrace(ex, true);
                StackFrame stackFrame = trace.GetFrame(trace.FrameCount - 1);
                int        lineNumber = stackFrame.GetFileLineNumber();

                I_Part.ErrorLog($"{Share.GetNow_ms()} ({lineNumber}) : {ex.ToString()}");
            }
        }
Beispiel #3
0
        internal async Task <bool> ShowShimChk(frmMain.PlcReference refplc, double chkkshim, string strindex = "G4")
        {
            bool bReturn = false;

            try
            {
                TB_FrontSetting sETTING = frmMain.G_Data._SETTING;
                if (refplc.AlcCode != frmMain.G_Data._SETTING.ALC_Code)
                {
                    using (GEN2_MEASUREDBEntities db = new GEN2_MEASUREDBEntities())
                    {
                        sETTING = await db.TB_FrontSetting.FindAsync(refplc.AlcCode);
                    }
                }

                BeginInvoke((Action)(() =>
                {
                    double dSelShim = double.Parse(lbl_FSG4_SelVal.Text);
                    lbl_FSG4_ChkVal.Text = chkkshim.ToString("0.000");
                    if (chkkshim >= dSelShim && chkkshim < (double)(dSelShim + sETTING.Shim_G4_Range))
                    {
                        lbl_FSG4_ChkVal.ForeColor = Color.DarkBlue;
                        lbl_FSG4_ChkVal.BackColor = SystemColors.Window;
                        bReturn = true;
                    }
                    else
                    {
                        lbl_FSG4_ChkVal.ForeColor = Color.Red;
                        lbl_FSG4_ChkVal.BackColor = Color.Yellow;
                        I_Home.ProcessLog(($"[ShimConfirmValue(G4) Error] " +
                                           $" 선택 값 :  {dSelShim}, 확인 값 : {chkkshim}"));
                        bReturn = false;
                    }
                }));
                using (GEN2_MEASUREDBEntities db = new GEN2_MEASUREDBEntities())
                {
                    TB_FrontShim tbShim = await db.TB_FrontShim.FindAsync(refplc.WorkDate, refplc.Barcode);

                    if (tbShim != null)
                    {
                        tbShim.ShimG4_Chk_Val = chkkshim;

                        await db.SaveChangesAsync();
                    }
                }
            }
            catch (Exception ex)
            {
                StackTrace trace      = new StackTrace(ex, true);
                StackFrame stackFrame = trace.GetFrame(trace.FrameCount - 1);
                int        lineNumber = stackFrame.GetFileLineNumber();

                I_Home.ErrorLog(($" ({lineNumber})[ShowShimChk({strindex}) Error] : {ex.ToString()}"));
            }
            return(bReturn);
        }
        private void UC_PartSetting_Load(object sender, EventArgs e)
        {
            DGVPart.DoubleBuffered(true);
            DGVPart.Font = new Font("현대하모니 L", 20f, FontStyle.Regular, GraphicsUnit.Point, Convert.ToByte(129));

            using (GEN2_MEASUREDBEntities db = new GEN2_MEASUREDBEntities())
            {
                DGVPart.DataSource = db.TB_FrontSetting.ToList();
            }
        }
        private async void btnFix_Click(object sender, EventArgs e)
        {
            try
            {
                int    rowindex = DGVPart.SelectedRows[0].Index;
                string ID       = DGVPart.SelectedRows[0].Cells[0].Value.ToString();
                if (txtAlcCode.Text != ID)
                {
                    MessageBox.Show("ALC CODE는 수정 할 수 없습니다. \r\n(추가 및 기존ALC삭제로 변경 가능)", "ALC Code 오류", MessageBoxButtons.OK);
                    return;
                }
                using (GEN2_MEASUREDBEntities db = new GEN2_MEASUREDBEntities())
                {
                    TB_FrontSetting partcode = db.TB_FrontSetting.Find(ID);
                    if (partcode != null)
                    {
                        txtAlcCode.Text      = partcode.ALC_Code;
                        partcode.Part_Name   = txtPartName.Text;
                        partcode.StandardVal = Convert.ToDouble(numStandDis.Value);

                        partcode.Gain_G4       = Convert.ToDouble(num_G4_Offset.Value);
                        partcode.Shim_G4_Min   = Convert.ToDouble(num_G4_Min.Value);
                        partcode.Shim_G4_Max   = Convert.ToDouble(num_G4_Max.Value);
                        partcode.Shim_G4_Range = Convert.ToDouble(num_G4_Range.Value);

                        int ir = await db.SaveChangesAsync();

                        lblResult.Text = ir.ToString();

                        DGVPart.DataSource = db.TB_FrontSetting.ToList();

                        if (partcode.ALC_Code == frmMain.G_Data._SETTING.ALC_Code)
                        {
                            frmMain.G_Data._SETTING = partcode;
                        }
                    }
                    DGVPart.Rows[rowindex].Selected = true;
                }
            }
            catch (Exception ex)
            {
                StackTrace trace      = new StackTrace(ex, true);
                StackFrame stackFrame = trace.GetFrame(trace.FrameCount - 1);
                int        lineNumber = stackFrame.GetFileLineNumber();

                I_Part.ErrorLog($"{Share.GetNow_ms()} ({lineNumber}) : {ex.ToString()}");
            }
        }
        private async void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtAlcCode.Text.Length != 4)
                {
                    MessageBox.Show("ALC CODE 문자 길이는 4입니다..", "ALC Code 오류", MessageBoxButtons.OK);
                    return;
                }
                using (GEN2_MEASUREDBEntities db = new GEN2_MEASUREDBEntities())
                {
                    TB_FrontSetting partcode = new TB_FrontSetting();
                    partcode.ALC_Code    = txtAlcCode.Text;
                    partcode.Part_Name   = txtPartName.Text;
                    partcode.StandardVal = Convert.ToDouble(numStandDis.Value);

                    partcode.Gain_G4       = Convert.ToDouble(num_G4_Offset.Value);
                    partcode.Shim_G4_Min   = Convert.ToDouble(num_G4_Min.Value);
                    partcode.Shim_G4_Max   = Convert.ToDouble(num_G4_Max.Value);
                    partcode.Shim_G4_Range = Convert.ToDouble(num_G4_Range.Value);

                    db.TB_FrontSetting.Add(partcode);

                    int ir = await db.SaveChangesAsync();

                    lblResult.Text = ir.ToString();

                    DGVPart.DataSource = db.TB_FrontSetting.ToList();
                    ClearText();
                }
            }
            catch (Exception ex)
            {
                StackTrace trace      = new StackTrace(ex, true);
                StackFrame stackFrame = trace.GetFrame(trace.FrameCount - 1);
                int        lineNumber = stackFrame.GetFileLineNumber();

                I_Part.ErrorLog($"{Share.GetNow_ms()} ({lineNumber}) : {ex.ToString()}");
            }
        }
Beispiel #7
0
        internal async Task ShowShimDGV(int iworkdate, DataGridView dgvShim, int iworkno = -1)
        {
            try
            {
                BeginInvoke((Action)(() => dgvShim.Rows.Clear()));

                using (GEN2_MEASUREDBEntities db = new GEN2_MEASUREDBEntities())
                {
                    List <TB_FrontShim> lstShim = await db.TB_FrontShim.SqlQuery($"Select * from TB_FrontShim " +
                                                                                 $" Order by Work_No Asc").ToListAsync();

                    for (int i = 0; i < lstShim.Count; i++)
                    {
                        if (lstShim[i].ShimG4_Val != null)
                        {
                            List <string> addrow = new List <string>();
                            addrow.Add(lstShim[i].Work_No.ToString());
                            addrow.Add(lstShim[i].ShimG4_Val.ToString());
                            BeginInvoke((Action)(() =>
                            {
                                dgvShim.AddGridrow(addrow.ToArray());
                            }));
                        }
                    }
                    if (iworkno != -1)
                    {
                        await Task.Run(() => FindShim(iworkno, dgvShim));
                    }
                }
            }
            catch (Exception ex)
            {
                StackTrace trace      = new StackTrace(ex, true);
                StackFrame stackFrame = trace.GetFrame(trace.FrameCount - 1);
                int        lineNumber = stackFrame.GetFileLineNumber();

                I_Home.ErrorLog(($"{dgvShim.Tag}({lineNumber}) : {ex.ToString()}"));
            }
        }
Beispiel #8
0
        internal async Task ShowData(int iworkdate)
        {
            try
            {
                using (GEN2_MEASUREDBEntities db = new GEN2_MEASUREDBEntities())
                {
                    lstGearfrt = await db.TB_GearFront.SqlQuery($"Select * from TB_GearFront ").ToListAsync();

                    lstFrtCase = await db.TB_FrontCase.SqlQuery($"Select * from TB_FrontCase ").ToListAsync();

                    for (int i = 0; i < lstGearfrt.Count; i++)
                    {
                        List <string> addrow = new List <string>();
                        addrow.Add(lstGearfrt[i].Insert_Time.ToString());
                        addrow.Add(lstGearfrt[i].Work_Date.ToString());
                        addrow.Add(lstGearfrt[i].Work_No.ToString());
                        addrow.Add(lstGearfrt[i].GearNo_Front.ToString());
                        addrow.Add(lstGearfrt[i].GearNo_4WD.ToString());
                        addrow.Add(lstGearfrt[i].Part_Name.ToString());

                        addrow.Add(lstGearfrt[i].FGear_G4_Min.ToString());
                        addrow.Add(lstGearfrt[i].FGear_G4_Val.ToString());
                        addrow.Add(lstGearfrt[i].FGear_G4_Max.ToString());

                        addrow.Add(lstGearfrt[i].FGear_G2_Min.ToString());
                        addrow.Add(lstGearfrt[i].FGear_G2_Val.ToString());
                        addrow.Add(lstGearfrt[i].FGear_G2_Max.ToString());

                        BeginInvoke((Action)(() =>
                        {
                            DGVFrontGear.AddGridrow(addrow.ToArray());
                        }));
                    }

                    for (int i = 0; i < lstFrtCase.Count; i++)
                    {
                        List <string> addrow = new List <string>();
                        addrow.Add(lstFrtCase[i].Insert_Time.ToString());
                        addrow.Add(lstFrtCase[i].Work_Date.ToString());
                        addrow.Add(lstFrtCase[i].Work_No.ToString());
                        addrow.Add(lstFrtCase[i].FrontCase_Bar.ToString());
                        addrow.Add(lstFrtCase[i].Part_Name.ToString());

                        addrow.Add(lstFrtCase[i].FCase_4WD_Min.ToString());
                        addrow.Add(lstFrtCase[i].FCase_4WD_Val.ToString());
                        addrow.Add(lstFrtCase[i].FCase_4WD_Max.ToString());

                        addrow.Add(lstFrtCase[i].FCase_G4_Min.ToString());
                        addrow.Add(lstFrtCase[i].FCase_G4_Val.ToString());
                        addrow.Add(lstFrtCase[i].FCase_G4_Max.ToString());

                        BeginInvoke((Action)(() =>
                        {
                            DGVFrontCase.AddGridrow(addrow.ToArray());
                        }));
                    }
                }
            }
            catch (Exception ex)
            {
                StackTrace trace      = new StackTrace(ex, true);
                StackFrame stackFrame = trace.GetFrame(trace.FrameCount - 1);
                int        lineNumber = stackFrame.GetFileLineNumber();

                I_Home.ErrorLog(($" ({lineNumber}) : {ex.ToString()}"));
            }
        }