public void ReduceEnrollment(int id) { try { using (SqlConnection connection = new SqlConnection(global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand command = new SqlCommand("UPDATE Exercise SET " + "Enrolled=Enrolled - 1 WHERE id=@id", connection)) { command.Parameters.AddWithValue("@id", id); command.Connection.Open(); command.ExecuteNonQuery(); command.Connection.Close(); } } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void button1_Click(object sender, EventArgs e) { try { OpenFileDialog d = new OpenFileDialog(); if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK) { pictureBox1.Image = LoadBitmap(d.FileName); } pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void button3_Click(object sender, EventArgs e) { try { sport.Close(); ShopItemForm formDialog = new ShopItemForm(label8.Text); formDialog.ShowDialog(); sport.Open(); getItems(); } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
public MeasurementHistoryForm(string memberId) { InitializeComponent(); string MemberId = memberId; try { using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { connection.Open(); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("SELECT Timestamp, Height, Weight, BodyFat, Neck, " + "Shoulders, LeftBicep, LeftForearm, RightBicep, RightForearm, Chest, Waist, Hips, LeftThighs, RightThighs," + "LeftCalves, RightCalves FROM Measurement WHERE MemberId='" + MemberId + "' ORDER BY Timestamp DESC", connection); DataTable db = new DataTable(); sqlDataAdapter.Fill(db); dataGridView1.DataSource = db; connection.Close(); } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void listView1_MouseClick(object sender, MouseEventArgs e) { String selected = listView1.SelectedItems[0].SubItems[0].Name; try { using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { //SELECT TOP 1 * FROM Measurement WHERE MemberId=1 ORDER BY Timestamp DESC; using (SqlCommand cmd2 = new SqlCommand("SELECT id, ItemName, ItemId, ItemPrice, ItemCount, ItemDescription" + " FROM Items WHERE ItemId = " + selected, connection)) { cmd2.CommandType = CommandType.Text; cmd2.Connection.Open(); SqlDataReader dr = cmd2.ExecuteReader(); while (dr.Read()) { itemId = dr["id"].ToString(); string itemname = dr["ItemName"].ToString(); string itemid = dr["ItemId"].ToString(); string itemprice = dr["ItemPrice"].ToString(); string itemcount = dr["ItemCount"].ToString(); string itemdesc = dr["ItemDescription"].ToString(); label7.Text = itemname; label8.Text = itemid; label9.Text = itemprice; label10.Text = itemcount; if (Convert.ToInt32(label10.Text) == 0) { label10.Text = "OUT OF STOCK"; } label11.Text = itemdesc; this.button3.Visible = true; } cmd2.Connection.Close(); } connection.Close(); } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
public void getItems() { items.Clear(); try { using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand command = new SqlCommand("SELECT id, ItemName, ItemId, ItemPrice, ItemCount, ItemDescription" + " FROM Items", connection)) { command.CommandType = CommandType.Text; connection.Open(); SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { int id = Convert.ToInt32(dr["id"]); string name = dr["ItemName"].ToString(); int itemid = Convert.ToInt32(dr["Itemid"]); decimal itemprice = Convert.ToDecimal(dr["ItemPrice"]); int itemcount = Convert.ToInt32(dr["ItemCount"]); string itemdesc = dr["ItemDescription"].ToString(); string itemurl = path.Trim() + "Images\\shopitems\\" + itemid.ToString() + ext; FullItem newItem = new FullItem(); newItem.id = id; newItem.ItemName = name; newItem.ItemId = itemid; newItem.ItemPrice = itemprice; newItem.ItemCount = itemcount; newItem.ItemDescription = itemdesc; newItem.ItemUrl = itemurl; items.Add(newItem); } connection.Close(); } } populate(); } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e) { try { datareceived = sport.ReadLine(); theNewId = Int64.Parse(datareceived.Trim(), NumberStyles.HexNumber); using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand cmd = new SqlCommand("SELECT id, (Name + ' ' + Surname) AS Name, Gender, LastEntrance FROM Member WHERE CardId=@CardId", connection)) { cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@CardId", theNewId); connection.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows == true) { ShopMember shopmember = new ShopMember(); while (dr.Read()) { string id = dr["id"].ToString(); string name = dr["Name"].ToString(); string gender = dr["Gender"].ToString(); string lastentrance = dr["LastEntrance"].ToString(); shopmember.id = dr["id"].ToString(); shopmember.Name = dr["Name"].ToString(); shopmember.Gender = dr["Gender"].ToString(); shopmember.LastEntrance = dr["LastEntrance"].ToString(); SetText(shopmember); sport.Close(); } sport.Open(); } connection.Close(); } } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
public void GetReport(DateTime p, DateTime d, List <ReducedAccount> accounts) { try { using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand cmd2 = new SqlCommand("SELECT id, Name, Surname, Price, PaymentDate, ExpirationDate, MemberId FROM" + " Account WHERE PaymentDate>=@p AND PaymentDate<=@d ", connection)) { cmd2.Parameters.AddWithValue("@p", p); cmd2.Parameters.AddWithValue("@d", d); cmd2.CommandType = CommandType.Text; connection.Open(); SqlDataReader dr = cmd2.ExecuteReader(); while (dr.Read()) { int id = Convert.ToInt32(dr["id"]); string name = dr["Name"].ToString(); string surname = dr["Surname"].ToString(); int memberid = Convert.ToInt32(dr["MemberId"]); double price = Convert.ToDouble(dr["Price"].ToString()); DateTime paymentdate = Convert.ToDateTime(dr["PaymentDate"]); DateTime expirationdate = Convert.ToDateTime(dr["ExpirationDate"]); ReducedAccount singleAccount = new ReducedAccount(); singleAccount.id = id; singleAccount.Name = name; singleAccount.Surname = surname; singleAccount.Price = price; singleAccount.PaymentDate = paymentdate; singleAccount.ExpirationDate = expirationdate; singleAccount.MemberId = memberid; accounts.Add(singleAccount); } connection.Close(); } } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void updateItem() { try { using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { //SELECT TOP 1 * FROM Measurement WHERE MemberId=1 ORDER BY Timestamp DESC; using (SqlCommand cmd2 = new SqlCommand("SELECT ItemName, ItemId, ItemPrice, ItemCount, ItemDescription" + " FROM Items WHERE ItemId = " + itemId, connection)) { cmd2.CommandType = CommandType.Text; cmd2.Connection.Open(); SqlDataReader dr = cmd2.ExecuteReader(); while (dr.Read()) { string itemname2 = dr["ItemName"].ToString(); string itemid33 = dr["ItemId"].ToString(); string itemprice = dr["ItemPrice"].ToString(); string itemcount = dr["ItemCount"].ToString(); string itemdesc2 = dr["ItemDescription"].ToString(); itemname.Text = itemname2; itemid2.Text = itemid33; itemprice2.Text = itemprice; itemcount1.Text = itemcount; itemdesc1.Text = itemdesc2; pictureBox1.Image = LoadBitmap(path + "\\" + itemid33 + ext); } cmd2.Connection.Close(); } connection.Close(); } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void ShopItemForm_Load(object sender, EventArgs e) { try { using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand cmd4 = new SqlCommand("SELECT PATH FROM Settings", connection)) { cmd4.CommandType = CommandType.Text; cmd4.Connection.Open(); SqlDataReader dr = cmd4.ExecuteReader(); while (dr.Read()) { path = dr["PATH"].ToString(); } cmd4.Connection.Close(); } } path = @"" + path + "\\Images\\shopitems\\"; } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } if (itemId == "0") { groupBox2.Text = "Add new Item:"; button2.Text = "Add"; getLastIndex(); } else { groupBox2.Text = "Update Item"; button2.Text = "Update"; updateItem(); } }
public void WriteEntrance(int id, int num, string name, string surname) { try { using (SqlConnection connection = new SqlConnection(global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand command = new SqlCommand("UPDATE Member SET NumOfEntrances" + "=@NumOfEntrances,LastEntrance=@LastEntrance WHERE id=@id", connection)) { command.Parameters.AddWithValue("@NumOfEntrances", num); command.Parameters.AddWithValue("@id", id); command.Parameters.AddWithValue("@LastEntrance", DateTime.Now); command.Connection.Open(); command.ExecuteNonQuery(); command.Connection.Close(); } using (SqlCommand command2 = new SqlCommand("INSERT INTO Report(MemberId, EntranceDate, Name, Surname) VALUES(@MemberId, @EntranceDate, @Name, @Surname)", connection)) { command2.Parameters.AddWithValue("@MemberId", id); command2.Parameters.AddWithValue("@EntranceDate", DateTime.Now); command2.Parameters.AddWithValue("@Name", name); command2.Parameters.AddWithValue("@Surname", surname); command2.Connection.Open(); command2.ExecuteNonQuery(); command2.Connection.Close(); } } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
public int GetMemberId(String k) { try { Int64 i = Convert.ToInt64(k); using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand cmd = new SqlCommand("SELECT id FROM Member WHERE CardId=@CardId", connection)) { cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@CardId", i); connection.Open(); object o = cmd.ExecuteScalar(); if (o != null) { string city = o.ToString(); int s = Convert.ToInt32(city); cmd.Connection.Close(); return(s); } cmd.Connection.Close(); return(0); } } } catch (Exception e) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(e.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); return(0); } }
public DateTime GetExpirationDate(long k) { try { using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand cmd = new SqlCommand("SELECT ExpirationDate FROM Account WHERE MemberId=@CardId ORDER BY id DESC;", connection)) { cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@CardId", k); connection.Open(); object o = cmd.ExecuteScalar(); if (o != null) { string id = o.ToString(); DateTime d = Convert.ToDateTime(id); connection.Close(); return(d); } connection.Close(); return(DateTime.Now); } } } catch (Exception e) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(e.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); return(DateTime.Now); } }
public string checkTrainingEnrollment(string id) { try { using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand cmd2 = new SqlCommand("SELECT MemberId, ExerciseId FROM TrainingEnrollment WHERE ExerciseId=@id", connection)) { string memberid; cmd2.Parameters.AddWithValue("id", id); cmd2.CommandType = CommandType.Text; connection.Open(); SqlDataReader dr = cmd2.ExecuteReader(); while (dr.Read()) { memberid = dr["MemberId"].ToString(); int exerciseId = Convert.ToInt32(dr["ExerciseId"]); return(memberid); } connection.Close(); } } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } return("0"); }
private void MeasurementsForm_Load(object sender, EventArgs e) { button2.Enabled = false; try { DataSet userDataSet = new DataSet(); using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand cmd2 = new SqlCommand("SELECT id, (Surname + ', ' + Name) AS Name FROM Member ORDER BY Surname ASC", connection)) { cmd2.CommandType = CommandType.Text; cmd2.Connection.Open(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd2; da.Fill(userDataSet); comboBox1.DisplayMember = "Name"; comboBox1.ValueMember = "id"; comboBox1.DataSource = userDataSet.Tables[0]; comboBox1.SelectedIndex = -1; cmd2.Connection.Close(); } connection.Close(); } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
public ExerciseListForm() { InitializeComponent(); using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand cmd4 = new SqlCommand("SELECT PATH FROM Settings", connection)) { cmd4.CommandType = CommandType.Text; cmd4.Connection.Open(); SqlDataReader dr = cmd4.ExecuteReader(); while (dr.Read()) { path = dr["PATH"].ToString(); } cmd4.Connection.Close(); path = @"" + path + "\\"; } } try { tmp = method.getComm(); sport = new System.IO.Ports.SerialPort("COM" + tmp, 9600, Parity.None, 8, StopBits.One); } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void getLastIndex() { try { using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { //"SELECT TOP 1 * FROM Measurement WHERE MemberId='"+ comboBox1.SelectedValue +"' ORDER BY Timestamp DESC" using (SqlCommand cmd = new SqlCommand("SELECT TOP 1 ItemId FROM Items ORDER BY ItemId DESC", connection)) { cmd.CommandType = CommandType.Text; connection.Open(); object o = cmd.ExecuteScalar(); if (o != null) { int idVlaue = Convert.ToInt32(o) + 1; string itemidstring = idVlaue.ToString(); itemid2.Text = itemidstring; } connection.Close(); } } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void measurementHistoryClicked(object sender, EventArgs e) { try { MeasurementHistoryForm f = new MeasurementHistoryForm(comboBox1.SelectedValue.ToString()); f.ShowDialog(); } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
public void populate() { listView1.Items.Clear(); ImageList imgs = new ImageList(); imgs.ImageSize = new Size(147, 147); try { listView1.LargeImageList = imgs; for (int i = 0; i < exercises.Count; i++) { System.Drawing.Image img = new Bitmap(System.Drawing.Image.FromFile(exercises[i].ExerciseUrl)); using (Graphics g = Graphics.FromImage(img)) { g.DrawRectangle(Pens.Black, 0, 0, img.Width - 2, img.Height - 2); } imgs.Images.Add(img); listView1.Items.Add(exercises[i].id.ToString(), "", i); } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void button2_Click_1(object sender, EventArgs e) { string[] name; if (label12.Text != "----------" && label9.Text != "----------") { try { using (SqlConnection connection = new SqlConnection(global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand command2 = new SqlCommand("DELETE FROM TrainingEnrollment Where " + "MemberId='" + globalId + "' AND ExerciseId='" + currExerciseId + "'", connection)) { command2.Connection.Open(); command2.ExecuteNonQuery(); command2.Connection.Close(); } method.ReduceEnrollment(currExerciseId); List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("Succesfull Left")); Labels.Add(MyLabel.SetOKLabel("Successfully left the " + label9.Text + " workout programme")); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetSuccess()); } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } } else { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel("Missing user and/or training programme.")); sport.Write("#ERROR: Missing user/training programme!\n"); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void button1_Click_1(object sender, EventArgs e) { string[] name; if (label12.Text != "----------" && label9.Text != "----------") { try { using (SqlConnection connection = new SqlConnection(global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand command2 = new SqlCommand("INSERT INTO TrainingEnrollment(MemberId, EnrollmentDate, Name, Surname, ExerciseId, " + "ExerciseName, ExercisePrice) VALUES(@MemberId, @EnrollmentDate, @Name, @Surname, @ExerciseId, @ExerciseName, @ExercisePrice)", connection)) { name = label13.Text.Split(null); command2.Parameters.AddWithValue("@MemberId", label12.Text); command2.Parameters.AddWithValue("@EnrollmentDate", DateTime.Now); command2.Parameters.AddWithValue("@Name", name[0]); command2.Parameters.AddWithValue("@Surname", name[1]); command2.Parameters.AddWithValue("@ExerciseId", currExerciseId); command2.Parameters.AddWithValue("@ExerciseName", label9.Text); command2.Parameters.AddWithValue("@ExercisePrice", label10.Text); command2.Connection.Open(); command2.ExecuteNonQuery(); command2.Connection.Close(); } method.UpdateEnrollment(currExerciseId); List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("Succesfull Enrolled")); Labels.Add(MyLabel.SetOKLabel("Successfully enrolled into " + label9.Text + " workout programme")); sport.Write("#SUCCS: Welcome to" + label9.Text + "!\n"); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetSuccess()); } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } } else { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel("Missing user and/or training programme.")); sport.Write("#ERROR: Missing user/training programme!\n"); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void listView1_MouseClick(object sender, MouseEventArgs e) { String selected = listView1.SelectedItems[0].SubItems[0].Name; try { using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand cmd2 = new SqlCommand("SELECT id, Name, Description, Link, Day, Time, Enrolled, Price" + " FROM Exercise WHERE id = " + selected, connection)) { cmd2.CommandType = CommandType.Text; cmd2.Connection.Open(); SqlDataReader dr = cmd2.ExecuteReader(); while (dr.Read()) { int id = Convert.ToInt32(dr["id"]); string name = dr["Name"].ToString(); string desc = dr["Description"].ToString(); string link = dr["Link"].ToString(); string day = dr["Day"].ToString(); string time = dr["Time"].ToString(); int enrolled = Convert.ToInt32(dr["Enrolled"]); int price = Convert.ToInt32(dr["Price"]); getYoutubeVideo(link); currExerciseId = id; label9.Text = name; label5.Text = desc; label3.Text = "Every " + day + " at " + time + "."; label1.Text = enrolled.ToString(); label10.Text = price.ToString(); } cmd2.Connection.Close(); string doesIdExists = method.checkTrainingEnrollment(currExerciseId.ToString()); if (doesIdExists == globalId) { button1.Enabled = false; button2.Enabled = true; } else { button1.Enabled = true; button2.Enabled = false; } } connection.Close(); } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void getExercises() { try { using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand command = new SqlCommand("SELECT id, Name, Description, Link, Day, Time, Enrolled, Price" + " FROM Exercise", connection)) { command.CommandType = CommandType.Text; connection.Open(); SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { int id = Convert.ToInt32(dr["id"]); string name = dr["Name"].ToString(); string desc = dr["Description"].ToString(); string link = dr["Link"].ToString(); string day = dr["Day"].ToString(); string time = dr["Time"].ToString(); int enrolled = Convert.ToInt32(dr["Enrolled"]); int price = Convert.ToInt32(dr["Price"]); string exerciseurl = path.Trim() + "Images\\trainings\\" + id.ToString() + ext; FullExercise exercise = new FullExercise(); exercise.id = id; exercise.Name = name; exercise.Description = desc; exercise.Link = link; exercise.Day = day; exercise.Time = time; exercise.Enrolled = enrolled; exercise.Price = price; exercise.ExerciseUrl = exerciseurl; exercises.Add(exercise); } connection.Close(); } } populate(); } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void button2_Click(object sender, EventArgs e) { if (itemId == "0") { try { using (SqlConnection connection = new SqlConnection(global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand command2 = new SqlCommand("INSERT INTO Items(ItemName, ItemId, ItemPrice, ItemCount, ItemDescription) " + "VALUES(@ItemName, @ItemId, @ItemPrice, @ItemCount, @ItemDescription)", connection)) { command2.Parameters.AddWithValue("@ItemName", itemname.Text.ToUpper()); command2.Parameters.AddWithValue("@ItemId", Convert.ToInt32(itemid2.Text)); command2.Parameters.AddWithValue("@ItemPrice", itemprice2.Text); command2.Parameters.AddWithValue("@ItemCount", Convert.ToInt32(itemcount1.Text)); command2.Parameters.AddWithValue("@ItemDescription", itemdesc1.Text); command2.Connection.Open(); command2.ExecuteNonQuery(); command2.Connection.Close(); saveImage(); itemname.Clear(); getLastIndex(); itemprice2.Clear(); itemcount1.Clear(); itemdesc1.Clear(); List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("Adding Items")); Labels.Add(MyLabel.SetOKLabel("Sucessfully added item.")); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetSuccess()); } } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } } else { try { using (SqlConnection connection = new SqlConnection(global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand command = new SqlCommand("UPDATE Items SET ItemCount" + "=@Count, ItemPrice=@Price WHERE ItemId=@itemid", connection)) { command.Parameters.AddWithValue("@Count", itemcount1.Text); command.Parameters.AddWithValue("@Price", itemprice2.Text); command.Parameters.AddWithValue("@itemid", itemId); command.Connection.Open(); command.ExecuteNonQuery(); command.Connection.Close(); List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("Updating Items")); Labels.Add(MyLabel.SetOKLabel("Sucessfully updated item.")); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetSuccess()); } } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } } }
public void GenerateReceipt(DataTable ExDataTable) { Document pdfDoc = new Document(PageSize.A5, 10, 10, 10, 10); try { string s = DateTime.Today.ToString("dddd, dd MMMM yyyy"); string wanted_path = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory())); PdfWriter.GetInstance(pdfDoc, new FileStream(wanted_path + "//Reports//Receipt_" + s + ".pdf", FileMode.Create)); pdfDoc.Open(); iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(new System.Uri(wanted_path + "//Images//logo//logo.png")); image.ScaleAbsolute(35, 35); image.Alignment = Element.ALIGN_CENTER; Paragraph guid = new Paragraph("Receipt ID: " + Guid.NewGuid().ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 12, iTextSharp.text.Font.NORMAL, new BaseColor(0, 0, 0))); Paragraph address = new Paragraph("Paromlinska 34, 71000, Sarajevo", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 12, iTextSharp.text.Font.NORMAL, new BaseColor(0, 0, 0))); Paragraph p1 = new Paragraph("Date: " + s, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 12, iTextSharp.text.Font.BOLD, new BaseColor(0, 0, 0))); Paragraph p2 = new Paragraph("\n"); Random rnd = new Random(); Paragraph jib = new Paragraph("JIB: " + rnd.Next(10000000, 99999999).ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 12, iTextSharp.text.Font.NORMAL, new BaseColor(0, 0, 0))); Paragraph pib = new Paragraph("PIB: " + rnd.Next(10000000, 99999999).ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 12, iTextSharp.text.Font.NORMAL, new BaseColor(0, 0, 0))); pdfDoc.Add(image); pdfDoc.Add(p2); pdfDoc.Add(p2); pdfDoc.Add(guid); pdfDoc.Add(address); pdfDoc.Add(p1); pdfDoc.Add(jib); pdfDoc.Add(pib); pdfDoc.Add(p2); pdfDoc.Add(p2); iTextSharp.text.Font fnt = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10, iTextSharp.text.Font.NORMAL, new BaseColor(0, 0, 0)); DataTable dt = ExDataTable; if (dt != null) { PdfPTable PdfTable = new PdfPTable(dt.Columns.Count); PdfPCell PdfPCell = null; for (int rows = 0; rows < dt.Rows.Count; rows++) { if (rows == 0) { for (int column = 0; column < dt.Columns.Count; column++) { PdfPCell = new PdfPCell(new Phrase(new Chunk(dt.Columns[column].ColumnName.ToString(), fnt))); PdfTable.AddCell(PdfPCell); } } for (int column = 0; column < dt.Columns.Count; column++) { PdfPCell = new PdfPCell(new Phrase(new Chunk(dt.Rows[rows][column].ToString(), fnt))); PdfTable.AddCell(PdfPCell); } } pdfDoc.Add(PdfTable); } pdfDoc.Add(p2); double pdvAmount = (Convert.ToDouble(label9.Text) / 100 * 14); double osnEAmount = Convert.ToDouble(label9.Text) - pdvAmount; Paragraph pdv = new Paragraph("PDV 17,00%: " + osnEAmount + " KM", fnt); Paragraph osne = new Paragraph("Osn E: " + pdvAmount + " KM", fnt); Paragraph p4 = new Paragraph("Total Amount: " + label9.Text + " KM", fnt); pdfDoc.Add(pdv); pdfDoc.Add(osne); pdfDoc.Add(p2); pdfDoc.Add(p4); p4.Alignment = Element.ALIGN_CENTER; Paragraph blank = new Paragraph("\n"); for (int i = 0; i <= 5; i++) { pdfDoc.Add(blank); } Paragraph gymmembershipsystem = new Paragraph("Arnold's Gym", fnt); Paragraph CEOandOwner = new Paragraph("CEO And Owner:", fnt); Paragraph Arnold = new Paragraph("Arnold Schwarzenegger", fnt); Paragraph spaces = new Paragraph("______________________________", fnt); pdfDoc.Add(gymmembershipsystem); pdfDoc.Add(CEOandOwner); pdfDoc.Add(Arnold); pdfDoc.Add(spaces); pdfDoc.Close(); } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void button1_Click(object sender, EventArgs e) { string Height = textBox1.Text; string Weight = textBox2.Text; string Neck = textBox3.Text; string BodyFat = textBox4.Text; string Shoulders = textBox6.Text; string LeftBicep = textBox5.Text; string LeftForearm = textBox7.Text; string RightBicep = textBox9.Text; string RightForearm = textBox8.Text; string Chest = textBox11.Text; string Waist = textBox10.Text; string Hips = textBox13.Text; string LeftThighs = textBox12.Text; string RightThighs = textBox15.Text; string LeftCalves = textBox14.Text; string RightCalves = textBox16.Text; try { using (SqlConnection connection2 = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand cmd = new SqlCommand("INSERT INTO Measurement(Height, Weight, Neck, BodyFat, Shoulders," + "LeftBicep, LeftForearm, RightBicep, RightForearm, Chest, Waist, Hips," + "LeftThighs, RightThighs, LeftCalves, RightCalves, MemberId, Timestamp)" + "VALUES(@Height, @Weight, @Neck, @BodyFat, @Shoulders, @LeftBicep, @LeftForearm, @RightBicep, @RightForearm, @Chest, @Waist, @Hips," + "@LeftThighs, @RightThighs, @LeftCalves, @RightCalves, @UserId, @Timestamp)", connection2)) { cmd.Parameters.AddWithValue("@Height", textBox1.Text); cmd.Parameters.AddWithValue("@Weight", textBox2.Text); cmd.Parameters.AddWithValue("@Neck", textBox3.Text); cmd.Parameters.AddWithValue("@BodyFat", textBox4.Text); cmd.Parameters.AddWithValue("@Shoulders", textBox6.Text); cmd.Parameters.AddWithValue("@LeftBicep", textBox5.Text); cmd.Parameters.AddWithValue("@LeftForearm", textBox7.Text); cmd.Parameters.AddWithValue("@RightBicep", textBox9.Text); cmd.Parameters.AddWithValue("@RightForearm", textBox8.Text); cmd.Parameters.AddWithValue("@Chest", textBox11.Text); cmd.Parameters.AddWithValue("@Waist", textBox10.Text); cmd.Parameters.AddWithValue("@Hips", textBox13.Text); cmd.Parameters.AddWithValue("@LeftThighs", textBox12.Text); cmd.Parameters.AddWithValue("@RightThighs", textBox15.Text); cmd.Parameters.AddWithValue("@LeftCalves", textBox14.Text); cmd.Parameters.AddWithValue("@RightCalves", textBox16.Text); cmd.Parameters.AddWithValue("@UserId", comboBox1.SelectedValue); cmd.Parameters.AddWithValue("@Timestamp", DateTime.Now); cmd.Connection.Open(); if (cmd.ExecuteNonQuery().ToString() == "1") { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("Measurement Update")); Labels.Add(MyLabel.SetOKLabel("Measurement update passed")); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetSuccess()); } else { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("Measurement Update")); Labels.Add(MyLabel.SetOKLabel("Measurement update failed")); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } } connection2.Close(); } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void button1_Click(object sender, EventArgs e) { string[] name; if (label12.Text != "----------" && label8.Text != "----------") { if (label10.Text == "OUT OF STOCK") { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel("Item Out of Stock")); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); sport.Write("#ERROR: Item Out Of Stock!\n"); } else { try { using (SqlConnection connection = new SqlConnection(global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand command2 = new SqlCommand("INSERT INTO ShopPayment(MemberId, PaymentDate, Name, Surname, ItemId, ItemName, ItemPrice) VALUES(@MemberId, @EntranceDate, @Name, @Surname, @ItemId, @ItemName, @ItemPrice)", connection)) { name = label13.Text.Split(null); command2.Parameters.AddWithValue("@MemberId", label12.Text); command2.Parameters.AddWithValue("@EntranceDate", DateTime.Now); command2.Parameters.AddWithValue("@Name", name[0]); command2.Parameters.AddWithValue("@Surname", name[1]); command2.Parameters.AddWithValue("@ItemId", Convert.ToInt32(itemId)); command2.Parameters.AddWithValue("@ItemName", label7.Text); command2.Parameters.AddWithValue("@ItemPrice", label9.Text); command2.Connection.Open(); command2.ExecuteNonQuery(); command2.Connection.Close(); } List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("Succesfull Payment")); Labels.Add(MyLabel.SetOKLabel("Item " + label7.Text + " sold successfully." + " Generated Receipt.")); method.UpdateItemCount(Convert.ToInt32(itemId)); sport.Write("#SUCCS: Item Sold! Price is:" + label9.Text + "KM\n"); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetSuccess()); label10.Text = (Convert.ToInt32(label10.Text) - 1).ToString(); if (Convert.ToInt32(label10.Text) == 0) { label10.Text = "OUT OF STOCK"; } DataTable dt = new DataTable(); dt.Columns.Add("Receipt Information"); dt.Columns.Add("Receipt Data"); DataRow dRow = dt.NewRow(); dRow["Receipt Information"] = "Member Id"; dRow["Receipt Data"] = label12.Text; dt.Rows.Add(dRow); dRow = dt.NewRow(); dRow["Receipt Information"] = "Member Name"; dRow["Receipt Data"] = name[0] + " " + name[1]; dt.Rows.Add(dRow); dRow = dt.NewRow(); dRow["Receipt Information"] = "Item Id"; dRow["Receipt Data"] = itemId; dt.Rows.Add(dRow); dRow = dt.NewRow(); dRow["Receipt Information"] = "Item Name"; dRow["Receipt Data"] = label7.Text; dt.Rows.Add(dRow); dRow = dt.NewRow(); dRow["Receipt Information"] = "Item Price"; dRow["Receipt Data"] = label9.Text; dt.Rows.Add(dRow); GenerateReceipt(dt); Task ignoredAwaitableResult; } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } } } else { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel("Missing user and/or item to sell.")); sport.Write("#ERROR: Missing user/item to sell!\n"); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e) { try { using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand cmd2 = new SqlCommand("SELECT TOP 1 * FROM Measurement WHERE MemberId='" + comboBox1.SelectedValue + "' ORDER BY Timestamp DESC", connection)) { cmd2.CommandType = CommandType.Text; cmd2.Connection.Open(); SqlDataReader dr = cmd2.ExecuteReader(); if (dr.HasRows == false) { button2.Enabled = false; textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox6.Clear(); textBox5.Clear(); textBox7.Clear(); textBox9.Clear(); textBox8.Clear(); textBox11.Clear(); textBox10.Clear(); textBox13.Clear(); textBox12.Clear(); textBox15.Clear(); textBox14.Clear(); textBox16.Clear(); } while (dr.Read()) { button2.Enabled = true; string Height = dr["Height"].ToString(); string Weight = dr["Weight"].ToString(); string BodyFat = dr["BodyFat"].ToString(); string Neck = dr["Neck"].ToString(); string Shoulders = dr["Shoulders"].ToString(); string LeftBicep = dr["LeftBicep"].ToString(); string LeftForearm = dr["LeftForearm"].ToString(); string RightBicep = dr["RightBicep"].ToString(); string RightForearm = dr["RightForearm"].ToString(); string Chest = dr["Chest"].ToString(); string Waist = dr["Waist"].ToString(); string Hips = dr["Hips"].ToString(); string LeftThighs = dr["LeftThighs"].ToString(); string RightThighs = dr["RightThighs"].ToString(); string LeftCalves = dr["LeftCalves"].ToString(); string RightCalves = dr["RightCalves"].ToString(); textBox1.Text = Height; textBox2.Text = Weight; textBox3.Text = Neck; textBox4.Text = BodyFat; textBox6.Text = Shoulders; textBox5.Text = LeftBicep; textBox7.Text = LeftForearm; textBox9.Text = RightBicep; textBox8.Text = RightForearm; textBox11.Text = Chest; textBox10.Text = Waist; textBox13.Text = Hips; textBox12.Text = LeftThighs; textBox15.Text = RightThighs; textBox14.Text = LeftCalves; textBox16.Text = RightCalves; } cmd2.Connection.Close(); } connection.Close(); } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
public void GetMembers(List <PartialMember> members) { try { using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand command = new SqlCommand("SELECT id, Name, Surname, Address, PhoneNumber, CardId, TypeId," + " NumOfEntrances, Gender, LastEntrance FROM Member ORDER BY Surname ASC", connection)) { command.CommandType = CommandType.Text; connection.Open(); SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { int id = Convert.ToInt32(dr["id"]); string name = dr["Name"].ToString(); string surname = dr["Surname"].ToString(); string address = dr["Address"].ToString(); string phonenum = dr["PhoneNumber"].ToString(); string typeid = dr["TypeId"].ToString(); int numofentr = Convert.ToInt32(dr["NumOfEntrances"]); Int64 cardid = Convert.ToInt64(dr["CardId"]); DateTime lastEntrance = Convert.ToDateTime(dr["LastEntrance"]); string gender = dr["Gender"].ToString(); DateTime expDate = GetExpirationDate(id); PartialMember newMember = new PartialMember(); newMember.Name = name; newMember.Surname = surname; newMember.Address = address; newMember.PhoneNumber = phonenum; newMember.TypeId = typeid; newMember.NumOfEntrances = numofentr; newMember.ExpirationDate = expDate; newMember.CardId = cardid; newMember.LastEntrance = lastEntrance; newMember.Gender = gender; newMember.id = id; newMember.NumOfDays = GetNumberOfEntrances(cardid.ToString()); members.Add(newMember); } connection.Close(); } } } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }