Exemplo n.º 1
0
        private void button4_Click(object sender, EventArgs e)
        {
            ExtendMemberShipForm extendmembershipform = new ExtendMemberShipForm(a);

            extendmembershipform.ShowDialog();
        }
Exemplo n.º 2
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (name.Text != "---------------------------")
            {
                ExtendMemberShipForm extendmembershipform = new ExtendMemberShipForm(a);
                extendmembershipform.ShowDialog();

                Int64 i = Convert.ToInt64(cardid.Text);

                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 responseid = o.ToString();
                            int    k          = Convert.ToInt32(responseid);
                            using (SqlCommand cmd2 = new SqlCommand("SELECT Name, Surname, Address, PhoneNumber, TypeId," +
                                                                    "NumOfEntrances, Gender, LastEntrance FROM Member WHERE id=@idd", connection))
                            {
                                cmd2.CommandType = CommandType.Text;
                                cmd2.Parameters.AddWithValue("@idd", k);

                                SqlDataReader dr = cmd2.ExecuteReader();
                                while (dr.Read())
                                {
                                    string   name1      = dr["Name"].ToString();
                                    string   surname1   = dr["Surname"].ToString();
                                    string   address1   = dr["Address"].ToString();
                                    string   phoneno1   = dr["PhoneNumber"].ToString();
                                    string   type1      = dr["TypeId"].ToString();
                                    int      numofentr1 = Convert.ToInt32(dr["NumOfEntrances"]);
                                    DateTime lastent1   = Convert.ToDateTime(dr["LastEntrance"]);
                                    string   gender1    = dr["Gender"].ToString();

                                    DateTime z = methods.GetExpirationDate(k);
                                    if (lastent1.Date != DateTime.Today.Date)
                                    {
                                        numofentr1++;
                                        methods.WriteEntrance(k, numofentr1, name1, surname1);
                                    }
                                    methods.WriteLastEntrance(k);
                                    lastent1 = DateTime.Now;

                                    a.Name           = name1;
                                    a.Surname        = surname1;
                                    a.Address        = address1;
                                    a.PhoneNumber    = phoneno1;
                                    a.TypeId         = type1;
                                    a.NumOfEntrances = numofentr1;
                                    a.ExpirationDate = z;
                                    a.CardId         = i;
                                    a.LastEntrance   = lastent1;
                                    a.Gender         = gender1;
                                    a.id             = k;
                                }
                            }
                            connection.Close();
                            cardid.Text = "---------------------------";
                            cardid.Text = i.ToString();
                        }
                    }
                }
            }
        }