Beispiel #1
0
        public void display_data()
        {
            var context = new db_daycareContextEntities();
            var data    = from a in context.Daycares where a.dayare_status == 1

                          join e in context.Employees on a.employee_id equals e.employee_id into tmp3
                          from emp in tmp3.DefaultIfEmpty()

                          join p in context.Pets on a.pet_id equals p.pet_id into tmp
                          from pet in tmp.DefaultIfEmpty()

                          join pt in context.Pet_Types on pet.pet_type_id equals pt.pet_type_id into tmp1
                          from type in tmp1.DefaultIfEmpty()

                          join o in context.Customers on pet.customer_id equals o.customer_id into tmp2
                          from own in tmp2.DefaultIfEmpty()

                          select new
            {
                ID      = a.daycare_id,
                Pet     = pet.pet_name,
                Jenis   = type.pet_type_name,
                Owner   = own.customer_name,
                Start   = a.daycare_date,
                Pickup  = a.daycare_pickup_date,
                Pegawai = emp.employee_name
            };

            dataGridView1.DataSource = data.ToList();
        }
Beispiel #2
0
        private void EditPetForm_Load(object sender, EventArgs e)
        {
            db_daycareContextEntities context = new db_daycareContextEntities();

            List <Pet_Types> petTypes = (from t in context.Pet_Types
                                         select t).ToList();

            petTypes.Insert(0, new Pet_Types
            {
                pet_type_id   = 0,
                pet_type_name = "Please select"
            });
            typeComboBox.DataSource    = petTypes;
            typeComboBox.ValueMember   = "pet_type_id";
            typeComboBox.DisplayMember = "pet_type_name";

            List <Customers> customer = (from c in context.Customers
                                         select c).ToList();

            customer.Insert(0, new Customers
            {
                customer_id   = 0,
                customer_name = "Please select"
            });
            ownerComboBox.DataSource    = customer;
            ownerComboBox.ValueMember   = "customer_id";
            ownerComboBox.DisplayMember = "customer_name";
        }
Beispiel #3
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            var context   = new db_daycareContextEntities();
            int idDaycare = Convert.ToInt32(textBoxSearch.Text);
            var query     = (from a in context.Daycares
                             where a.daycare_id == idDaycare
                             select a);
            var daycare = query.FirstOrDefault <Daycares>();


            if (daycare != null)
            {
                var pet     = context.Pets.Find(daycare.pet_id);
                var petType = context.Pet_Types.Find(pet.pet_type_id);
                var owner   = context.Customers.Find(pet.customer_id);

                var dateDaycare = Convert.ToDateTime(daycare.daycare_date);
                var datePickup  = Convert.ToDateTime(daycare.daycare_pickup_date);

                labelPetName.Text = pet.pet_name;
                labelPetType.Text = petType.pet_type_name;
                labelOwner.Text   = owner.customer_name;
                labelStart.Text   = dateDaycare.ToString("yyyy-MM-dd");
                labelEnd.Text     = datePickup.ToString("yyyy-MM-dd");
                panelForm.Show();
            }
            else
            {
                MessageBox.Show("Maaf data yang anda cari tidak ada!");
            }
        }
Beispiel #4
0
        private void DaycareForm_Load(object sender, EventArgs e)
        {
            db_daycareContextEntities context = new db_daycareContextEntities();

            List <Employees> employees = (from t in context.Employees
                                          select t).ToList();

            employees.Insert(0, new Employees
            {
                employee_id   = 0,
                employee_name = "Please select"
            });
            comboBoxEmployee.DataSource    = employees;
            comboBoxEmployee.ValueMember   = "employee_id";
            comboBoxEmployee.DisplayMember = "employee_name";

            List <Pets> pets = (from c in context.Pets
                                select c).ToList();

            pets.Insert(0, new Pets
            {
                pet_id   = 0,
                pet_name = "Please select"
            });
            comboBoxPet.DataSource    = pets;
            comboBoxPet.ValueMember   = "pet_id";
            comboBoxPet.DisplayMember = "pet_name";
        }
Beispiel #5
0
        private void countCharger(object sender, EventArgs e)
        {
            var context    = new db_daycareContextEntities();
            int idDaycare  = int.Parse(textBoxSearch.Text);
            var daycare    = context.Daycares.Find(idDaycare);
            var pickUpDate = Convert.ToDateTime(daycare.daycare_pickup_date);
            int dateTotal  = (dateTimePickerPickupCharge.Value - pickUpDate).Days;
            int chargeCost = dateTotal * 50000;

            labelCost.Text = chargeCost.ToString();
        }
Beispiel #6
0
        private void countCost(object sender, EventArgs e)
        {
            db_daycareContextEntities context = new db_daycareContextEntities();
            int idPet   = int.Parse(comboBoxPet.SelectedValue.ToString());
            var pet     = context.Pets.Find(idPet);
            var petType = context.Pet_Types.Find(pet.pet_type_id);

            int totalDate = (dateTimePickerPickup.Value - dateTimePickerDaycare.Value).Days;
            int totalCost = totalDate * Convert.ToInt32(petType.pet_type_cost);

            labelCost.Text = totalCost.ToString();
        }
        public void display_data()
        {
            var context = new db_daycareContextEntities();
            var data    = from a in context.Customers
                          select new
            {
                ID     = a.customer_id,
                Nama   = a.customer_name,
                Alamat = a.customer_address,
                NoTelp = a.customer_phone
            };

            dataGridView1.DataSource = data.ToList();
        }
Beispiel #8
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            string nama   = textBoxSearch.Text;
            var    contex = new db_daycareContextEntities();
            var    cust   = (from a in contex.Customers where a.customer_name == nama select a).Single();

            contex.Customers.Remove(cust);
            contex.SaveChanges();

            MessageBox.Show("Data telah berhasil dihapus.");

            CustomerForm f = new CustomerForm();

            f.Show();
            this.Hide();
        }
Beispiel #9
0
        private void addCustomerButton_Click(object sender, EventArgs e)
        {
            var contex = new db_daycareContextEntities();
            var cust   = new Customers();

            cust.customer_name    = nameTextBox.Text;
            cust.customer_address = addressTextBox.Text;
            cust.customer_phone   = phoneTextBox.Text;
            contex.Customers.Add(cust);
            contex.SaveChanges();

            MessageBox.Show("Tambah data owner pet berhasil!!");

            CustomerForm f = new CustomerForm();

            f.Show();
            this.Hide();
        }
Beispiel #10
0
        private void addEmployeeButton_Click(object sender, EventArgs e)
        {
            var contex = new db_daycareContextEntities();
            var emp    = new Employees();

            emp.employee_name    = nameTextBox.Text;
            emp.employee_address = addressTextBox.Text;
            emp.employee_phone   = phoneTextBox.Text;
            contex.Employees.Add(emp);
            contex.SaveChanges();

            MessageBox.Show("Tambah data pegawai berhasil!!");

            EmployeeForm f = new EmployeeForm();

            f.Show();
            this.Hide();
        }
Beispiel #11
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            var context = new db_daycareContextEntities();
            var pet     = (from a in context.Pets
                           where a.pet_name == textBoxSearch.Text
                           select a).Single();

            pet.pet_name    = nameTextBox.Text;
            pet.customer_id = int.Parse(ownerComboBox.SelectedValue.ToString());
            pet.pet_type_id = int.Parse(typeComboBox.SelectedValue.ToString());

            context.SaveChanges();
            MessageBox.Show("Data telah berhasil diupdate.");

            PetForm f = new PetForm();

            f.Show();
            this.Hide();
        }
Beispiel #12
0
        public void display_data()
        {
            var context = new db_daycareContextEntities();
            var data    = from a in context.Pets
                          join customer in context.Customers on a.customer_id equals customer.customer_id into tmp
                          from cust in tmp.DefaultIfEmpty()
                          join petType in context.Pet_Types on a.pet_type_id equals petType.pet_type_id into tmp1
                          from type in tmp1.DefaultIfEmpty()

                          select new
            {
                ID    = a.pet_id,
                Nama  = a.pet_name,
                Jenis = type.pet_type_name,
                Owner = cust.customer_name
            };

            dataGridView1.DataSource = data.ToList();
        }
Beispiel #13
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            var context = new db_daycareContextEntities();
            var cust    = (from a in context.Customers
                           where a.customer_name == textBoxSearch.Text
                           select a).Single();

            cust.customer_name    = nameTextBox.Text;
            cust.customer_address = addressTextBox.Text;
            cust.customer_phone   = phoneTextBox.Text;

            context.SaveChanges();
            MessageBox.Show("Data telah berhasil diupdate.");

            CustomerForm f = new CustomerForm();

            f.Show();
            this.Hide();
        }
Beispiel #14
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            var context = new db_daycareContextEntities();
            var emp     = (from a in context.Employees
                           where a.employee_name == textBoxSearch.Text
                           select a).Single();

            emp.employee_name    = nameTextBox.Text;
            emp.employee_address = addressTextBox.Text;
            emp.employee_phone   = phoneTextBox.Text;

            context.SaveChanges();
            MessageBox.Show("Data telah berhasil diupdate.");

            EmployeeForm f = new EmployeeForm();

            f.Show();
            this.Hide();
        }
Beispiel #15
0
        private void proccessButton_Click(object sender, EventArgs e)
        {
            db_daycareContextEntities context = new db_daycareContextEntities();
            var daycare = new Daycares();

            daycare.employee_id         = int.Parse(comboBoxEmployee.SelectedValue.ToString());
            daycare.pet_id              = int.Parse(comboBoxPet.SelectedValue.ToString());
            daycare.daycare_date        = dateTimePickerDaycare.Value;
            daycare.daycare_pickup_date = dateTimePickerPickup.Value;
            daycare.daycare_cost        = Convert.ToInt32(labelCost.Text);
            daycare.dayare_status       = 1;

            context.Daycares.Add(daycare);
            context.SaveChanges();

            SuccessForm f = new SuccessForm();

            f.Show();
            this.Hide();
        }
Beispiel #16
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            var context = new db_daycareContextEntities();
            var query   = (from a in context.Pets
                           where a.pet_name == textBoxSearch.Text
                           select a);
            var pet = query.FirstOrDefault <Pets>();

            if (pet != null)
            {
                nameTextBox.Text            = pet.pet_name;
                ownerComboBox.SelectedValue = pet.customer_id;
                typeComboBox.SelectedValue  = pet.pet_type_id;
                panelForm.Show();
            }
            else
            {
                MessageBox.Show("Maaf data yang anda cari tidak ada!");
            }
        }
Beispiel #17
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            var context = new db_daycareContextEntities();
            var query   = (from a in context.Customers
                           where a.customer_name == textBoxSearch.Text
                           select a);
            var cust = query.FirstOrDefault <Customers>();

            if (cust != null)
            {
                nameTextBox.Text    = cust.customer_name;
                addressTextBox.Text = cust.customer_address;
                phoneTextBox.Text   = cust.customer_phone;
                panelForm.Show();
            }
            else
            {
                MessageBox.Show("Maaf data yang anda cari tidak ada!");
            }
        }
Beispiel #18
0
        private void addPetButton_Click(object sender, EventArgs e)
        {
            db_daycareContextEntities context = new db_daycareContextEntities();

            var pet = new Pets();

            pet.pet_name = nameTextBox.Text;
            //pet.customer_id = (int)ownerComboBox.SelectedIndex;
            //pet.pet_type_id = (int)typeComboBox.SelectedIndex;
            pet.customer_id = int.Parse(ownerComboBox.SelectedValue.ToString());
            pet.pet_type_id = int.Parse(typeComboBox.SelectedValue.ToString());
            context.Pets.Add(pet);
            context.SaveChanges();

            MessageBox.Show("Peliharaan berhasil ditambah!");

            PetForm f = new PetForm();

            f.Show();
            this.Hide();
        }
Beispiel #19
0
        private void buttonPickup_Click(object sender, EventArgs e)
        {
            var context = new db_daycareContextEntities();

            var pickup = new Pickups();

            pickup.daycare_id    = int.Parse(textBoxSearch.Text);
            pickup.pickup_date   = dateTimePickerPickupCharge.Value;
            pickup.pickup_charge = int.Parse(labelCost.Text);
            context.Pickups.Add(pickup);

            int daycareId = int.Parse(textBoxSearch.Text);
            var daycare   = (from a in context.Daycares
                             where a.daycare_id == daycareId
                             select a).Single();

            daycare.dayare_status = 0;
            context.SaveChanges();

            SuccessForm f = new SuccessForm();

            f.Show();
            this.Hide();
        }