Exemple #1
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     BarcodeController.print_barcode(int.Parse(txtId.Text), int.Parse(txtQty.Text));
     BarcodeController.print_barcode_preview(int.Parse(txtId.Text));
 }
Exemple #2
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            try
            {
                if (PermissionController.CheckPermission(PermissionType.PRODUCT_ADD))
                {
                    if (MessageHelper.AlertRegisterConfirmation() == DialogResult.Yes)
                    {
                        Product product = new Product();
                        product.Name         = txtName.Text;
                        product.Description  = txtDescription.Text;
                        product.Category     = (Category)cmbCategory.SelectedItem;
                        product.BarcodeData  = txtBarcode.Text;
                        product.ReOrderLevel = decimal.Parse(txtReOrder.Text);


                        ProductBatch batch = new ProductBatch();
                        batch.Cost   = CostCodeController.CodeToCost(txtCost.Text);
                        batch.Cash   = decimal.Parse(txtCash.Text);
                        batch.Credit = decimal.Parse(txtCredit.Text);
                        batch.Markup = decimal.Parse(txtMarkup.Text);
                        batch.Stock  = decimal.Parse(txtStock.Text);

                        if (product.BarcodeData == "")
                        {
                            context.Products.Add(product);
                            context.SaveChanges();
                            product.BarcodeData  = product.Id.ToString();
                            product.BarcodeImage = BarcodeController.GetBarcodeBytes(product.BarcodeData.ToString());
                            context.SaveChanges();
                            batch.Product = product;
                            context.ProductBatches.Add(batch);
                            context.SaveChanges();
                            MessageHelper.AlertRegisterSuccess();
                        }
                        else
                        {
                            context.Products.Add(product);
                            context.SaveChanges();
                            batch.Product = product;
                            context.ProductBatches.Add(batch);
                            context.SaveChanges();
                            MessageHelper.AlertRegisterSuccess();
                        }

                        if (MessageBox.Show("Do you want to print Labels", "Labels", MessageBoxButtons.YesNo) ==
                            DialogResult.Yes)
                        {
                            if (MessageBox.Show("Do you want to Double the Labels", "Labels", MessageBoxButtons.YesNo) ==
                                DialogResult.Yes)
                            {
                                BarcodeController.print_barcode(product.Id, int.Parse((batch.Stock * 2).ToString()));
                                // BarcodeController.print_barcode_preview(product.Id);
                            }
                            else
                            {
                                BarcodeController.print_barcode(product.Id, int.Parse(batch.Stock.ToString()));
                                //BarcodeController.print_barcode_preview(product.Id);
                            }
                        }

                        Helper.ClearForm.ClearAllTextFields(this);
                        txtDescription.Text = "-";
                        txtReOrder.Text     = "0";
                        txtName.Focus();
                    }
                }
                else
                {
                    throw new Exception("Access Denied! (PRODUCT_ADD)");
                }
            }
            catch (Exception ex)
            {
                MessageHelper.AlertError(ex.Message);
            }
        }