public ErrorAlarmForm(BarcodeTestResultInfo info, bool isTest) { this.WindowState = FormWindowState.Maximized; InitializeComponent(); InitializeFactor(info); this.isTest = isTest; }
private void InitializeControlAddedEvent() { FileInfo existFunctionFileCheck = new FileInfo(this.jsonFunctionSettingFilePath); if (existFunctionFileCheck.Exists == true) { using (FileStream fs = new FileStream(this.jsonFunctionSettingFilePath, FileMode.Open)) { using (BinaryReader br = new BinaryReader(fs)) { string jsonDeSerializedData = br.ReadString(); this.function = JsonConvert.DeserializeObject <FunctionSetting>(jsonDeSerializedData); br.Close(); } fs.Close(); } } if (function.INSPECTION_INFO != false) { button_Save.Enabled = false; textBox_FactoryName.Enabled = false; textBox_FactoryName.Text = ""; textBox_LineNum.Enabled = false; textBox_LineNum.Text = "0"; textBox_WorkerName.Enabled = false; textBox_WorkerName.Text = ""; return; } else { button_Save.Enabled = true; textBox_FactoryName.Enabled = true; textBox_LineNum.Enabled = true; textBox_WorkerName.Enabled = true; } FileInfo existCheck = new FileInfo(this.jsonFilePath); if (existCheck.Exists == true) { using (FileStream fs = new FileStream(this.jsonFilePath, FileMode.Open)) { using (BinaryReader br = new BinaryReader(fs)) { string jsonDeSerializedData = br.ReadString(); this.trInfo = JsonConvert.DeserializeObject <BarcodeTestResultInfo>(jsonDeSerializedData); br.Close(); } fs.Close(); } textBox_FactoryName.Text = trInfo.Factory_Name; textBox_LineNum.Text = trInfo.Line_Num.ToString(); textBox_WorkerName.Text = trInfo.Worker_Name; } }
private void InitializeFactor(BarcodeTestResultInfo info) { string currentFolder = Environment.CurrentDirectory; string path = Path.Combine(currentFolder, "BarcodeDatabase.sqlite"); connStr = "Data Source=" + path + ";" + "version=3;"; errorInfo = info; if (isTest == true) { this.textBox_OriginCode.Text = errorInfo.Origin_Item; } else { this.textBox_OriginCode.Text = "Scan Lot/Box Error"; } }
private void InitializeControlAddedEvent() { FileInfo existFunctionFileCheck = new FileInfo(this.jsonFunctionSettingFilePath); if (existFunctionFileCheck.Exists == true) { using (FileStream fs = new FileStream(this.jsonFunctionSettingFilePath, FileMode.Open)) { using (BinaryReader br = new BinaryReader(fs)) { string jsonDeSerializedData = br.ReadString(); this.function = JsonConvert.DeserializeObject <FunctionSetting>(jsonDeSerializedData); br.Close(); } fs.Close(); } } FileInfo existCheck = new FileInfo(this.jsonFilePath); if (existCheck.Exists == true) { using (FileStream fs = new FileStream(this.jsonFilePath, FileMode.Open)) { using (BinaryReader br = new BinaryReader(fs)) { string jsondeSerializedData = br.ReadString(); this.testResultInfo = JsonConvert.DeserializeObject <BarcodeTestResultInfo>(jsondeSerializedData); br.Close(); } fs.Close(); } if (this.testResultInfo.Factory_Name == "" || this.testResultInfo.Worker_Name == "") { this.testResultInfo.Factory_Name = "None"; this.testResultInfo.Worker_Name = "None"; this.testResultInfo.Line_Num = 0; } } else { this.testResultInfo.Factory_Name = "None"; this.testResultInfo.Worker_Name = "None"; this.testResultInfo.Line_Num = 0; } using (conn = new SQLiteConnection(connStr)) { conn.Open(); code_CRUD = new BarcodeReferenceCode_CRUD(conn); master_ds = code_CRUD.SelectAll_Dataset(BarcodeReferenceCode_CRUD.Table.MASTER_CODE); middle_ds = code_CRUD.SelectAll_Dataset(BarcodeReferenceCode_CRUD.Table.BOX_CODE); carton_ds = code_CRUD.SelectAll_Dataset(BarcodeReferenceCode_CRUD.Table.LOT_CODE); } cbbMaster.DataSource = master_ds.Tables["MasterCodeTable"]; cbbMaster.DisplayMember = "MasterCode"; try { if (function.BOX_LOT_CODE == false) { cbbMaster.Enabled = true; cbbMaster.SelectedIndex = _masterIndex; chbOnlyMaster.Checked = false; } else { if (chbOnlyMaster.Checked) { cbbMaster.Enabled = true; cbbMaster.SelectedIndex = _masterIndex; } else { cbbMaster.Enabled = false; cbbMaster.Text = ""; } } } catch { } cbbMiddle.DataSource = middle_ds.Tables["BoxCodeTable"]; cbbMiddle.DisplayMember = "BoxCode"; try { if (function.BOX_LOT_CODE == false) { cbbMiddle.Enabled = true; cbbMiddle.SelectedIndex = _middleIndex; chbSelectMiddle.Checked = false; } else { if (chbSelectMiddle.Checked) { cbbMiddle.Enabled = true; cbbMiddle.SelectedIndex = _middleIndex; } else { cbbMiddle.Enabled = false; cbbMiddle.Text = ""; } } } catch { } cbbCarton.DataSource = carton_ds.Tables["LotCodeTable"]; cbbCarton.DisplayMember = "LotCode"; try { if (function.BOX_LOT_CODE == false) { cbbCarton.Enabled = true; cbbCarton.SelectedIndex = _cartonIndex; chbSelectCarton.Checked = false; } else { if (chbSelectCarton.Checked) { cbbCarton.Enabled = true; cbbCarton.SelectedIndex = _middleIndex; } else { cbbCarton.Enabled = false; cbbCarton.Text = ""; } } } catch { } if (function.BOX_LOT_CODE == false) { chbSerial.Checked = false; } else { chbSerial.Checked = true; } }