private bool CheckRatioSums(int combID)
        {
            int mealRatioSum  = 0;
            int totalRatioSum = 0;

            for (int i = 0; i < newMealRatiosList.Count; i++)
            {
                MealRatio ratio = newMealRatiosList[i];
                mealRatioSum = ratio.FatPortion + ratio.CarbPortion + ratio.ProteinPortion;
                if (mealRatioSum != 100)
                {
                    lblError.Text = $"Omjer namirnica za obrok {ratio.Meal.Name} nije pravilan";
                    SQLProcedures.DeleteCombination(combID);
                    return(false);
                }
                totalRatioSum += ratio.TotalPortion;
            }

            if (totalRatioSum != 100)
            {
                lblError.Text = $"Omjer obroka za kombinaciju nije pravilan";
                SQLProcedures.DeleteCombination(combID);
                return(false);
            }

            return(true);
        }
        protected void btnSpremi_Click(object sender, EventArgs e)
        {
            int numberOfMeals = int.Parse(ddlBrojObroka.SelectedValue);
            int combID;

            if (!string.IsNullOrEmpty(txtStartDate.Text))
            {
                lblError.Text = string.Empty;
                DateTime startDate = DateTime.Parse(txtStartDate.Text);
                DateTime endDate;

                if (!string.IsNullOrEmpty(txtEndDate.Text))
                {
                    endDate = DateTime.Parse(txtEndDate.Text);
                    if (endDate < DateTime.Now)
                    {
                        lblError.Text = "Uneseni datum isteka je već prošao";
                        return;
                    }
                    combID = SQLProcedures.InsertCombination(numberOfMeals, startDate, endDate);
                }
                else
                {
                    combID = SQLProcedures.InsertCombination(numberOfMeals, startDate, null);
                }

                mealsList = SQLProcedures.GetMeals();
                for (int i = 0; i < gvCombinations.Rows.Count; i++)
                {
                    MealRatio    mealRatio = new MealRatio();
                    DropDownList ddl       = gvCombinations.Rows[i].FindControl("ddlObroci") as DropDownList;
                    if (mealsList.Find(m => m.Name == ddl.SelectedItem.Text).IsValid)
                    {
                        mealRatio.Meal = mealsList.Find(m => m.Name == ddl.SelectedItem.Text);
                    }
                    else
                    {
                        lblError.Text = $"Odabran obrok u {i + 1}. redu nije dozvoljen - pogledati tablicu Obroci";
                        SQLProcedures.DeleteCombination(combID);
                        return;
                    }

                    var txtFat   = gvCombinations.Rows[i].FindControl("txtMasti") as TextBox;
                    var txtCarb  = gvCombinations.Rows[i].FindControl("txtUgljikohidrati") as TextBox;
                    var txtProt  = gvCombinations.Rows[i].FindControl("txtBjelancevine") as TextBox;
                    var txtTotal = gvCombinations.Rows[i].FindControl("txtUkupno") as TextBox;

                    if (int.TryParse(txtFat.Text, out int fat))
                    {
                        mealRatio.FatPortion = fat;
                    }
                    else
                    {
                        lblError.Text = $"Unesena vrijednost masti za obrok {mealRatio.Meal.Name} nije valjana";
                        SQLProcedures.DeleteCombination(combID);
                        return;
                    }

                    if (int.TryParse(txtCarb.Text, out int carb))
                    {
                        mealRatio.CarbPortion = carb;
                    }
                    else
                    {
                        lblError.Text = $"Unesena vrijednost ugljikohidrata za obrok {mealRatio.Meal.Name} nije valjana";
                        SQLProcedures.DeleteCombination(combID);
                        return;
                    }

                    if (int.TryParse(txtProt.Text, out int prot))
                    {
                        mealRatio.ProteinPortion = prot;
                    }
                    else
                    {
                        lblError.Text = $"Unesena vrijednost bjelancevina za obrok {mealRatio.Meal.Name} nije valjana";
                        SQLProcedures.DeleteCombination(combID);
                        return;
                    }

                    if (int.TryParse(txtTotal.Text, out int total))
                    {
                        mealRatio.TotalPortion = total;
                    }
                    else
                    {
                        lblError.Text = $"Unesena vrijednost ukupnog udjela za obrok {mealRatio.Meal.Name} nije valjana";
                        SQLProcedures.DeleteCombination(combID);
                        return;
                    }

                    newMealRatiosList.Add(mealRatio);
                }

                AddNewMealRatios(combID);
            }

            else
            {
                lblError.Text = "Početni datum nije definiran";
            }
        }