private void selectCustomer_Load(object sender, EventArgs e)
        {
            Connection connection = new Connection();
            connection.openConnection();

            OleDbCommand getCustomers = new OleDbCommand();
            getCustomers.Connection = connection.connection;
            getCustomers.CommandText = "SELECT * FROM Customers";

            OleDbDataReader customersReader = getCustomers.ExecuteReader();

            while (customersReader.Read())
            {
                string id = customersReader[0].ToString();
                string first_name = customersReader[1].ToString();
                string last_name = customersReader[2].ToString();
                string address = customersReader[3].ToString();
                string phone = customersReader[4].ToString();
                DateTime birthday = (DateTime)customersReader[5];

                CCustomer tmpCustomer = new CCustomer(id,first_name,last_name,address,phone,birthday);
                customersList.Items.Add(tmpCustomer);
            }
            connection.closeConnection();

            if (customersList.Items.Count == 0)
            {
                doneBtn.Enabled = false;
            }
            else
                customersList.SelectedIndex = 0;
        }
        private void addbtn_Click(object sender, EventArgs e)
        {
            if (nameTxt.Text.Length < 1 || lastNameTxt.Text.Length < 1 || addressTxt.Text.Length < 1 || phoneTxt.Text.Length < 1)
            {
                MessageBox.Show("All fields must be entered!", "Invalid Values", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (birthdayPicker.Value.AddYears(18) > DateTime.Today)
            {
                MessageBox.Show("Your employee must be atleast 18 years old!", "Invalid Birthday", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Connection connection = new Connection();

            connection.openConnection();

            OleDbCommand employeeCommand = new OleDbCommand();
            employeeCommand.Connection = connection.connection;

            string name = nameTxt.Text;
            string lastName = lastNameTxt.Text;
            string address = addressTxt.Text;
            string phone = phoneTxt.Text;
            string birthday = birthdayPicker.Value.ToShortDateString();
            string employment = DateTime.Now.ToString();

            if (edit)
            {
                employeeCommand.CommandText = "UPDATE Employees SET First_Name = '" + name + "', Last_Name = '" + lastName + "', Address = '" + address + "', Phone = '" + phone + "', Birthday = #" + birthday + "# WHERE ID = " + employee.id;
                employeeCommand.ExecuteNonQuery();

                employee.name = name;
                employee.lastName = lastName;
                employee.address = address;
                employee.phone = phone;
                employee.birthday = birthdayPicker.Value.Date;
            }
            else
            {
                employeeCommand.CommandText = "INSERT INTO Employees (First_Name,Last_Name,Address,Phone,Birthday,Employmend,Fired) VALUES ('" + name + "', '" + lastName + "', '" + address + "', '" + phone + "', #" + birthday + "#, #" + employment + "#, false)";
                employeeCommand.ExecuteNonQuery();

                employeeCommand.CommandText = "Select @@Identity";
                string idEmployee = employeeCommand.ExecuteScalar().ToString();

                employee = new CEmployee(idEmployee, name, lastName, address, phone, birthdayPicker.Value.Date, DateTime.Now, false);
            }

            connection.closeConnection();

            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
        private void selectService_Load(object sender, EventArgs e)
        {
            Connection connection = new Connection();

            connection.openConnection();

            OleDbCommand getServices = new OleDbCommand();
            getServices.Connection = connection.connection;
            getServices.CommandText = "SELECT * FROM Services";

            OleDbDataReader servicesReader = getServices.ExecuteReader();

            while (servicesReader.Read())
            {
                string id = servicesReader[0].ToString();
                string name = servicesReader[1].ToString();
                string price = servicesReader[2].ToString();
                CService tmpSerice = new CService(id, name, float.Parse(price));
                servicesList.Items.Add(tmpSerice);
            }

            OleDbCommand getEmployees = new OleDbCommand();
            getEmployees.Connection = connection.connection;
            getEmployees.CommandText = "SELECT * FROM Employees";

            OleDbDataReader employeesReader = getEmployees.ExecuteReader();

            while (employeesReader.Read())
            {
                string id = employeesReader[0].ToString();
                string first_name = employeesReader[1].ToString();
                string last_name = employeesReader[2].ToString();
                string address = employeesReader[3].ToString();
                string phone = employeesReader[4].ToString();
                DateTime birthday = (DateTime)employeesReader[5];
                DateTime dayOfEmploymend = (DateTime)employeesReader[6];
                bool fired = (bool)employeesReader[7];

                CEmployee tmpEmployee = new CEmployee(id, first_name, last_name, address, phone, birthday, dayOfEmploymend,fired);
                if (!fired)
                    employeesList.Items.Add(tmpEmployee);
            }

            connection.closeConnection();

            if (servicesList.Items.Count == 0)
            {
                doneBtn.Enabled = false;
                employeesList.Enabled = false;
            }
            else
                servicesList.SelectedIndex = 0;
        }
        private void addbtn_Click(object sender, EventArgs e)
        {
            if (nameTxt.Text.Length < 1 || lastNameTxt.Text.Length < 1 || addressTxt.Text.Length < 1 || phoneTxt.Text.Length < 1)
            {
                MessageBox.Show("All fields must be entered!", "Invalid Values", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Connection connection = new Connection();

            connection.openConnection();

            OleDbCommand customerCommand = new OleDbCommand();
            customerCommand.Connection = connection.connection;

            string name = nameTxt.Text;
            string lastName = lastNameTxt.Text;
            string address = addressTxt.Text;
            string phone = phoneTxt.Text;
            string birthday = birthdayPicker.Value.ToShortDateString();

            if (edit)
            {
                customerCommand.CommandText = "UPDATE Customers SET First_Name = '" + name + "', Last_Name = '" + lastName + "', Address = '" + address + "', Phone = '" + phone + "', Birthday = #" + birthday + "# WHERE ID = " + customer.id;
                customerCommand.ExecuteNonQuery();

                customer.name = name;
                customer.lastName = lastName;
                customer.address = address;
                customer.phone = phone;
                customer.birthday = birthdayPicker.Value.Date;
            }
            else
            {
                customerCommand.CommandText = "INSERT INTO Customers (First_Name,Last_Name,Address,Phone,Birthday) VALUES ('" + name + "', '" + lastName + "', '" + address + "', '" + phone + "', #" + birthday + "#)";
                customerCommand.ExecuteNonQuery();

                customerCommand.CommandText = "Select @@Identity";
                string idCustomer = customerCommand.ExecuteScalar().ToString();

                customer = new CCustomer(idCustomer, name, lastName, address, phone, birthdayPicker.Value.Date);
            }

            connection.closeConnection();

            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
        private void doneBtn_Click(object sender, EventArgs e)
        {
            if (nameTxt.Text.Length < 1 || priceTxt.Text.Length < 1)
            {
                MessageBox.Show("All fields must be entered!", "Invalid Values", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Connection connection = new Connection();

            connection.openConnection();

            OleDbCommand serviceCommand = new OleDbCommand();
            serviceCommand.Connection = connection.connection;

            if (edit)
            {
                serviceCommand.CommandText = "UPDATE Services SET Service_Name = '" + nameTxt.Text + "', Price = " + priceTxt.Text + " WHERE ID = " + service.id;
                serviceCommand.ExecuteNonQuery();

                service.name = nameTxt.Text;
                service.price = float.Parse(priceTxt.Text);
            }
            else
            {
                serviceCommand.CommandText = "INSERT INTO Services (Service_Name, Price) VALUES ('" + nameTxt.Text + "', " + priceTxt.Text + ")";
                serviceCommand.ExecuteNonQuery();

                serviceCommand.CommandText = "Select @@Identity";
                string serviceID = serviceCommand.ExecuteScalar().ToString();

                service = new CService(serviceID, nameTxt.Text, float.Parse(priceTxt.Text));
            }

            connection.closeConnection();

            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
        public mainForm()
        {
            InitializeComponent();

            connection = new Connection();

            // Defualt Values
            nb_TotalPrice = 0.0f;
            ab_TotalPrice = 0.0f;
            ab_TotalBills = 0;
            nb_TotalPriceTxt.Text = "0";
            nb_DeleteService.Enabled = false;
            nb_DateTimePicker.Value = DateTime.Now;
            nb_CompliteBllBtn.Enabled = false;

            DateTime firstDay = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            DateTime lastDay = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1);

            e_ToDP.Value = lastDay;
            e_FromDP.Value = firstDay;
            ab_To.Value = lastDay;
            ab_From.Value = firstDay;
        }
        private void selectPackage_Load(object sender, EventArgs e)
        {
            Connection connection = new Connection();

            connection.openConnection();

            OleDbCommand getPackages = new OleDbCommand();
            getPackages.Connection = connection.connection;
            getPackages.CommandText = "SELECT * FROM Packages";

            OleDbDataReader packageReader = getPackages.ExecuteReader();

            while (packageReader.Read())
            {
                string id = packageReader[0].ToString();
                string name = packageReader[1].ToString();
                string price = packageReader[2].ToString();

                OleDbCommand getPackageServices = new OleDbCommand();
                getPackageServices.Connection = connection.connection;
                getPackageServices.CommandText = "SELECT Services.ID, Service_Name, Price FROM Services, Package_Services WHERE Package_Services.ID_Package = " + id + " AND Services.ID = Package_Services.ID_Service";

                OleDbDataReader packageServicesReader = getPackageServices.ExecuteReader();

                List<CService> services = new List<CService>();
                while (packageServicesReader.Read())
                {
                    string serviceId = packageServicesReader[0].ToString();
                    string serviceName = packageServicesReader[1].ToString();
                    string servicePrice = packageServicesReader[2].ToString();
                    CService tmpSerice = new CService(serviceId, serviceName, float.Parse(servicePrice));
                    services.Add(tmpSerice);
                }

                CPackage tmpPackage = new CPackage(id, name, float.Parse(price), services);
                packagesList.Items.Add(tmpPackage);
            }

            OleDbCommand getEmployees = new OleDbCommand();
            getEmployees.Connection = connection.connection;
            getEmployees.CommandText = "SELECT * FROM Employees";

            OleDbDataReader employeesReader = getEmployees.ExecuteReader();

            while (employeesReader.Read())
            {
                string id = employeesReader[0].ToString();
                string first_name = employeesReader[1].ToString();
                string last_name = employeesReader[2].ToString();
                string address = employeesReader[3].ToString();
                string phone = employeesReader[4].ToString();
                DateTime birthday = (DateTime)employeesReader[5];
                DateTime dayOfEmploymend = (DateTime)employeesReader[6];
                bool fired = (bool)employeesReader[7];

                CEmployee tmpEmployee = new CEmployee(id,first_name, last_name, address, phone, birthday, dayOfEmploymend,fired);
                if (!fired)
                    employeeList.Items.Add(tmpEmployee);
            }

            connection.closeConnection();

            if (packagesList.Items.Count == 0)
            {
                doneBtn.Enabled = false;
                employeeList.Enabled = false;
            }
            else
                packagesList.SelectedIndex = 0;
        }
 public packageForm()
 {
     InitializeComponent();
     connection = new Connection();
 }