示例#1
0
        private void textBox_LotCode_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                textBox_LotCode.Text = "";
                textBox_LotCode.Text = scannedCode.ToString();
                scannedCode.Clear();

                using (conn = new SQLiteConnection(connStr))
                {
                    conn.Open();
                    codeCURD = new BarcodeReferenceCode_CRUD(conn);

                    BarcodeLotCodeInfo item = new BarcodeLotCodeInfo();
                    var id = codeCURD.GetMaxID(BarcodeReferenceCode_CRUD.Table.LOT_CODE) + 1;
                    item.ID      = id;
                    item.LotCode = textBox_LotCode.Text;

                    codeCURD.Insert(item);

                    ds = codeCURD.SelectAll_Dataset(BarcodeReferenceCode_CRUD.Table.LOT_CODE);
                    conn.Close();
                }

                DataGridViewRefreshBinding(BarcodeReferenceCode_CRUD.Table.LOT_CODE);
            }
            else
            {
                textBox_LotCode.Text = "";
                scannedCode.Append(KeyToUni.KeyCodeToUnicode(e.KeyCode).ToUpper());
            }
        }
示例#2
0
        private void InitializeDatabaseConfig()
        {
            string currentFolder = Environment.CurrentDirectory;
            string path          = Path.Combine(currentFolder, "BarcodeDatabase.sqlite");

            connStr = "Data Source=" + path + ";" + "version=3;";

            using (conn = new SQLiteConnection(connStr))
            {
                conn.Open();
                codeCURD = new BarcodeReferenceCode_CRUD(conn);
                ds       = codeCURD.SelectAll_Dataset(BarcodeReferenceCode_CRUD.Table.MASTER_CODE);
                conn.Close();
            }
        }
示例#3
0
        private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (tabControl.SelectedIndex)
            {
            case 0:     //master
                using (conn = new SQLiteConnection(connStr))
                {
                    conn.Open();
                    codeCURD = new BarcodeReferenceCode_CRUD(conn);
                    ds       = codeCURD.SelectAll_Dataset(BarcodeReferenceCode_CRUD.Table.MASTER_CODE);
                    conn.Close();
                }
                DataGridViewRefreshBinding(BarcodeReferenceCode_CRUD.Table.MASTER_CODE);
                break;

            case 1:     //box
                using (conn = new SQLiteConnection(connStr))
                {
                    conn.Open();
                    codeCURD = new BarcodeReferenceCode_CRUD(conn);
                    ds       = codeCURD.SelectAll_Dataset(BarcodeReferenceCode_CRUD.Table.BOX_CODE);
                    conn.Close();
                }
                DataGridViewRefreshBinding(BarcodeReferenceCode_CRUD.Table.BOX_CODE);
                break;

            case 2:     //lot
                using (conn = new SQLiteConnection(connStr))
                {
                    conn.Open();
                    codeCURD = new BarcodeReferenceCode_CRUD(conn);
                    ds       = codeCURD.SelectAll_Dataset(BarcodeReferenceCode_CRUD.Table.LOT_CODE);
                    conn.Close();
                }
                DataGridViewRefreshBinding(BarcodeReferenceCode_CRUD.Table.LOT_CODE);
                break;

            default:
                break;
            }
        }
示例#4
0
        private void button_LotDelete_Click(object sender, EventArgs e)
        {
            var index = dataGridView.CurrentCell.RowIndex;
            var id    = dataGridView[0, index];
            var code  = dataGridView[1, index];

            BarcodeLotCodeInfo item = new BarcodeLotCodeInfo();

            item.ID      = (int)id.Value;
            item.LotCode = (string)code.Value;

            using (conn = new SQLiteConnection(connStr))
            {
                conn.Open();
                codeCURD = new BarcodeReferenceCode_CRUD(conn);
                codeCURD.Delete(item);
                ds = codeCURD.SelectAll_Dataset(BarcodeReferenceCode_CRUD.Table.LOT_CODE);
                conn.Close();
            }

            DataGridViewRefreshBinding(BarcodeReferenceCode_CRUD.Table.LOT_CODE);
        }
        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;
            }
        }