Ejemplo n.º 1
0
 private void txtBarcode_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         try
         {
             P = ProductsBLL.CheckProductCodeExistance(txtBarcode.Text);
             if (P == null)
             {
                 btnSaveProduct.Enabled = true;
                 P = OpenFoodFactsAPI.GetProductDetails(txtBarcode.Text);
                 if (P != null)
                 {
                     lblItemName.Text      = P.PRODUCT_NAME;
                     picProductImage.Image = P.PRODUCT_IMAGE;
                     picProductImage.AdjustPictureBox();
                 }
                 else
                 {
                     MessageBox.Show("Product Not found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                 }
             }
             else
             {
                 btnSaveProduct.Enabled = false;
                 lblItemName.Text       = P.PRODUCT_NAME;
                 picProductImage.Image  = P.PRODUCT_IMAGE;
                 picProductImage.AdjustPictureBox();
                 DialogResult Res = MessageBox.Show("This Product is already Exists, do you want to add new expiry date for it? (Y/N)", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                 if (Res == DialogResult.Yes)
                 {
                     btnProductExpiryDates_Click(btnProductExpiryDates, null);
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
         }
     }
 }
Ejemplo n.º 2
0
 private void txtBarcode_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         P = ProductsBLL.CheckProductCodeExistance(txtBarcode.Text);
         if (P == null)
         {
             DialogResult Res = MessageBox.Show("This Product is not Exists, do you want to Create it? (Y/N)", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
             if (Res == DialogResult.Yes)
             {
                 frmNewProduct frm = new frmNewProduct(txtBarcode.Text);
                 frm.ShowDialog();
             }
         }
         else
         {
             lblItemName.Text      = P.PRODUCT_NAME;
             picProductImage.Image = P.PRODUCT_IMAGE;
             picProductImage.AdjustPictureBox();
             lblExpiryDate.Text = ProductExpiryDatesBLL.GetNearestProductExpiryDate(P.PRODUCT_ID).ToString();
         }
     }
 }