示例#1
0
 private void ShowInfo()
 {
     using (var ctx = new DbAccess())
     {
         this.service_title_lbl.Text = ctx.Services.Where(p => p.Id == Id).Select(u => u.Title).FirstOrDefault();
         this.service_address_lbl.Text = ctx.Services.Where<Service>(p => p.Id == Id).Select(u => u.Address).FirstOrDefault();
         this.service_hours_lbl.Text = ctx.Services.Where(p => p.Id == Id).Select(u => u.OpenHours).FirstOrDefault();
         this.service_desc_lbl.Text = ctx.Services.Where(p => p.Id == Id).Select(u => u.Description).FirstOrDefault();
     }
 }
示例#2
0
        private void GetServices()
        {
            using (var ctx = new DbAccess())
            {
                var services = ctx.Services.OrderBy(x => x.Title).ToList<Service>();

                this.services_list.DataSource = services;
                this.services_list.ValueMember = "Id";
                this.services_list.DisplayMember = "Title";
            };
        }
示例#3
0
        private void register_ok_button_Click(object sender, EventArgs e)
        {
            if (this.DisplayRole() == "service")
            {
                Service service = new Service()
                {
                    Title = this.service_title_txt.Text,
                    Address = this.service_address_txt.Text,
                    OpenHours = this.service_open_hours.Text,
                    Description = this.service_description.Text
                };

                using(DbAccess ctx = new DbAccess())
                {
                    ctx.Services.Add(service);
                    ctx.SaveChanges();

                    //MessageBox.Show(ctx.Services.FirstOrDefault().Title);
                }
            }
            else if(this.DisplayRole() == "account")
            {
                bool smoker = false;

                if (this.acc_smoker_radio.Checked)
                {
                    smoker = true;
                }

                Account account = new Account()
                {
                    FirstName = this.acc_first_name_txt.Text,
                    LastName = this.acc_last_name_txt.Text,
                    Age = this.GetAge(),
                    Smoker = smoker
                };

                using(DbAccess ctx = new DbAccess())
                {
                    ctx.Accounts.Add(account);
                }
            }

            this.Dispose();
        }