private void dtgListProduct_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            ListProduct product = new ListProduct();

            product.STT = Convert.ToInt32(this.dtgListProduct.CurrentRow.Cells[0].Value.ToString());
            if (product.STT <= 0)
            {
                return;
            }
            if (this.dtgListProduct.CurrentRow.Cells[1].Value is null)
            {
                this.dtgListProduct.CurrentRow.Cells[1].Value = "";
            }
            product.ProductID = this.dtgListProduct.CurrentRow.Cells[1].Value.ToString();
            if (this.dtgListProduct.CurrentRow.Cells[2].Value is null)
            {
                this.dtgListProduct.CurrentRow.Cells[2].Value = "";
            }
            product.ProductType = this.dtgListProduct.CurrentRow.Cells[2].Value.ToString();
            if (this.dtgListProduct.CurrentRow.Cells[3].Value is null)
            {
                this.dtgListProduct.CurrentRow.Cells[3].Value = "";
            }
            product.ProductName = this.dtgListProduct.CurrentRow.Cells[3].Value.ToString();
            QRController.UpdateQRProduct(product);
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.dtgListProduct.SelectedRows.Count <= 0)
            {
                return;
            }
            if (this.dtgListProduct.SelectedRows[0].Cells[1].Value is null)
            {
                MessageBox.Show("Không có giá trị để xoá", "Thông báo", MessageBoxButtons.OK);
            }
            else
            {
                ListProduct product = QRController.getProduct(this.dtgListProduct.SelectedRows[0].Cells[1].Value.ToString());
                if (QRController.DeleteProduct(product) == false)
                {
                    MessageBox.Show("Lỗi xoá sản phẩm", "Thông báo", MessageBoxButtons.OK);
                    return;
                }
            }

            BindingSource source = new BindingSource();

            source.DataSource = QRController.getListProduct();
            this.dtgListProduct.DataSource = source;

            this.btnDelete.Enabled = false;
        }
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            BindingSource source = new BindingSource();

            source.DataSource = QRController.getListProduct();
            this.dtgListProduct.DataSource = source;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            string lblProductIDCut = lblProductID.Text.Replace(" ", "");
            string ProductIDCut    = lblProductIDCut.Trim() + txtProductID.Text;

            if (QRController.getProduct(ProductIDCut) != null)
            {
                MessageBox.Show("Sản phẩm này đã tồn tại", "Thông báo", MessageBoxButtons.OK);
                return;
            }

            ListProduct product = new ListProduct();

            product.ProductID   = ProductIDCut;
            product.ProductType = this.cbxProductType.Text;
            product.ProductName = this.txtProductName.Text;
            if (QRController.AddProduct(product) == false)
            {
                MessageBox.Show("Lỗi thêm sản phẩm", "Thông báo", MessageBoxButtons.OK);
                return;
            }

            BindingSource source = new BindingSource();

            source.DataSource = QRController.getListProduct();
            this.dtgListProduct.DataSource = source;
            this.btnSave.Enabled           = false;
        }
 private void OnQRCodeScanned(QRController obj, string code)
 {
     if (webtalk.is_code_level_unlock(code))
     {
         qr_controller.enabled = false;
         webtalk.add_score(code);
     }
 }
        public FormMain()
        {
            InitializeComponent();
            BindingSource source = new BindingSource();

            source.DataSource = QRController.getListProduct();
            this.dtgListProduct.DataSource = source;
        }
 public void Start()
 {
     if (webtalk == null)
     {
         webtalk = new WebTalk();
         webtalk.OnScoreAdded  += OnScoreAdded;
         webtalk.OnScoreFailed += OnScoreFailed;
     }
     qr_controller                  = GetComponent <QRController>();
     qr_controller.enabled          = false;
     qr_controller.OnQRCodeScanned += OnQRCodeScanned;
 }
 private void dtgListProduct_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyData == Keys.Delete)
     {
         if (this.dtgListProduct.SelectedRows.Count > 0)
         {
             ListProduct product = QRController.getProduct(this.dtgListProduct.SelectedRows[0].Cells[1].Value.ToString());
             if (QRController.DeleteProduct(product) == false)
             {
                 MessageBox.Show("Lỗi xoá sản phẩm", "Thông báo", MessageBoxButtons.OK);
                 return;
             }
         }
     }
 }
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            DBQuanLyMaQREntities db = new DBQuanLyMaQREntities();

            if (this.txtSearch.Text.Trim().Length <= 0)
            {
                BindingSource source = new BindingSource();
                source.DataSource = QRController.getListProduct();
                this.dtgListProduct.DataSource = source;
            }
            else
            {
                dtgListProduct.DataSource = db.ListProduct.Where(x => x.ProductName.Contains(txtSearch.Text) || x.ProductID.Contains(txtSearch.Text)).ToList();
            }
        }
    void Start()
    {
        Levels = new level_info[2];
        if (webtalk == null)
        {
            webtalk = new WebTalk();
            webtalk.OnScoreAdded  += OnScoreAdded;
            webtalk.OnScoreFailed += OnScoreFailed;
        }

        MainMenu.SetActive(true);
        LevelSelector.SetActive(false);
        EllieSelector.SetActive(false);
        Level1IMG.color = new Color(255, 255, 255, 50);
        Level1IMG.GetComponent <Button>().interactable = false;
        Level1txt.text = "locked";
        Levels[0]      = new level_info("Level 1", Level1IMG, Level1txt, false);

        /*Level2IMG.color = new Color(255, 255, 255, 50);
         * Level2IMG.GetComponent<Button>().interactable = false;
         * Level2txt.text = "locked";
         * Levels[1] = new level_info("Level 2", Level2IMG, Level2txt, false);*/
        PlayLevelBtn.SetActive(false);

        ScanQRBtn.SetActive(true);
        qr_controller                  = ScanQRBtn.GetComponent <QRController>();
        qr_controller.enabled          = false;
        qr_controller.OnQRCodeScanned += OnQRCodeScanned;

        try
        {
            gamemanager = GameObject.Find("GameManager").GetComponent <GameManager>();
        }
        catch
        {
            gamemanager = null;
        }
    }
Exemple #11
0
    public void Decode()
    {
        string resultStr = QRController.DecodeByStaticPic(targetTex);

        resultText.text = resultStr;
    }