private void CalcKcal_button1_Click(object sender, EventArgs e) { try { int varsta = Convert.ToInt32(CalcKcal_text1.Text); int inaltime = Convert.ToInt32(CalcKcal_text2.Text); int greutate = Convert.ToInt32(CalcKcal_text3.Text); varsta += inaltime; varsta += greutate; int Kcal; if (varsta < 250) { Kcal = 1800; } else if (varsta > 275) { Kcal = 2500; } else { Kcal = 2200; } CalcKcal_text4.Text = Kcal.ToString(); client.kcal_zilnice = Kcal; GenMeniu_text1.Text = client.kcal_zilnice.ToString(); Comanda_text1.Text = client.kcal_zilnice.ToString(); parent.updateDataBase(); CalcKcal_ErrorLabel.Text = ""; } catch (Exception ex) { CalcKcal_ErrorLabel.Text = "Datele introduse nu sunt valide"; } }
public override string ToString() { return ($"\nProteins {Proteins.ToString("0.##")} g = {(Proteins * 4).ToString("0.##")} Kcal" + $"\nFat {Fat.ToString("0.##")} g = {(Fat * 9).ToString("0.##")} Kcal" + $"\nCarbs {Carbs.ToString("0.##")} g = {(Carbs * 4).ToString("0.##")} Kcal" + $"\nTotalgram {TotalGrams.ToString("0.##")} g = {Kcal.ToString("0.##")} Kcal"); }
public string ToInsert() { var kcal = Kcal.ToString().Replace(',', '.'); var protein = Protein.ToString().Replace(',', '.'); var fat = Fat.ToString().Replace(',', '.'); var carbs = Carbs.ToString().Replace(',', '.'); return($"('{ID}', '{Name}', '{kcal}', '{protein}', '{fat}', '{carbs}', '{Type}')"); }
private void GetDataFromDB(string ItemCode) { try { logList.Clear(); DataSet dsLogList = new DataSet(); query = "Call GetItemData('" + ItemCode + "')"; MySqlDataAdapter adapter = new MySqlDataAdapter(query, conn); adapter.Fill(dsLogList, "product_name"); DataTable dtProductValues = dsLogList.Tables["product_name"]; if (dtProductValues.Rows.Count == 0) { Toast.MakeText(this, "brak itemu w bazie ", ToastLength.Long).Show(); return; } foreach (DataColumn col in dsLogList.Tables["product_name"].Columns) { logList.Add(col.ColumnName); } foreach (DataRow row in dsLogList.Tables["product_name"].Rows) { for (int i = 0; i < logList.Count; i++) { logList[i] += " : " + row[i].ToString(); } } double Kcal; // KJ to KCAL Kcal = float.Parse(dtProductValues.Rows[0]["energia"].ToString(), CultureInfo.InvariantCulture.NumberFormat) * 0.2388; kcalInput = Kcal.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture); carbInput = dtProductValues.Rows[0]["weglowodany"].ToString(); fatInput = dtProductValues.Rows[0]["tluszcz"].ToString(); proteinInput = dtProductValues.Rows[0]["bialko"].ToString(); ArrayAdapter <string> adapterArray = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSelectableListItem, logList); ListDataPos.Adapter = adapterArray; } catch (Exception ex) { Toast.MakeText(this, "Error : " + ex.ToString(), ToastLength.Long).Show(); } }
public override string ToString() { return(string.Format("{0}: {1}/100g Rodzaj:{2}", Name, Kcal.ToString(), Kind)); }