/// <summary> /// 레시피를 업데이트 하는 메서드 /// </summary> /// <param name="menuCode">지정된 제품의 레시피를 나타내기위한 메뉴코드</param> /// <param name="sucessUpdateRecipe">레시피 업데이트 성공 여부</param> /// <returns>레시피 업데이트 성공 여부 반환.</returns> private bool UpdatingRecipe(string menuCode, bool sucessUpdateRecipe) { bool necess = false; int ingrAmount = 0; foreach (InventoryTypeVO item in inventoryTypeList) { MenuRecipeVO menuRecipeVO = new MenuRecipeVO(); menuRecipeVO.InventoryTypeCode = item.InventoryTypeCode; menuRecipeVO.MenuCode = menuCode; foreach (FlowLayoutPanel panel in FlowPanel.Controls) { foreach (var ctrl in panel.Controls) { if (ctrl.GetType() == typeof(RadioButton)) { RadioButton rbtn = ctrl as RadioButton; if (item.InventoryName.Equals(rbtn.Text)) { necess = rbtn.Checked; } } if (ctrl.GetType() == typeof(CheckBox)) { CheckBox cbx = ctrl as CheckBox; if (item.InventoryName.Equals(cbx.Text)) { necess = cbx.Checked; } } if (ctrl.GetType() == typeof(NumericUpDown)) { NumericUpDown numeric = ctrl as NumericUpDown; if (item.InventoryTypeCode.Equals(numeric.Name)) { ingrAmount = (int)numeric.Value; } } } } menuRecipeVO.Necessary = necess; menuRecipeVO.IngredientAmount = ingrAmount; try { int result = new MenuRecipeDAO().UpdateRecipes(menuRecipeVO); if (result < 1) { MessageBox.Show(item.InventoryName + "이(가) 존재하지 않습니다.\n재고 종류를 우선 추가 해주세요."); sucessUpdateRecipe = false; } else { sucessUpdateRecipe = true; } } catch (SqlException ex) { MessageBox.Show(ex.Message); } } return(sucessUpdateRecipe); }
private void salesMenuGView_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { oldMenuCode = msktbxMnuCode.Text = salesMenuGView.Rows[e.RowIndex].Cells[0].Value.ToString(); tbxMnuName.Text = salesMenuGView.Rows[e.RowIndex].Cells[1].Value.ToString(); tbxPrice.Text = salesMenuGView.Rows[e.RowIndex].Cells[2].Value.ToString(); tbxKcal.Text = salesMenuGView.Rows[e.RowIndex].Cells[3].Value.ToString(); tbxAddContxt.Text = salesMenuGView.Rows[e.RowIndex].Cells[6].Value.ToString(); tbxDiscountRatio.Text = salesMenuGView.Rows[e.RowIndex].Cells[7].Value.ToString(); pbxPhoto.ImageLocation = Application.StartupPath + salesMenuGView.Rows[e.RowIndex].Cells[4].Value.ToString(); images = salesMenuGView.Rows[e.RowIndex].Cells[4].Value.ToString(); foreach (Division item in Enum.GetValues(typeof(Division))) { if (salesMenuGView.Rows[e.RowIndex].Cells[5].Value.Equals((int)item)) { cbxDivision.SelectedItem = item; oldDivision = (int)item; } } if (cbxDivision.SelectedIndex == 0) { List <MenuRecipeVO> menuRecipeList = default(List <MenuRecipeVO>); try { menuRecipeList = new MenuRecipeDAO().SelectRecipesByMenuCode(msktbxMnuCode.Text); } catch (SqlException) { MessageBox.Show("레시피를 가져올 수 없습니다."); } foreach (MenuRecipeVO item in menuRecipeList) { foreach (FlowLayoutPanel panel in FlowPanel.Controls) { foreach (var ctrl in panel.Controls) { if (ctrl.GetType() == typeof(RadioButton)) { RadioButton rbtn = ctrl as RadioButton; if (item.InventoryTypeCode.Equals(rbtn.Name)) { rbtn.Checked = item.Necessary; } } if (ctrl.GetType() == typeof(CheckBox)) { CheckBox cbx = ctrl as CheckBox; if (item.InventoryTypeCode.Equals(cbx.Name)) { cbx.Checked = item.Necessary; } } if (ctrl.GetType() == typeof(NumericUpDown)) { NumericUpDown numeric = ctrl as NumericUpDown; if (item.InventoryTypeCode.Equals(numeric.Name)) { numeric.Value = item.IngredientAmount; } } } } } } tbxPrice.Focus(); salesMenuGView.Focus(); } }