Пример #1
0
        private void txtCost_Leave(object sender, EventArgs e)
        {
            decimal price = CostCodeController.CodeToCost(txtCost.Text);

            txtCash.Text   = (price + price / 100 * 60).ToString();
            txtMarkup.Text = (price + price / 100 * 60).ToString();
            txtCredit.Text = (price + price / 100 * 60).ToString();
        }
Пример #2
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     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);
     controller.UpdateProduct();
     this.Close();
 }
Пример #3
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);
            }
        }