private void btnRecipeEdit_Click(object sender, EventArgs e) { if (this.SelectedRecipeInfo.RecipeNo == 0 || this.SelectedRecipeInfo.RecipeID == "RecipeID") { MessageBox.Show(ResourceHelper.Language.GetString("SelectRecipeMsg")); return; } RecipeInfo recipeInfo = new RecipeInfo(); EditorRecipeForm editorRecipeForm = new EditorRecipeForm(this.SelectedRecipeInfo, recipeInfo); editorRecipeForm.Text = ((Button)sender).Text == "Create" ? "Recipe Create" : "Recipe Edit"; if (editorRecipeForm.ShowDialog() == DialogResult.OK) { if (RecipeInfoManager.GetInstance().EditRecipeInfo(this.SelectedRecipeInfo, recipeInfo)) { //RefreshRecipeInfoCollection(); } } }
private void btnRecipeCopy_Click(object sender, EventArgs e) { if (this.SelectedRecipeInfo.RecipeNo == 0 || this.SelectedRecipeInfo.RecipeID == "RecipeID") { MessageBox.Show(ResourceHelper.Language.GetString("SelectRecipeMsg")); return; } RecipeInfo recipeInfo = new RecipeInfo(); recipeInfo.RecipeNo = RecipeNoGenerator(); CopyRecipeForm copyRecipeForm = new CopyRecipeForm(this.SelectedRecipeInfo, recipeInfo); if (copyRecipeForm.ShowDialog() == DialogResult.OK) { if (RecipeInfoManager.GetInstance().CopyRecipeInfo(this.SelectedRecipeInfo, recipeInfo)) { //RefreshRecipeInfoCollection(); } } }
private void RecipeEditorControl_Load(object sender, EventArgs e) { if (ProcessInfo.IsDesignMode()) { return; } _recipeInfoCollection = new RecipeInfoCollection(); this.SelectedRecipeInfo = new RecipeInfo(); RecipeInfoManager.GetInstance().RecipeInfoSelectedIndexChanged += new RecipeInfoManager.RecipeInfoSelectedIndexChangedEventHandler(RecipeEditorControl_RecipeInfoSelectedIndexChangedEvent); RecipeInfoManager.GetInstance().RecipeInfoCollectionChanged += new RecipeInfoManager.RecipeInfoCollectionChangedEventHandler(RecipeEditorControl_RecipeInfoCollectionChangedEvent); RecipeInfoManager.GetInstance().RecipeInfoCopyChanged += new RecipeInfoManager.RecipeInfoCopyChangedEventHandler(RecipeEditorControl_RecipeInfoCopyChangedEvent); RefreshRecipeInfoCollection(); RecipeInfo actRecipeInfo = RecipeInfoManager.GetInstance().ActiveRecipe; if (actRecipeInfo != null) { RefreshRecipeStatus(actRecipeInfo.RecipeNo.ToString("D3"), actRecipeInfo.RecipeID); } LanguageManager.Apply(this); }
private void RefreshRecipeStatus(string recipeNo, string recipeID) { this.lblRecipeNo.Text = string.Format("Recipe No:{0}", recipeNo); this.lblRecipeID.Text = string.Format("Recipe ID:{0}", recipeID); if (recipeNo == RecipeInfoManager.GetInstance().ActiveRecipe.RecipeNo.ToString("D3") && recipeID == RecipeInfoManager.GetInstance().ActiveRecipe.RecipeID) { this.lblRecipeNo.ForeColor = Color.FromKnownColor(KnownColor.Red); this.lblRecipeID.ForeColor = Color.FromKnownColor(KnownColor.Red); } else { this.lblRecipeNo.ForeColor = Color.FromKnownColor(KnownColor.ControlText); this.lblRecipeID.ForeColor = Color.FromKnownColor(KnownColor.ControlText); } for (int i = 0; i < _recipeInfoCollection.Count; i++) { if (recipeID == _recipeInfoCollection[i].RecipeID) { this.cboCurrentRecipeChange.SelectedItem = _recipeInfoCollection[i]; } } }
private void btnRecipeDelete_Click(object sender, EventArgs e) { if (this.SelectedRecipeInfo.RecipeNo == 0 || this.SelectedRecipeInfo.RecipeID == "RecipeID") { MessageBox.Show(ResourceHelper.Language.GetString("SelectRecipeMsg")); return; } RecipeInfo activeRecipe = RecipeInfoManager.GetInstance().ActiveRecipe; if (this.SelectedRecipeInfo.RecipeNo == activeRecipe.RecipeNo || this.SelectedRecipeInfo.RecipeID == activeRecipe.RecipeID) { MessageBox.Show(ResourceHelper.Language.GetString("DeleteRecipeMsg")); return; } if (RecipeInfoManager.GetInstance().DeleteRecipeInfo(this.SelectedRecipeInfo)) { if (DeleteRecipeInfoEvent != null) { DeleteRecipeInfoEvent(); } //RefreshRecipeInfoCollection(); } }
private void btnRecipeChange_Click(object sender, EventArgs e) { //v1.0.2.31 避免短時間內重複切換Recipe if (this.ChangeRecipeTimeInterval > 0 && (DateTime.Now - _lastRecipeChangeTime).TotalSeconds < this.ChangeRecipeTimeInterval) { MessageBox.Show(ResourceHelper.Language.GetString("ChagneRecipeRepeatMsg")); return; } _lastRecipeChangeTime = DateTime.Now; if (this.cboCurrentRecipeChange.SelectedItem == null) { MessageBox.Show(ResourceHelper.Language.GetString("SelectRecipeMsg")); return; } RecipeInfo recipeInfo = (RecipeInfo)this.cboCurrentRecipeChange.SelectedItem; if (MessageBox.Show(string.Format("{0} {1:000} {2}", ResourceHelper.Language.GetString("ChangeRecipeMsg1"), recipeInfo, ResourceHelper.Language.GetString("ChangeRecipeMsg2")), "", MessageBoxButtons.OKCancel) == DialogResult.OK) { if (RecipeInfoManager.GetInstance().SetRecipeNo(recipeInfo.RecipeNo)) { } } }
private void RecipeListSelectForm_Load(object sender, EventArgs e) { this.dataGridView.DataSource = RecipeInfoManager.GetInstance().RecipeInfoCollection; }
private void RecipeEditorForm_Load(object sender, EventArgs e) { RecipeInfoManager.GetInstance().RecipeInfoSelectedIndexChanged += new RecipeInfoManager.RecipeInfoSelectedIndexChangedEventHandler(RecipeEditorForm_RecipeInfoSelectedIndexChangedEvent); }
private void RefreshRecipeInfoCollection() { if (this.InvokeRequired) { this.Invoke(new Action(RefreshRecipeInfoCollection)); return; } try { _recipeInfoCollection = RecipeInfoManager.GetInstance().GetRecipeInfoCollection(); this.dgvRecipeList.Rows.Clear(); this.dgvRecipeList.Columns.Clear(); this.dgvRecipeList.Columns.AddRange(new DataGridViewColumn[] { new DataGridViewTextBoxColumn() { HeaderText = "RecipeNo", Name = "RecipeNo", ReadOnly = true, Width = 55 }, new DataGridViewTextBoxColumn() { HeaderText = "RecipeID", Name = "RecipeID", ReadOnly = true, Width = 120 }, new DataGridViewTextBoxColumn() { HeaderText = "Description", Name = "Description", ReadOnly = true, Width = 160 }, new DataGridViewTextBoxColumn() { HeaderText = "ModifyTime", Name = "ModifyTime", ReadOnly = true, Width = 120 } }); foreach (RecipeInfo recipeInfo in _recipeInfoCollection) { this.dgvRecipeList.Rows.Add( string.Format("{0:D3}", recipeInfo.RecipeNo), recipeInfo.RecipeID, recipeInfo.Description, recipeInfo.ModifyTime.ToString("yyyy.MM.dd HH:mm:ss")); } this.cboCurrentRecipeChange.DataSource = null; this.cboCurrentRecipeChange.DataSource = _recipeInfoCollection; if (this.cboCurrentRecipeChange.SelectedIndex == -1) { this.SelectedRecipeInfo = null; this.lblRecipeNo.Text = ""; this.lblRecipeID.Text = ""; RefreshRecipeStatus("", ""); } else { this.SelectedRecipeInfo = (RecipeInfo)this.cboCurrentRecipeChange.SelectedItem; this.lblRecipeNo.Text = string.Format("Recipe No:{0:D3}", this.SelectedRecipeInfo.RecipeNo); this.lblRecipeID.Text = string.Format("Recipe ID:{0}", this.SelectedRecipeInfo.RecipeID); RefreshRecipeStatus(this.SelectedRecipeInfo.RecipeNo.ToString("D3"), this.SelectedRecipeInfo.RecipeID); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }