コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            String oldName = textBox1.Text;
            String newName = textBox2.Text;
            String price   = textBox3.Text;

            String result = null;

            if (!(newName == "" || price == "" || price == ""))
            {
                Type            obj               = Type.GetType(ConfigurationManager.AppSettings["DefaultRepositoryServicii"]);
                ConstructorInfo constructor       = obj.GetConstructor(new Type[] { });
                IServiciiDAO    defaultRepository = (IServiciiDAO)constructor.Invoke(null);

                ServiciiService serviciiService = new ServiciiService(defaultRepository);

                result = serviciiService.updateService(oldName, newName, price);
            }

            if (result == null)
            {
                MessageBox.Show("Something went wrong");
            }
            else
            {
                MessageBox.Show("Service updated successfully!");
            }
            this.Close();
        }
コード例 #2
0
        public String addProgramare(String date, String name, String telefon, String services, String ora)
        {
            Type            obj                = Type.GetType(ConfigurationManager.AppSettings["DefaultRepositoryServicii"]);
            ConstructorInfo constructor        = obj.GetConstructor(new Type[] { });
            IServiciiDAO    serviciiRepository = (IServiciiDAO)constructor.Invoke(null);

            String[] s = services.Split(',');

            int cost = 0;

            foreach (String w in s)
            {
                if (verifIfTaken(w, date, ora))
                {
                    return("ERROR! Service: " + w + " is taken. Choose another!");
                }
                Serviciu u = serviciiRepository.getService(w);
                if (u == null)
                {
                    return(null);
                }
                else
                {
                    cost += u.getPrice();
                }
            }

            String result = _repository.addProgramare(date, ora, name, telefon, services, cost);

            return(result);
        }
コード例 #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            Type            obj               = Type.GetType(ConfigurationManager.AppSettings["DefaultRepositoryServicii"]);
            ConstructorInfo constructor       = obj.GetConstructor(new Type[] { });
            IServiciiDAO    defaultRepository = (IServiciiDAO)constructor.Invoke(null);

            ServiciiService serviciiService = new ServiciiService(defaultRepository);

            String result = serviciiService.getServicii(null);

            MessageBox.Show(result);
        }
コード例 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            String date     = monthCalendar1.SelectionRange.Start.ToShortDateString();
            String name     = textBox1.Text;
            String telefon  = textBox2.Text;
            String services = textBox3.Text;
            String ora      = textBox4.Text;

            String result = null;

            Type            obj               = Type.GetType(ConfigurationManager.AppSettings["DefaultRepositoryProgramari"]);
            ConstructorInfo constructor       = obj.GetConstructor(new Type[] { });
            IProgramareDAO  defaultRepository = (IProgramareDAO)constructor.Invoke(null);

            ProgramareService programareService = new ProgramareService(defaultRepository);

            Type            obj1               = Type.GetType(ConfigurationManager.AppSettings["DefaultRepositoryServicii"]);
            ConstructorInfo constructor1       = obj1.GetConstructor(new Type[] { });
            IServiciiDAO    defaultRepository1 = (IServiciiDAO)constructor1.Invoke(null);

            ServiciiService serviciiService = new ServiciiService(defaultRepository1);

            String serviciiAvailable = null;


            if (!(name == "" || telefon == "" || services == "" || ora == ""))
            {
                result = programareService.addProgramare(date, name, telefon, services, ora);

                if (result == null)
                {
                    serviciiAvailable = serviciiService.getServicii(null);
                    MessageBox.Show("Something went wrong!\n\n" + serviciiAvailable);
                }
                else if (result.Substring(0, 6).Equals("ERROR!"))
                {
                    String[] s = result.Split(' ');
                    serviciiAvailable = serviciiService.getServicii(s[2]);
                    MessageBox.Show(result + "\n" + serviciiAvailable);
                }
                else
                {
                    MessageBox.Show("Appointment booked successfully!");
                }
            }
            else
            {
                MessageBox.Show("Fields must not be empty!");
            }
        }
コード例 #5
0
 public ServiciiService(IServiciiDAO repository)
 {
     _repository = repository;
 }