Beispiel #1
0
        private void strUserInputCode_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (String.IsNullOrEmpty(strUserInputCode.Text))
                {
                    return;
                }

                bool success = VerifyUser();
                if (success)
                {
                    this.Hide();
                    string message = String.Format("User Change to User: {0} En: {1} Level: {2}", AppMachine.This.CurrentUser.UserName, AppMachine.This.CurrentUser.UserEN, AppMachine.This.CurrentUser.UserLevel);
                    U.LogInfo(message);
                    AppUtility.ShowKryptonMessageBox("User Change Completed", "User Change Completed", message, TaskDialogButtons.OK, MessageBoxIcon.Information, this);
                }
                else
                {
                    string message = String.Format("Could not find user code: {0} ", strUserInputCode.Text);
                    this.Hide();
                    AppUtility.ShowKryptonMessageBox("User Change Fail", "User Change Fail", message, TaskDialogButtons.OK, MessageBoxIcon.Error, this);

                    strUserInputCode.Clear();
                    this.Show();
                }
            }
        }
        private void btnAddRecipe_Click(object sender, EventArgs e)
        {
            if (tbNewRecipe.Text == "")
            {
                AppUtility.ShowKryptonMessageBox("No Recipe Name", "Please input recipe name", "", ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Error, this);
                return;
            }

            if (_allRecipe.ChildExists(tbNewRecipe.Text))
            {
                AppUtility.ShowKryptonMessageBox("Recipe Name Exist", String.Format("Recipe name \"{0}\" already exist.", tbNewRecipe.Text), "", ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Error, this);
                return;
            }

            try
            {
                AppProductRecipe newRecipe = new AppProductRecipe(tbNewRecipe.Text);
                newRecipe.PropertyValChanged += new PropertyChangedEventHandler(AppMachine.Comp.AppMachine.This.RecipePropValue_OnChange);
                _allRecipe.Add(newRecipe);
                componentBrowser.Rebuild(_allRecipe);
                AppUtility.ShowKryptonMessageBox("Add New Product Completed", String.Format("Add New Product \"{0}\" Completed", tbNewRecipe.Text), "", ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Information, this);
                tbNewRecipe.Clear();
            }
            finally
            {
            }
        }
Beispiel #3
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 = "";
        }
Beispiel #4
0
        private void btnDelUser_Click(object sender, EventArgs e)
        {
            if (cbDelUser.SelectedItem != null &&
                _allUsers.ChildExists(cbDelUser.SelectedItem.ToString()))
            {
                DialogResult result = AppUtility.ShowKryptonMessageBox("Remove User", String.Format("Confirm to remove user \"{0}\".", cbDelUser.SelectedItem.ToString()), "",
                                                                       ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK | ComponentFactory.Krypton.Toolkit.TaskDialogButtons.Cancel, MessageBoxIcon.Question, this);

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

                if (cbDelUser.SelectedItem.ToString() == AppMachine.Comp.AppMachine.This.CurrentUser.UserName ||
                    cbDelUser.SelectedItem.ToString() == AppConstStaticName.ADMIN_USER || cbDelUser.SelectedItem.ToString() == AppConstStaticName.GUEST_USER)
                {
                    AppUtility.ShowKryptonMessageBox("Remove User", String.Format("Unable to remove active user \"{0}\" ", cbDelUser.SelectedItem.ToString()), "", ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Information, this);
                    return;
                }


                try
                {
                    _allUsers.Remove(cbDelUser.SelectedItem as CompBase);
                    componentBrowser.Rebuild(_allUsers);
                    AppUtility.ShowKryptonMessageBox("Remove User", String.Format("User \"{0}\" Removed", cbDelUser.SelectedItem.ToString()), "", ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Information, this);

                    cbDelUser.Items.Clear();
                    cbDelUser.Text = "";
                }
                finally
                {
                }
            }
        }
Beispiel #5
0
        private void btnAddUser_Click(object sender, EventArgs e)
        {
            if (tbNewUser.Text == "")
            {
                AppUtility.ShowKryptonMessageBox("No User Name", "Please input user name", "", ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Error, this);
                return;
            }

            if (_allUsers.ChildExists(tbNewUser.Text))
            {
                AppUtility.ShowKryptonMessageBox("Duplicate User Name", String.Format("User name \"{0}\" already exist.", tbNewUser.Text), "", ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Error, this);
                return;
            }

            try
            {
                DefaultLogger logger = U.GetComponent(AppConstStaticName.DEFAULT_LOGGER) as DefaultLogger;
                logger.Abort();
                AppUserInfo newUser = new AppUserInfo(tbNewUser.Text);
                newUser.Initialize();
                _allUsers.Add(newUser);
                newUser.InitializeIDReferences();
                logger.Abort();
                componentBrowser.Rebuild(_allUsers);
                AppUtility.ShowKryptonMessageBox("Add New User Completed", String.Format("Add New User \"{0}\" Completed", tbNewUser.Text), "", ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Information, this);
                tbNewUser.Clear();
            }
            finally
            {
            }
        }
        private void btnExportRecipe_Click(object sender, EventArgs e)
        {
            if (cbDelRecipe.SelectedItem != null &&
                _allRecipe.ChildExists(cbDelRecipe.SelectedItem.ToString()))
            {
                string recipeDumpPath = AppUtility.AppFullPath + "\\Dump Recipes\\";
                U.EnsureDirectory(recipeDumpPath);
                AppProductRecipe exportRecipe   = cbDelRecipe.SelectedItem as AppProductRecipe;
                string           exportFilePath = String.Format("{0}DumpRecipe[ {1} ]_{2}.xml", recipeDumpPath, exportRecipe.Name, DateTime.Now.ToString("yyyy-MM-dd-HHmmss"));
                CompRoot.ExportSettings(exportFilePath, exportRecipe);

                AppUtility.ShowKryptonMessageBox("Export Recipe Completed", String.Format("Export Recipe \"{0}\" Completed", exportRecipe.Name), String.Format("Export Recipe {0} to {1}", exportRecipe.Name, exportFilePath),
                                                 ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Information, this);
            }
        }
        private void btnDelRecipe_Click(object sender, EventArgs e)
        {
            if (cbDelRecipe.SelectedItem != null &&
                _allRecipe.ChildExists(cbDelRecipe.SelectedItem.ToString()))
            {
                DialogResult result = AppUtility.ShowKryptonMessageBox("Remove Recipe", String.Format("Confirm to remove recipe \"{0}\".", cbDelRecipe.SelectedItem.ToString()), "",
                                                                       ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK | ComponentFactory.Krypton.Toolkit.TaskDialogButtons.Cancel, MessageBoxIcon.Question, this);

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

                if (cbDelRecipe.SelectedItem.ToString() == AppMachine.Comp.AppMachine.This.CurrentProdRecipeName ||
                    cbDelRecipe.SelectedItem.ToString() == AppConstStaticName.SAMPLE_RECIPE ||
                    cbDelRecipe.SelectedItem.ToString() == AppConstStaticName.REF_CURRENT_RECIPE)
                {
                    AppUtility.ShowKryptonMessageBox("Remove Recipe", String.Format("Unable to remove active recipe \"{0}\" ", cbDelRecipe.SelectedItem.ToString()), "", ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Error, this);
                    return;
                }


                try
                {
                    (cbDelRecipe.SelectedItem as AppProductRecipe).PropertyValChanged -= new PropertyChangedEventHandler(AppMachine.Comp.AppMachine.This.RecipePropValue_OnChange);
                    _allRecipe.Remove(cbDelRecipe.SelectedItem as CompBase);
                    componentBrowser.Rebuild(_allRecipe);
                    AppUtility.ShowKryptonMessageBox("Remove Recipe", String.Format("Recipe \"{0}\" Removed", cbDelRecipe.SelectedItem.ToString()), "", ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Information, this);
                    cbDelRecipe.Items.Clear();
                    cbDelRecipe.Text = "";
                }
                finally
                {
                }
            }
        }
        private void btnImportRecipe_Click(object sender, EventArgs e)
        {
            string recipeDumpPath = AppUtility.AppFullPath + "\\Dump Recipes\\";

            U.EnsureDirectory(recipeDumpPath);
            OpenFileDialog od = new OpenFileDialog();

            od.DefaultExt       = ".xml";
            od.Filter           = "Product File|*.xml";
            od.InitialDirectory = recipeDumpPath;
            od.CheckFileExists  = true;
            od.Multiselect      = false;
            od.ShowDialog();
            if (String.IsNullOrEmpty(od.FileName))
            {
                return;
            }

            string           importFilePath = od.FileName;
            AppProductRecipe importRecipe   = null;

            try
            {
                importRecipe = CompRoot.ImportFile(typeof(AppProductRecipe), importFilePath) as AppProductRecipe;
            }
            catch (Exception ex)
            {
                AppUtility.ShowKryptonMessageBox("Import Recipe Error", String.Format("Import Recipe Error"), ex.ToString(), ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Error, this);
                return;
            }


            if (_allRecipe.ChildExists(importRecipe.Name))
            {
                DialogResult result = AppUtility.ShowKryptonMessageBox("Recipe Name Exist", String.Format("Recipe name \"{0}\" already exist.", importRecipe.Name),
                                                                       "Do you want to auto generate unique name?", ComponentFactory.Krypton.Toolkit.TaskDialogButtons.Yes | ComponentFactory.Krypton.Toolkit.TaskDialogButtons.No, MessageBoxIcon.Question, this);
                if (result != DialogResult.Yes)
                {
                    return;
                }

                int    count             = 1;
                string autoGenRecipeName = "";
                do
                {
                    autoGenRecipeName = importRecipe.Name + count.ToString("_00#");
                } while (_allRecipe.ChildExists(autoGenRecipeName));
                importRecipe.Name = autoGenRecipeName;
            }

            try
            {
                importRecipe.PropertyValChanged += new PropertyChangedEventHandler(AppMachine.Comp.AppMachine.This.RecipePropValue_OnChange);
                _allRecipe.Add(importRecipe);
                componentBrowser.Rebuild(_allRecipe);
                AppUtility.ShowKryptonMessageBox("Import Recipe Completed", String.Format("Import Recipe \"{0}\" Completed", importRecipe.Name), "", ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Information, this);
                tbNewRecipe.Clear();
            }
            finally
            {
            }
        }