public static List <Audioplatform> GetPlatforms()
        {
            ISession             session      = SessionManager.GetSession();
            List <Audioplatform> platformList = new List <Audioplatform>();


            if (session == null)
            {
                return(null);
            }

            var platforms = session.Execute("select * from \"AudioPlatform\"");


            foreach (var platformData in platforms)
            {
                Audioplatform platform = new Audioplatform();
                platform.name        = platformData["name"] != null ? platformData["name"].ToString() : string.Empty;
                platform.price       = (double)(platformData["price"] != null ? platformData["price"] : 0);
                platform.description = platformData["description"] != null ? platformData["description"].ToString() : string.Empty;
                platformList.Add(platform);
            }



            return(platformList);
        }
        private void FillControls(Customer c)
        {
            lblName.Text    = c.name;
            lblSurname.Text = c.surname;
            lblEmail.Text   = c.email;

            Audioplatform ap = DataProvider.GetPlatform(c.audio_tier);

            lblAudioTier.Text = ap.name;

            //Contract contract = DataProvider.GetContract(c.contract_start_date,c.audio_tier,c.name,c.surname);

            dtpBirthDate.Value = DateTime.Parse(customer.birth_date);

            contracts = DataProvider.GetContracts();

            foreach (Contract con in contracts)
            {
                if (con.customer_name.Equals(customer.name) && con.customer_surname.Equals(c.surname))
                {
                    int rowId = dataGridView1.Rows.Add();

                    // Grab the new row!
                    DataGridViewRow row = dataGridView1.Rows[rowId];

                    // Add the data
                    row.Cells["ColStartDate"].Value = con.start_date;
                    row.Cells["ColEndsAt"].Value    = con.end_date;
                    row.Cells["ColPlatform"].Value  = con.audio_tier;
                }
            }
        }
        public static void AddPlatform(Audioplatform platform) //postoji funkcija ali logika aplikacije je ne zahteva jer ne moze se tako dodati platforma bilo bi glupo
        {
            ISession session = SessionManager.GetSession();

            if (session == null)
            {
                return;
            }

            RowSet data = session.Execute("insert into \"AudioPlatform\" (name, price,description) values ('" + platform.name + "'," + platform.price + "'," + platform.description + "')");
        }
        public static Audioplatform GetPlatform(string name)
        {
            ISession      session  = SessionManager.GetSession();
            Audioplatform platform = new Audioplatform();

            if (session == null)
            {
                return(null);
            }

            Row platformData = session.Execute("select * from \"AudioPlatform\" where name ='" + name + "'").FirstOrDefault();

            if (platformData != null)
            {
                platform.name        = platformData["name"] != null ? platformData["name"].ToString() : string.Empty;
                platform.price       = (double)(platformData["price"] != null ? platformData["price"] : 0);
                platform.description = platformData["description"] != null ? platformData["description"].ToString() : string.Empty;
            }

            return(platform);
        }
Пример #5
0
        private void btnRegister_Click_1(object sender, EventArgs e)
        {
            customer = new Customer();
            Contract contract = new Contract();

            string   name     = txtName.Text;
            string   surname  = txtSurname.Text;
            string   password = txtPassword.Text;
            string   email    = txtEmail.Text;
            DateTime date     = dtpBirthday.Value.Date;

            if (String.IsNullOrEmpty(name) || String.IsNullOrEmpty(surname) || String.IsNullOrEmpty(email) && String.IsNullOrEmpty(password))
            {
                MessageBox.Show("All inputs must be filled", "Error registering",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
            }
            else
            {
                foreach (RadioButton r in buttons)
                {
                    if (r.Checked == true)
                    {
                        Audioplatform p     = DataProvider.GetPlatform(r.Name);
                        DateTime      dtend = DateTime.Now;
                        DateTime      end   = new DateTime(2020, dtend.Month, dtend.Day);
                        DataProvider.AddContract(DateTime.Now.ToString("yyyy-MM-dd"), end.ToString("yyyy-MM-dd"), r.Name, name, surname);
                        DataProvider.AddCustomer(name, surname, email, date.ToString("yyyy-MM-dd"), password, r.Name, p.price, DateTime.Now.ToString("yyyy-MM-dd"), end.ToString("yyyy-MM-dd"));
                        MessageBox.Show("You have successfully registred on audio platform " + p.name + " which costs" + p.price, "Wellcome!",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                }
            }
            this.Close();
        }