private void GetReportName(DateTime p, DateTime d, string fullname) { 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 AND (Name+' '+Surname)=@s", connection)) { cmd2.Parameters.AddWithValue("@p", p); cmd2.Parameters.AddWithValue("@d", d); cmd2.Parameters.AddWithValue("@s", fullname); 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 GetAccount(long id) { try { using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand cmd2 = new SqlCommand("SELECT PaymentDate, ExpirationDate, Price FROM Account WHERE MemberId=@id ", connection)) { cmd2.Parameters.AddWithValue("@id", id); cmd2.CommandType = CommandType.Text; connection.Open(); SqlDataReader dr = cmd2.ExecuteReader(); while (dr.Read()) { DateTime payments = Convert.ToDateTime(dr["PaymentDate"]); DateTime expirations = Convert.ToDateTime(dr["ExpirationDate"]); double amounts = Convert.ToDouble(dr["Price"].ToString()); ReducedAccount c = new ReducedAccount(); c.Price = amounts; c.PaymentDate = payments; c.ExpirationDate = expirations; accounts.Add(c); } 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()); } }