Exemplo n.º 1
0
        private void button9_Click(object sender, EventArgs e)
        {
            try
            {
                sport.Close();

                ShopForm formDialog = new ShopForm();
                formDialog.ShowDialog();
                sport.Open();
            }
            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());
            }
        }
Exemplo n.º 2
0
        private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
        {
            try
            {
                string indata = sport.ReadLine();
                theNewId = Int64.Parse(indata.Trim(), NumberStyles.HexNumber);
                this.Invoke((MethodInvoker) delegate
                {
                    cardIdLabel.Text = theNewId.ToString();
                });
            }
            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());
            }
        }
Exemplo n.º 3
0
        public HomeForm(string authLevel, string username)
        {
            InitializeComponent();
            currUsername = username;
            string AuthLevel = authLevel;

            label6.Text = "Welcome back " + username + ". Your Authorization Level is " + authLevel + ".";
            if (AuthLevel == "1")
            {
                measurementsButton.Visible = false;
                shopButton.Visible         = false;
                exercisesButton.Visible    = false;
            }
            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());
            }
        }
Exemplo n.º 4
0
        private void accountForm_load(object sender, EventArgs e)
        {
            try
            {
                populateMembersInDropdown();

                dateTimePicker1.Value = (DateTime.Now.AddDays(-30));
                populateDataGridView();

                double price = 0;
                for (int i = 0; i < accounts.Count; i++)
                {
                    price = price + accounts[i].Price;
                }
                label5.Text             = price.ToString();
                label6.Text             = accounts.Count.ToString();
                comboBox1.SelectedIndex = 0;
            }
            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());
            }
        }
Exemplo n.º 5
0
        public InformationForm(string id)
        {
            InitializeComponent();
            try
            {
                this.id = id;
                string tmp = "0";
                tmp = methods.getComm();

                sport = new System.IO.Ports.SerialPort("COM" + tmp, 9600, Parity.None, 8, StopBits.One);
                if (id != "0")
                {
                    cardid.Text = cardid.Text = "---------------------------";
                    cardid.Text = id;
                }
                else
                {
                    cardid.Text = "---------------------------";
                }
            }
            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());
            }
        }
Exemplo n.º 6
0
        public AddMemberForm()
        {
            InitializeComponent();
            try
            {
                string tmp = "0";

                tmp   = methods.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());
            }
        }
Exemplo n.º 7
0
        private void button1_Click_1(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());
            }
        }
Exemplo n.º 8
0
        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());
            }
        }
Exemplo n.º 9
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(
                           global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase))
                {
                    using (SqlCommand cmd2 = new SqlCommand("SELECT COMM, PATH FROM Settings", connection))
                    {
                        cmd2.CommandType = CommandType.Text;
                        cmd2.Connection.Open();
                        SqlDataReader dr = cmd2.ExecuteReader();
                        while (dr.Read())
                        {
                            string com  = dr["COMM"].ToString();
                            string path = dr["PATH"].ToString();
                            label8.Text = path;
                            int x = Convert.ToInt32(com);
                            comboBox1.SelectedIndex = x - 1;
                        }
                        cmd2.Connection.Close();
                    }

                    using (SqlCommand cmd = new SqlCommand("SELECT username, password, authLevel FROM Admin WHERE username='******'", connection))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Connection.Open();

                        SqlDataReader dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            string user = dr["username"].ToString();
                            password           = dr["password"].ToString();
                            authLevel          = dr["authLevel"].ToString();
                            userLabel.Text     = user;
                            passwordLabel.Text = new string('*', password.Length);
                        }
                        cmd.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());
            }
        }
Exemplo n.º 10
0
        private void GetEnrollments(long id)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(
                           global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase))
                {
                    using (SqlCommand cmd2 = new SqlCommand("SELECT EnrollmentDate, Name, Surname, ExerciseId, ExerciseName, ExercisePrice FROM TrainingEnrollment WHERE MemberId=@id ", connection))
                    {
                        cmd2.Parameters.AddWithValue("@id", id);

                        cmd2.CommandType = CommandType.Text;

                        connection.Open();
                        SqlDataReader dr = cmd2.ExecuteReader();
                        while (dr.Read())
                        {
                            string   name           = Convert.ToString(dr["Name"]);
                            string   surname        = Convert.ToString(dr["Surname"]);
                            DateTime enrollmentdate = Convert.ToDateTime(dr["EnrollmentDate"].ToString());
                            int      exerciseid     = Convert.ToInt32(dr["ExerciseId"]);
                            string   exercisename   = Convert.ToString(dr["ExerciseName"]);
                            decimal  exercisePrice  = Convert.ToDecimal(dr["ExercisePrice"]);

                            TrainingEnrollment te = new TrainingEnrollment();

                            te.Name           = name;
                            te.Surname        = surname;
                            te.EnrollmentDate = enrollmentdate;
                            te.ExerciseId     = exerciseid;
                            te.ExerciseName   = exercisename;
                            te.ExercisePrice  = exercisePrice;
                            trainingEnrollments.Add(te);
                        }
                        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());
            }
        }
Exemplo n.º 11
0
        private void GetShop(long id)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(
                           global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase))
                {
                    using (SqlCommand cmd2 = new SqlCommand("SELECT PaymentDate, Name, Surname, ItemId, ItemName, ItemPrice FROM ShopPayment WHERE MemberId=@id ", connection))
                    {
                        cmd2.Parameters.AddWithValue("@id", id);

                        cmd2.CommandType = CommandType.Text;

                        connection.Open();
                        SqlDataReader dr = cmd2.ExecuteReader();
                        while (dr.Read())
                        {
                            string   name        = Convert.ToString(dr["Name"]);
                            string   surname     = Convert.ToString(dr["Surname"]);
                            DateTime paymentDate = Convert.ToDateTime(dr["PaymentDate"].ToString());
                            int      itemid      = Convert.ToInt32(dr["ItemId"]);
                            string   itemname    = Convert.ToString(dr["ItemName"]);
                            int      itemPrice   = Convert.ToInt32(dr["ItemPrice"]);

                            ShopPayment sp = new ShopPayment();

                            sp.Name        = name;
                            sp.Surname     = surname;
                            sp.PaymentDate = paymentDate;
                            sp.ItemId      = itemid;
                            sp.ItemName    = itemname;
                            sp.ItemPrice   = itemPrice;
                            shopPayments.Add(sp);
                        }
                        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());
            }
        }
Exemplo n.º 12
0
        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());
            }
        }
Exemplo n.º 13
0
        private void GetReport(long id)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(
                           global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase))
                {
                    using (SqlCommand cmd2 = new SqlCommand("SELECT Name, Surname, EntranceDate FROM Report WHERE MemberId=@id ", connection))
                    {
                        cmd2.Parameters.AddWithValue("@id", id);

                        cmd2.CommandType = CommandType.Text;

                        connection.Open();
                        SqlDataReader dr = cmd2.ExecuteReader();
                        while (dr.Read())
                        {
                            string   name          = Convert.ToString(dr["Name"]);
                            string   surname       = Convert.ToString(dr["Surname"]);
                            DateTime entranceDates = Convert.ToDateTime(dr["EntranceDate"].ToString());

                            Report c = new Report();

                            c.Name         = name;
                            c.Surname      = surname;
                            c.EntranceDate = entranceDates;
                            reports.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());
            }
        }
Exemplo n.º 14
0
        private void _cardid_TextChanged(object sender, EventArgs e)
        {
            if (methods.CheckId(cardIdLabel.Text) == false)
            {
                List <Label> Labels = new List <Label>();
                Labels.Add(MyLabel.SetOKLabel("Card already exists."));
                Labels.Add(MyLabel.SetOKLabel("There is a card with this Card Id."));

                List <Button> Buttons = new List <Button>();
                Buttons.Add(MyButton.SetOKThemeButton());
                MyMessageBox.Show(
                    Labels,
                    "",
                    Buttons,
                    MyImage.SetFailed());
            }
        }
Exemplo n.º 15
0
        public void populate()
        {
            listView1.Items.Clear();
            ImageList imgs = new ImageList();

            imgs.ImageSize  = new Size(125, 165);
            imgs.ColorDepth = ColorDepth.Depth16Bit;

            try
            {
                listView1.LargeImageList = imgs;

                for (int i = 0; i < members.Count; i++)
                {
                    string memberImagePath = path.Trim() + "Images\\" + members[i].CardId.ToString() + ext;
                    if (!File.Exists(memberImagePath))
                    {
                        memberImagePath = path.Trim() + "Images\\av2.png";
                    }

                    System.Drawing.Image img = new Bitmap(System.Drawing.Image.FromFile(memberImagePath));

                    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(members[i].id.ToString(), members[i].Name + " " + members[i].Surname, 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());
            }
        }
Exemplo n.º 16
0
        private void button6_Click(object sender, EventArgs e)
        {
            try
            {
                sport.Close();

                SettingsForm p = new SettingsForm(currUsername);
                p.ShowDialog();
                using (SqlConnection connection = new SqlConnection(
                           global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase))
                {
                    using (SqlCommand cmd = new SqlCommand("SELECT COMM FROM Settings WHERE Id=1", connection))
                    {
                        cmd.CommandType = CommandType.Text;
                        connection.Open();

                        object o = cmd.ExecuteScalar();
                        if (o != null)
                        {
                            tmp = o.ToString();
                        }
                        connection.Close();
                    }
                }
                sport = new System.IO.Ports.SerialPort("COM" + tmp, 9600, Parity.None, 8, StopBits.One);
                sport.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
                sport.Open();
            }
            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());
            }
        }
Exemplo n.º 17
0
        private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
        {
            try
            {
                string indata = sport.ReadLine();
                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", indata);
                        connection.Open();

                        object o = cmd.ExecuteScalar();
                        if (o != null)
                        {
                            sport.Close();
                            InformationForm ev = new InformationForm(indata);
                            ev.ShowDialog();
                            ev.Focus();
                            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());
            }
        }
Exemplo n.º 18
0
        public SearchMembersForm()
        {
            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());
            }
        }
Exemplo n.º 19
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                InformationForm ev = new InformationForm(a.CardId.ToString());
                ev.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());
            }
        }
Exemplo n.º 20
0
        private void AddMemberForm_Load(object sender, EventArgs e)
        {
            try
            {
                sport.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
                sport.Open();
                monthsno.SelectedIndex = 0;
                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 + "\\";
            }
            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());
            }
        }
Exemplo n.º 21
0
        private void reportFormButtonClick(object sender, EventArgs e)
        {
            try
            {
                sport.Close();
                InformationForm ev = new InformationForm("0");
                ev.ShowDialog();
                sport.Open();
            }
            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());
            }
        }
Exemplo n.º 22
0
        private void GetInfo()
        {
            try
            {
                int i = Convert.ToInt32(globalId);

                using (SqlConnection connection = new SqlConnection(
                           global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase))
                {
                    using (SqlCommand cmd2 = new SqlCommand("SELECT Name, Surname, CardId, Address, PhoneNumber, TypeId, NumOfEntrances, Gender, " +
                                                            "LastEntrance FROM Member WHERE id=@id", connection))
                    {
                        connection.Open();
                        cmd2.CommandType = CommandType.Text;
                        cmd2.Parameters.AddWithValue("@id", i);

                        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   typeid1         = dr["TypeId"].ToString();
                            long     cardId1         = Convert.ToInt64(dr["CardId"]);
                            int      numofentrances1 = Convert.ToInt32(dr["NumOfEntrances"]);
                            DateTime lastEntr        = Convert.ToDateTime(dr["LastEntrance"]);
                            string   gender1         = dr["Gender"].ToString();

                            DateTime z = methods.GetExpirationDate(i);
                            if (lastEntr.Date != DateTime.Today)
                            {
                                numofentrances1++;
                                methods.WriteEntrance(i, numofentrances1, name1, surname1);
                            }
                            string date = z.Day + "/" + z.Month + "/" + z.Year;
                            methods.WriteLastEntrance(i);
                            lastEntr = DateTime.Now;


                            panel1.Visible = true;
                            label14.Text   = name1;
                            label8.Text    = surname1;
                            label4.Text    = gender1;
                            label24.Text   = address1;
                            label22.Text   = phoneno1;
                            label21.Text   = date;
                            label20.Text   = cardId1.ToString();
                            label15.Text   = typeid1;
                            label17.Text   = numofentrances1.ToString();


                            a.Name           = name1;
                            a.Surname        = surname1;
                            a.Address        = address1;
                            a.PhoneNumber    = phoneno1;
                            a.TypeId         = typeid1;
                            a.NumOfEntrances = numofentrances1;
                            a.ExpirationDate = z;
                            a.CardId         = cardId1;
                            a.LastEntrance   = lastEntr;
                            a.Gender         = gender1;
                            a.id             = i;
                        }
                    }
                    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());
            }
        }
Exemplo n.º 23
0
        public void ExportToPdf(DataTable ExDataTable)
        {
            Document pdfDoc = new Document(PageSize.A4, 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//Report_" + s + "-" + Guid.NewGuid().ToString() + ".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("Report ID: " + Guid.NewGuid().ToString(), new
                                               iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 12, iTextSharp.text.Font.NORMAL, new BaseColor(0, 0, 0)));

                Paragraph date = new Paragraph("Date: " + s, new
                                               iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 18, iTextSharp.text.Font.BOLD, new BaseColor(0, 0, 0)));

                Paragraph newline = new Paragraph("\n");

                Paragraph dateaccounts = new Paragraph("From " + dateTimePicker1.Value.ToString("dd/MM/yyyy") + " to " + dateTimePicker2.Value.ToString("dd/MM/yyyy"),
                                                       new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 14, iTextSharp.text.Font.BOLD, new BaseColor(0, 0, 0)));

                Paragraph reportGeneratedFor = new Paragraph("Report Generated For: " + comboBox1.SelectedItem,
                                                             new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 14, iTextSharp.text.Font.BOLD, new BaseColor(0, 0, 0)));

                pdfDoc.Add(image);
                pdfDoc.Add(newline);
                pdfDoc.Add(newline);
                pdfDoc.Add(guid);
                pdfDoc.Add(date);

                pdfDoc.Add(dateaccounts);
                pdfDoc.Add(reportGeneratedFor);
                pdfDoc.Add(newline);
                pdfDoc.Add(newline);
                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);
                    PdfTable.SetWidths(new int[] { 35, 135, 135, 35, 80, 80, 55 });
                    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(newline);
                pdfDoc.Add(newline);
                Paragraph p4 = new Paragraph("Total Amount: " + label5.Text + " KM", fnt);
                Paragraph p5 = new Paragraph("Number of Payments: " + label6.Text, fnt);
                p4.Alignment = Element.ALIGN_CENTER;
                p5.Alignment = Element.ALIGN_CENTER;
                pdfDoc.Add(p4);
                pdfDoc.Add(p5);

                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());
            }
        }
Exemplo n.º 24
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string tmp       = "";
            string authLevel = "";

            try
            {
                using (SqlConnection connection = new SqlConnection(
                           global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase))
                {
                    using (SqlCommand cmd = new SqlCommand("SELECT password, authLevel FROM Admin WHERE username=@user", connection))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@user", userBox.Text);

                        connection.Open();

                        SqlDataReader o = cmd.ExecuteReader();
                        if (o != null)
                        {
                            while (o.Read())
                            {
                                tmp       = o["password"].ToString();
                                authLevel = o["authLevel"].ToString();
                            }
                        }
                        connection.Close();
                    }
                }

                if (passBox.Text != tmp || tmp == "")
                {
                    List <Label> Labels = new List <Label>();
                    Labels.Add(MyLabel.SetOKLabel("Login Failed!"));
                    Labels.Add(MyLabel.SetOKLabel("Incorrect Username/Password"));

                    List <Button> Buttons = new List <Button>();
                    Buttons.Add(MyButton.SetOKThemeButton());
                    MyMessageBox.Show(
                        Labels,
                        "",
                        Buttons,
                        MyImage.SetFailed());
                    userBox.Text = "";
                    passBox.Text = "";
                }
                else
                {
                    List <Label> Labels = new List <Label>();
                    Labels.Add(MyLabel.SetOKLabel("Successfull Login!"));
                    Labels.Add(MyLabel.SetOKLabel("Welcome Back " + userBox.Text + "!"));

                    List <Button> Buttons = new List <Button>();
                    Buttons.Add(MyButton.SetOKThemeButton());
                    MyMessageBox.Show(
                        Labels,
                        "",
                        Buttons,
                        MyImage.SetSuccess());

                    HomeForm h = new HomeForm(authLevel, userBox.Text);
                    h.MaximizeBox = false;
                    h.MinimizeBox = false;
                    this.Hide();
                    h.ShowDialog();
                    this.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());
            }
        }
Exemplo n.º 25
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (label8.Text == "")
            {
                List <Label> Labels = new List <Label>();
                Labels.Add(MyLabel.SetOKLabel("General Error"));
                Labels.Add(MyLabel.SetOKLabel("Please enter location: "));

                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 Settings SET COMM=@c,PATH=@p WHERE Id=1 ", connection))
                        {
                            int x = comboBox1.SelectedIndex + 1;
                            command.Parameters.AddWithValue("@c", x);
                            command.Parameters.AddWithValue("@p", label8.Text);
                            command.Connection.Open();

                            if (command.ExecuteNonQuery().ToString() == "1")
                            {
                                List <Label> Labels = new List <Label>();
                                Labels.Add(MyLabel.SetOKLabel("Settings Changed Successfully"));
                                Labels.Add(MyLabel.SetOKLabel("Settings changed"));

                                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("Settings change Failed"));
                                Labels.Add(MyLabel.SetOKLabel("Settings not changed"));

                                List <Button> Buttons = new List <Button>();
                                Buttons.Add(MyButton.SetOKThemeButton());
                                MyMessageBox.Show(
                                    Labels,
                                    "",
                                    Buttons,
                                    MyImage.SetSuccess());

                                command.Connection.Close();
                                this.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());
                }
            }
        }
Exemplo n.º 26
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (visibilitylevel == 1)
            {
                if (formbox1.Text != password)
                {
                    formbox1.Text = "";
                    formbox2.Text = "";
                    formbox3.Text = "";

                    label1.Text = "Password is incorrect!";
                    errorProvider1.SetError(formbox1, "Password is incorrect");
                }
                else if (formbox2.Text.Length <= 5)
                {
                    formbox2.Text = "";
                    formbox3.Text = "";
                    errorProvider1.SetError(formbox1, "");
                    label1.Text = "Password has to be longer than 5 characters!";
                    errorProvider1.SetError(formbox2, "Password has to be longer than 5 characters!");
                }
                else if (formbox2.Text != formbox3.Text)
                {
                    formbox2.Text = "";
                    formbox3.Text = "";
                    label1.Text   = "Passwords aren't equal!";
                    errorProvider1.SetError(formbox2, "Passwords aren't equal!");
                    errorProvider1.SetError(formbox3, "Passwords aren't equal!");
                }
                else
                {
                    try
                    {
                        label1.Text = "";
                        errorProvider1.SetError(formbox2, "");
                        errorProvider1.SetError(formbox3, "");
                        using (SqlConnection connection = new SqlConnection(global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase))
                        {
                            using (SqlCommand command = new SqlCommand("UPDATE Admin SET password=@s WHERE username='******'", connection))
                            {
                                command.Parameters.AddWithValue("@s", formbox2.Text);
                                command.Connection.Open();

                                if (command.ExecuteNonQuery().ToString() == "1")
                                {
                                    List <Label> Labels = new List <Label>();
                                    Labels.Add(MyLabel.SetOKLabel("Password Change"));
                                    Labels.Add(MyLabel.SetOKLabel("Password changed successfully"));

                                    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("Password Change"));
                                    Labels.Add(MyLabel.SetOKLabel("Password Change failed"));

                                    List <Button> Buttons = new List <Button>();
                                    Buttons.Add(MyButton.SetOKThemeButton());
                                    MyMessageBox.Show(
                                        Labels,
                                        "",
                                        Buttons,
                                        MyImage.SetFailed());
                                }

                                formbox1.Text = "";
                                formbox2.Text = "";
                                formbox3.Text = "";

                                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());
                    }
                }
            }
            else if (visibilitylevel == 2)
            {
                if (authLevel == "2")
                {
                    try
                    {
                        using (SqlConnection connection2 = new SqlConnection(
                                   global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase))
                        {
                            using (SqlCommand cmd = new SqlCommand("INSERT INTO Admin(username, password, authLevel)" +
                                                                   "VALUES(@username, @password, @authLevel)", connection2))
                            {
                                cmd.Parameters.AddWithValue("@username", formbox1.Text);
                                cmd.Parameters.AddWithValue("@password", formbox2.Text);
                                cmd.Parameters.AddWithValue("@authLevel", formbox3.Text);

                                cmd.Connection.Open();

                                if (cmd.ExecuteNonQuery().ToString() == "1")
                                {
                                    List <Label> Labels = new List <Label>();
                                    Labels.Add(MyLabel.SetOKLabel("Created new superuser"));
                                    Labels.Add(MyLabel.SetOKLabel("New superuser created successfully"));

                                    List <Button> Buttons = new List <Button>();
                                    Buttons.Add(MyButton.SetOKThemeButton());
                                    MyMessageBox.Show(
                                        Labels,
                                        "",
                                        Buttons,
                                        MyImage.SetSuccess());


                                    formbox1.Text = "";
                                    formbox2.Text = "";
                                    formbox3.Text = "";
                                }
                            }

                            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());
                    }
                }
                else
                {
                    List <Label> Labels = new List <Label>();
                    Labels.Add(MyLabel.SetOKLabel("Unavailable"));
                    Labels.Add(MyLabel.SetOKLabel("You don't have the Auth Level of 1"));

                    List <Button> Buttons = new List <Button>();
                    Buttons.Add(MyButton.SetOKThemeButton());
                    MyMessageBox.Show(
                        Labels,
                        "",
                        Buttons,
                        MyImage.SetFailed());
                }
            }
        }
Exemplo n.º 27
0
        private void HomeForm_Load(object sender, EventArgs e)
        {
            timer1.Start();
            try
            {
                using (SqlConnection connection = new SqlConnection(global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase))
                {
                    bool tmp = false;
                    using (SqlCommand cmd = new SqlCommand("SELECT PATH FROM Settings WHERE Id=1", connection))
                    {
                        cmd.CommandType = CommandType.Text;

                        connection.Open();

                        object o = cmd.ExecuteScalar();
                        if (o != null)
                        {
                            if (o.ToString() == "")
                            {
                                tmp = true;
                            }
                            else
                            {
                                tmp = false;
                            }
                        }
                        else
                        {
                            tmp = true;
                        }

                        cmd.Connection.Close();
                    }
                    if (tmp)
                    {
                        using (SqlCommand command = new SqlCommand("UPDATE Settings SET PATH=@p WHERE Id=1 ", connection))
                        {
                            string wanted_path = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()));

                            command.Parameters.AddWithValue("@p", wanted_path);
                            command.Connection.Open();
                            command.ExecuteNonQuery();

                            command.Connection.Close();
                        }
                    }
                }

                sport.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);

                sport.Open();
            }
            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());
            }
        }
Exemplo n.º 28
0
        private void button3_Click(object sender, EventArgs e)
        {
            members.Clear();
            string genderCheckBox = "";
            string query          = "";

            if (radioButton5.Checked)
            {
                genderCheckBox = "Male";
            }
            else if (radioButton6.Checked)
            {
                genderCheckBox = "Female";
            }

            if (genderCheckBox != "")
            {
                query = "SELECT id, Name, Surname, CardId, TypeId, NumOfEntrances, Gender, " +
                        "LastEntrance, PhoneNumber, Address FROM Member WHERE (Name LIKE '%' + @d + '%' OR Surname LIKE '%' +  @d +'%') AND Gender = @g";
            }
            else
            {
                query = "SELECT id, Name, Surname, CardId, TypeId, NumOfEntrances, Gender, " +
                        "LastEntrance, PhoneNumber, Address FROM Member WHERE Name LIKE '%' + @d + '%' OR Surname LIKE '%' +  @d +'%'";
            }
            try
            {
                using (SqlConnection connection = new SqlConnection(
                           global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase))
                {
                    using (SqlCommand cmd2 = new SqlCommand(query, connection))
                    {
                        cmd2.Parameters.AddWithValue("@d", name.Text);
                        if (genderCheckBox != "")
                        {
                            cmd2.Parameters.AddWithValue("@g", genderCheckBox);
                        }
                        cmd2.CommandType = CommandType.Text;
                        connection.Open();
                        SqlDataReader dr = cmd2.ExecuteReader();
                        while (dr.Read())
                        {
                            int      id2          = 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 = method.GetExpirationDate(id2);

                            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             = id2;
                            newMember.NumOfDays      = method.GetNumberOfEntrances(cardid.ToString());
                            members.Add(newMember);
                        }

                        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());
            }
        }
Exemplo n.º 29
0
        private void GetMembers()
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(
                           global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase))
                {
                    using (SqlCommand cmd2 = new SqlCommand("SELECT id, Name, Surname, Address, PhoneNumber, CardId, TypeId," +
                                                            " NumOfEntrances, Gender, LastEntrance FROM Member", connection))
                    {
                        cmd2.CommandType = CommandType.Text;
                        connection.Open();
                        SqlDataReader dr = cmd2.ExecuteReader();
                        while (dr.Read())
                        {
                            long     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 = method.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;
                            if (gender.Trim() == "Female")
                            {
                                female++;
                            }
                            else
                            {
                                male++;
                            }
                            newMember.id        = id;
                            newMember.NumOfDays = method.GetNumberOfEntrances(cardid.ToString());
                            members.Add(newMember);
                        }

                        label9.Text  = members.Count.ToString();
                        label2.Text  = male.ToString();
                        label10.Text = female.ToString();
                        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());
            }
        }
Exemplo n.º 30
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (cardIdLabel.Text == "______________________")
                {
                    List <Label> Labels = new List <Label>();
                    Labels.Add(MyLabel.SetOKLabel("Card doesn't exist"));
                    Labels.Add(MyLabel.SetOKLabel("Please put your card to the scanner"));

                    List <Button> Buttons = new List <Button>();
                    Buttons.Add(MyButton.SetOKThemeButton());
                    MyMessageBox.Show(
                        Labels,
                        "",
                        Buttons,
                        MyImage.SetFailed());
                    sport.Write("#ERROR: Card doesn't exist!\n");
                }
                else if (pictureBox1.BackgroundImage == null)
                {
                    List <Label> Labels = new List <Label>();
                    Labels.Add(MyLabel.SetOKLabel("Image is empty"));
                    Labels.Add(MyLabel.SetOKLabel("Please upload your image"));

                    List <Button> Buttons = new List <Button>();
                    Buttons.Add(MyButton.SetOKThemeButton());
                    MyMessageBox.Show(
                        Labels,
                        "",
                        Buttons,
                        MyImage.SetFailed());
                    sport.Write("#ERROR: Image is empty!\n");
                }
                else if (radioButton2.Checked == false && radioButton3.Checked == false)
                {
                    List <Label> Labels = new List <Label>();
                    Labels.Add(MyLabel.SetOKLabel("Card type empty"));
                    Labels.Add(MyLabel.SetOKLabel("Please select a card type"));

                    List <Button> Buttons = new List <Button>();
                    Buttons.Add(MyButton.SetOKThemeButton());
                    MyMessageBox.Show(
                        Labels,
                        "",
                        Buttons,
                        MyImage.SetFailed());
                    sport.Write("#ERROR: Card type is empty!\n");
                }
                else if (radioButton5.Checked == false && radioButton6.Checked == false)
                {
                    List <Label> Labels = new List <Label>();
                    Labels.Add(MyLabel.SetOKLabel("Gender is empty"));
                    Labels.Add(MyLabel.SetOKLabel("Please select a gender!"));

                    List <Button> Buttons = new List <Button>();
                    Buttons.Add(MyButton.SetOKThemeButton());
                    MyMessageBox.Show(
                        Labels,
                        "",
                        Buttons,
                        MyImage.SetFailed());
                    sport.Write("#ERROR: Gender is empty!\n");
                }
                else if (methods.CheckId(cardIdLabel.Text) == false)
                {
                    List <Label> Labels = new List <Label>();
                    Labels.Add(MyLabel.SetOKLabel("Card already exists!"));
                    Labels.Add(MyLabel.SetOKLabel("There is a card in the database!"));

                    List <Button> Buttons = new List <Button>();
                    Buttons.Add(MyButton.SetOKThemeButton());
                    MyMessageBox.Show(
                        Labels,
                        "",
                        Buttons,
                        MyImage.SetFailed());
                    sport.Write("#ERROR: Already a member!\n");
                }

                else
                {
                    using (SqlConnection connection = new SqlConnection(
                               global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase))
                    {
                        using (SqlCommand command = new SqlCommand("INSERT INTO Member(Name,Surname,Address,PhoneNumber,CardId,TypeId,NumOfEntrances,Gender,LastEntrance)" +
                                                                   "VALUES(@Name,@Surname,@Address,@PhoneNumber,@CardId,@TypeId,@NumOfEntrances, @Gender, @LastEntrance)", connection))
                        {
                            string cardType = " ";
                            string gender   = " ";
                            if (radioButton2.Checked == true)
                            {
                                cardType = "Student";
                            }
                            if (radioButton3.Checked == true)
                            {
                                cardType = "Work";
                            }
                            if (radioButton5.Checked == true)
                            {
                                gender = "Male";
                            }
                            if (radioButton6.Checked == true)
                            {
                                gender = "Female";
                            }

                            command.Parameters.AddWithValue("Name", name.Text);
                            command.Parameters.AddWithValue("Surname", surname.Text);
                            command.Parameters.AddWithValue("Address", address.Text);
                            command.Parameters.AddWithValue("PhoneNumber", phoneno.Text);
                            command.Parameters.AddWithValue("Cardid", Convert.ToInt64(cardIdLabel.Text));
                            command.Parameters.AddWithValue("TypeId", cardType);
                            command.Parameters.AddWithValue("NumOfEntrances", 1);
                            command.Parameters.AddWithValue("Gender", gender);
                            command.Parameters.AddWithValue("LastEntrance", DateTime.Now);


                            command.Connection.Open();

                            if (command.ExecuteNonQuery().ToString() == "1")
                            {
                                List <Label> Labels = new List <Label>();
                                Labels.Add(MyLabel.SetOKLabel("Member insertion."));
                                Labels.Add(MyLabel.SetOKLabel("Member insertion passed."));

                                List <Button> Buttons = new List <Button>();
                                Buttons.Add(MyButton.SetOKThemeButton());
                                MyMessageBox.Show(
                                    Labels,
                                    "",
                                    Buttons,
                                    MyImage.SetSuccess());
                                if (cardType == "Student")
                                {
                                    sport.Write("#SUCCS: Your membership is 40 KM!\n");
                                }
                                else
                                {
                                    sport.Write("#SUCCS: Your membership is 50 KM!\n");
                                }
                            }
                            else
                            {
                                List <Label> Labels = new List <Label>();
                                Labels.Add(MyLabel.SetOKLabel("Member insertion."));
                                Labels.Add(MyLabel.SetOKLabel("Member insertion failed."));

                                List <Button> Buttons = new List <Button>();
                                Buttons.Add(MyButton.SetOKThemeButton());
                                MyMessageBox.Show(
                                    Labels,
                                    "",
                                    Buttons,
                                    MyImage.SetFailed());
                            }
                            command.Connection.Close();
                        }
                        int p = methods.GetMemberId(cardIdLabel.Text);

                        using (SqlCommand command2 = new SqlCommand("INSERT INTO Account(PaymentDate,ExpirationDate,Price,Name,Surname,MemberId)" +
                                                                    "VALUES(@PaymentDate,@ExpirationDate,@Price,@Name,@Surname,@MemberId)", connection))
                        {
                            command2.Parameters.AddWithValue("PaymentDate", DateTime.Today);
                            command2.Parameters.AddWithValue("ExpirationDate", DateTime.Today.AddDays(30 * (monthsno.SelectedIndex + 1)));
                            command2.Parameters.AddWithValue("Price", price.Text);
                            command2.Parameters.AddWithValue("Name", name.Text);
                            command2.Parameters.AddWithValue("Surname", surname.Text);
                            command2.Parameters.AddWithValue("MemberId", p);
                            command2.Connection.Open();

                            command2.ExecuteNonQuery();

                            command2.Connection.Close();
                        }
                        using (SqlCommand command3 = new SqlCommand("INSERT INTO Report(MemberId,EntranceDate,Name,Surname) VALUES(@MemberId,@EntranceDate,@Name,@Surname)", connection))
                        {
                            command3.Parameters.AddWithValue("@MemberId", p);
                            command3.Parameters.AddWithValue("@EntranceDate", DateTime.Now);
                            command3.Parameters.AddWithValue("@Name", name.Text);
                            command3.Parameters.AddWithValue("@Surname", surname.Text);

                            command3.Connection.Open();
                            command3.ExecuteNonQuery();

                            command3.Connection.Close();
                        }

                        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();
                        }

                        saveImage();
                        this.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());
            }
        }