示例#1
0
        public List <MenuRecipeVO> SelectRecipesByMenuCode(string menuCode)
        {
            List <MenuRecipeVO> lst = new List <MenuRecipeVO>();
            string sp = "SelectRecipesByMenuCode";

            SqlParameter[] sqlParameters = new SqlParameter[]
            {
                new SqlParameter("menuCode", menuCode)
            };
            try
            {
                SqlDataReader sdr = new DBConnection().Select(sp, sqlParameters);
                while (sdr.Read())
                {
                    MenuRecipeVO menuRecipe = new MenuRecipeVO();
                    menuRecipe.RecipeNo          = sdr["recipeNo"].ToString();
                    menuRecipe.IngredientAmount  = Convert.ToInt32(sdr["ingredientAmount"]);
                    menuRecipe.MenuCode          = sdr["menuCode"].ToString();
                    menuRecipe.InventoryTypeCode = sdr["InventoryTypeCode"].ToString();
                    menuRecipe.Necessary         = Convert.ToBoolean(sdr["necessary"]);
                    lst.Add(menuRecipe);
                }
                return(lst);
            }
            catch (SqlException)
            {
                throw;
            }
        }
示例#2
0
        /// <summary>
        /// 레시피를 등록하기위한 InsertingRecipe 메서드
        /// </summary>
        /// <param name="menuCode">지정된 제품의 레시피를 나타내기위한 메뉴코드</param>
        /// <param name="succRecip">레시피 등록 성공 여부</param>
        /// <returns>레시피 등록 성공 여부 반환.</returns>
        private bool InsertingRecipe(string menuCode, bool succRecip)
        {
            int ingrAmount = 0;

            succRecip = false;
            bool necess = false;

            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
                {
                    if (new MenuRecipeDAO().InsertRecipe(menuRecipeVO))
                    {
                        succRecip = true;
                    }
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            return(succRecip);
        }
示例#3
0
        public bool InsertRecipe(MenuRecipeVO menuRecipeVO)
        {
            DBConnection connection      = new DBConnection();
            string       storedProcedure = "InsertRecipe";

            SqlParameter[] sqlParameters = new SqlParameter[]
            {
                new SqlParameter("ingredientAmount", menuRecipeVO.IngredientAmount),
                new SqlParameter("menuCode", menuRecipeVO.MenuCode),
                new SqlParameter("InventoryTypeCode", menuRecipeVO.InventoryTypeCode),
                new SqlParameter("necessary", menuRecipeVO.Necessary)
            };
            try
            {
                return(connection.Insert(storedProcedure, sqlParameters));
            }
            catch (SqlException)
            {
                throw;
            }
        }
示例#4
0
        /// <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);
        }