-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdd_Food.cs
87 lines (77 loc) · 2.56 KB
/
Add_Food.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ConsoleApplication1.WindowsFormsApplication3;
using Constants;
namespace MyLife
{
public partial class Add_Food : Form
{
private void addfood_basic()
{
Dictionary<String, string> data = new Dictionary<String, string>();
string max_int = helperfns.get_Max_value("food_id", "Foods"); /*Constants_class.db.ExecuteScalar("Select max(food_id) from Foods");
if (max_int == "") { max_int = "1"; }
else
{
max_int = Convert.ToString(Convert.ToInt32(max_int) + 1);
}*/
data.Add("food_id", max_int);
data.Add("name", AddFoodNameTextBox.Text);
data.Add("serving_size", AddFoodServingSizeUpDown.Text);
data.Add("calories", AddFoodCaloriesUpDown.Text);
data.Add("carbs", AddFoodCarbohydratesUpDown.Text);
data.Add("fat", AddFoodFatUpDown.Text);
data.Add("protein", AddFoodProteinUpDown.Text);
//if (AddFoodRecommendRBYes.Checked == true)
//{
data.Add("Recommend", AddFoodRecommendRBNo.Checked.ToString());
//data.Add("Recommend", "true");
//}
//else if (AddFoodRecommendRBNo.Checked == false)
//{
//data.Add("Recommend", "false");
//}
//else
//{
//data.Add("Recommend", "errorz");
//}
data.Add("comments", AddFoodCommentsTextBox.Text);
try
{
Constants_class.db.Insert("foods", data,true);
}
catch (Exception crap)
{
MessageBox.Show(crap.Message);
}
}
public Add_Food()
{
InitializeComponent();
}
private void AddFoodSaveButton_Click(object sender, EventArgs e)
{
addfood_basic();
this.Close();
}
public void AddFoodSaveAndContinueButton_Click(object sender, EventArgs e)
{
addfood_basic();
helperfns.RecursiveClearControls(this.Controls);
}
private void AFGoogleIt_Click(object sender, EventArgs e)
{
helperfns.GoogleItButtonGo(AddFoodNameTextBox);
}
private void AFCancelButton_Click(object sender, EventArgs e)
{
this.Close();
}
}
}