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()}");
            }
        }
        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()}");
            }
        }
示例#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 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()}");
            }
        }