Example #1
0
        //  Commit to database - new product
        private void saveNewProductInformationToDb()
        {
            //Save the product that was just created. Check whether the product saved correctly.
            int id = SqliteDAProduct.SaveProductAndGetId(this.product);

            if (id != 0)
            {
                DialogResult dialogResult = MessageBox.Show("New product created successfully", "New Product",
                                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (dialogResult == DialogResult.OK)
                {
                    //Set the product id variable equal to the product id saved to the database. The forms product id can be accessed by other forms that need it.
                    this.product.Id = id;
                    if (barcodeComboBox.Text != "")
                    {
                        BarcodeModel barcode = new BarcodeModel();
                        barcode.Barcode   = barcodeComboBox.Text;
                        barcode.ProductId = id;
                        SqliteDataAccessBarcode.SaveBarcode(barcode);
                    }
                    this.Close();
                }
            }
            else if (id == 0)
            {
                MessageBox.Show("Something went wrong. New product could not be saved.\nCheck the error log for more information.", "New Product Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
 private void AddProductToInvoice()
 {
     productId = Convert.ToInt32(row.Cells["Id"].Value);
     if (barcode != "")
     {
         BarcodeModel barcode = new BarcodeModel();
         barcode.Barcode   = this.barcode;
         barcode.ProductId = productId;
         SqliteDataAccessBarcode.SaveBarcode(barcode);
     }
     this.Close();
 }
Example #3
0
 //  Commit to database - new barcode
 private void saveNewBarcodeInformationToDb()
 {
     if (SqliteDataAccessBarcode.SaveBarcode(barcode))
     {
         DialogResult dialogResult = MessageBox.Show("New Barcode created successfully", "New Barcode",
                                                     MessageBoxButtons.OK, MessageBoxIcon.Information);
         if (dialogResult == DialogResult.OK)
         {
             this.Close();
         }
     }
     else
     {
         MessageBox.Show("Something went wrong. New barcode could not be saved.", "New Category Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #4
0
        //  5. Delete Barcode Button Click
        private void deleteBarcodeButton_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this barcode?",
                                                        "Delete Barcode", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);

            if (dialogResult == DialogResult.Yes)
            {
                if (SqliteDataAccessBarcode.DeleteBarcodeById(Convert.ToInt32(barcodeComboBox.SelectedValue)))
                {
                    DialogResult dialog = MessageBox.Show("Barcode was successfully deleted.", "Delete Barcode",
                                                          MessageBoxButtons.OK, MessageBoxIcon.Information);
                    loadBarcodeComboBox();
                    barcodeComboBox.ResetText();
                }
                else
                {
                    DialogResult dialog = MessageBox.Show("Something went wrong. Barcode could not be deleted.\nCheck the error log for more information.",
                                                          "Delete Barcode Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Example #5
0
 //  Other Methods
 //******************************************************************************************************
 //  Wire up the barcode combo box with a list of barcodes for this product from the database.
 private void loadBarcodeComboBox()
 {
     barcodeComboBox.DataSource    = SqliteDataAccessBarcode.GetBarcodesByProductId(this.existingProduct.Id);
     barcodeComboBox.DisplayMember = "Barcode";
     barcodeComboBox.ValueMember   = "Id";
 }