Beispiel #1
0
        private void btnCopyRecipe_Click(object sender, EventArgs e)
        {
            if (_masterRecipe == null)
            {
                return;
            }

            DialogResult result = AppUtility.ShowKryptonMessageBox("Confirm copy recipe", "All current recipe data will replace with replace with master copy recipe", "",
                                                                   ComponentFactory.Krypton.Toolkit.TaskDialogButtons.Yes | ComponentFactory.Krypton.Toolkit.TaskDialogButtons.No, MessageBoxIcon.Question, this);

            if (result != DialogResult.OK)
            {
                return;
            }


            AppProductRecipe masterCopy = _masterRecipe.ShallowClone(typeof(AppProductRecipe)) as AppProductRecipe;

            masterCopy.Name = AppMachine.Comp.AppMachine.This.CurrentRecipe.Name;
            masterCopy.CopyPropertyTo(AppMachine.Comp.AppMachine.This.CurrentRecipe);


            pgRecipe.BrowsableAttributes = new AttributeCollection(new CategoryAttribute("Product Recipe"));
            //pgRecipe.BrowsableAttributes = new AttributeCollection(new SubCategoryAttribute("General Recipe"));

            pgRecipe.SelectedObject = AppMachine.Comp.AppMachine.This.CurrentRecipe;
            AppMachine.Comp.AppMachine.This.CurrentProdRecipeName = "";
            AppMachine.Comp.AppMachine.This.CurrentProdRecipeName = masterCopy.Name;

            _masterRecipe = null;
            cbMasterCopyRecipe.Items.Clear();
            cbMasterCopyRecipe.Text = "";
        }
        public void RecipePropValue_OnChange(object sender, PropertyChangedEventArgs e)
        {
            if (sender == null)
            {
                return;
            }

            AppProductRecipe recipeChanged = sender as AppProductRecipe;

            //Clone data to reference recipe
            if (recipeChanged.Name == this.CurrentRecipe.Name)
            {
                AppProductRecipe masterCopy = recipeChanged.ShallowClone(typeof(AppProductRecipe)) as AppProductRecipe;
                masterCopy.Name = AppConstStaticName.REF_CURRENT_RECIPE;
                masterCopy.CopyPropertyTo(_refCurrentRecipe);
            }
            //Copy to Current Recipe
            else if (recipeChanged.Name == AppConstStaticName.REF_CURRENT_RECIPE)
            {
                AppProductRecipe masterCopy = recipeChanged.ShallowClone(typeof(AppProductRecipe)) as AppProductRecipe;
                masterCopy.Name = this.CurrentRecipe.Name;
                masterCopy.CopyPropertyTo(this.CurrentRecipe);
            }
        }