Beispiel #1
0
        private void addAppointment_Click(object sender, EventArgs e)
        {
            int counter  = 0;
            int overload = 0;

            conn.Open();
            MySqlCommand mysqlcommand3 = conn.CreateCommand();

            mysqlcommand3.CommandText = "Select * from appointment where visitingDate='" + dateTimePicker.Text + "' and visitingTime='" + timeComboBox.Text + "' and doctorId='" + doctorEntry.Text + "'";
            MySqlDataReader reader = mysqlcommand3.ExecuteReader();

            while (reader.Read())
            {
                counter++;
            }
            reader.Close();
            conn.Close();

            if (counter > 4)
            {
                overload = 1;
                MessageBox.Show("Sorry.No more persons can be appointed to that period");
            }



            double visitCost = 0;

            visitCost = 6000.00;

            if (!isPhoneNumber(telephone.Text))
            {
                MessageBox.Show("Not a valid phone number");
            }

            if (overload < 1 && isPhoneNumber(telephone.Text))
            {
                string paymentStatus     = "UnPaid";
                string appointmentStatus = "Active";

                Crud clash = new Crud();
                clash.handleClash("appointment", "appointmentId", "appoint", appointmentIdBox);

                Appointment addAppointment = new Appointment(appointmentIdBox.Text, doctorEntry.Text, patientIdBox.Text, dateTimePicker.Text, timeComboBox.Text, visitCost, paymentStatus, appointmentStatus);
                addAppointment.addAppointment();

                Patient patient = new Patient(patientIdBox.Text, firstNameEntry.Text, lastNameEntry.Text, genderEntry.Text, telephone.Text);
                patient.addPatient();

                firstNameEntry.Clear(); lastNameEntry.Clear(); genderEntry.Text = ""; telephone.Clear();

                Random rnd          = new Random();
                int    appointment2 = rnd.Next(1, 9999);
                int    patient2     = rnd.Next(1, 9999);
                appointmentIdBox.Text = "appoint" + appointment2;
                patientIdBox.Text     = "patient" + patient2;
            }
        }
Beispiel #2
0
        private void AddGlass_Click(object sender, EventArgs e)
        {
            Random rnd    = new Random();
            int    saleId = rnd.Next(1, 9999);

            DateTime date       = DateTime.Now;
            string   formatDate = string.Format("{0:D}", date);

            double totalCost, amountPaidNow, balance;

            totalCost     = Math.Round(Convert.ToDouble(glassesCost.Text), 2);
            amountPaidNow = Math.Round(Convert.ToDouble(amountPaid.Text), 2);
            balance       = totalCost - amountPaidNow;

            string  saleIdNum  = "sale" + saleId.ToString();
            Sale    saleRecord = new Sale(saleIdNum, patientSaleId.Text, glassesBrand.Text, frameColourCombo.Text, formatDate, totalCost, balance);
            Crud    clash      = new Crud();
            TextBox sales      = new TextBox();

            sales.Text = saleIdNum;
            clash.handleClash("sale", "saleId", "sale", sales);
            saleRecord.addSale();


            int quantity    = int.Parse(quantityBox.Text);
            int newQuantity = quantity - 1;

            conn.Open();
            MySqlCommand mysqlcommand2 = new MySqlCommand("Update glasses set quantity=" + newQuantity + " where glassId='" + searchGlasses.Text + "'", conn);

            if (mysqlcommand2.ExecuteNonQuery() == 1)
            {
                MessageBox.Show("INVENTORY UPDATED");
            }



            MySqlCommand mysqlcommand3 = conn.CreateCommand();

            mysqlcommand3.CommandText = "Select * from patient where patientId='" + patientSaleId.Text + "'";
            MySqlDataReader reader = mysqlcommand3.ExecuteReader();

            while (reader.Read())
            {
                DateTime date2       = DateTime.Now;
                string   formatDate2 = string.Format("{0:D}", date2);
                glassesReceiptMaker(reader["patientId"].ToString(), reader["fname"].ToString(), reader["lname"].ToString(), reader["telephone"].ToString(), glassesBrand.Text, frameColourCombo.Text, formatDate2, totalCost, amountPaidNow, balance);
            }
            reader.Close();
            conn.Close();

            glassesBrand.Clear(); glassesCost.Clear(); amountPaid.Clear(); frameColourCombo.Text = ""; patientSaleId.Clear();
            searchGlasses.Text = ""; amountPaid.Clear();
        }
        private void button7_Click(object sender, EventArgs e)
        {
            Crud.clash = "error";

            int error = 0;

            if (emailIsValid(employeeId.Text))
            {
                error = 0;
            }
            else
            {
                error = 1;
                MessageBox.Show("Not a valid email.Please try again");
            }


            if (confirmPassword.Text != password.Text)
            {
                error = 1;
                MessageBox.Show("Passwords do not match");
            }



            if (error < 1)
            {
                if (imagePath1.Text == "" || imagePath1.Text == "avatar.png")
                {
                    imagePath1.Text = "avatar.png";
                }
                else
                {
                    File.Copy(Crud.fileName, Crud.destination);
                }

                Crud clash = new Crud();
                clash.handleClash("employee", "employeeId", employeeId.Text, employeeId);


                Employee addEmp = new Employee(employeeId.Text, userName.Text, lastName.Text, gender.Text, imagePath1.Text);
                addEmp.addEmployee();


                LoginDetail cred = new LoginDetail(employeeId.Text, Hash(password.Text), position.Text);
                cred.addCredentials();

                Success closing = new Success();
                closing.Close();
                refreshInputs();
            }
        }
Beispiel #4
0
        private void button5_Click(object sender, EventArgs e)
        {
            int counter  = 0;
            int overload = 0;

            conn.Open();
            MySqlCommand mysqlcommand3 = conn.CreateCommand();

            mysqlcommand3.CommandText = "Select * from appointment where visitingDate='" + dateTimePicker2.Text + "' and visitingTime='" + timeBox.Text + "' and doctorId='" + doctorEntry2.Text + "'";
            MySqlDataReader reader = mysqlcommand3.ExecuteReader();

            while (reader.Read())
            {
                counter++;
            }
            reader.Close();
            conn.Close();

            if (counter > 4)
            {
                overload = 1;
                MessageBox.Show("Sorry.No more persons can be appointed to that period");
            }

            double visitCost = 0;

            visitCost = 6000.00;

            if (!isPhoneNumber(telephoneBox2.Text))
            {
                MessageBox.Show("Not a valid phone number");
            }

            if (overload < 1 && isPhoneNumber(telephoneBox2.Text))
            {
                Crud appointment = new Crud();
                appointment.handleClash("appointment", "appointmentId", appointmentBox2.Text, appointmentBox2);

                Crud patient = new Crud();
                patient.handleClash("patient", "patientId", appointmentBox2.Text, appointmentBox2);

                Appointment updateSchedule = new Appointment(appointmentBox2.Text, doctorEntry2.Text, appointmentUpdateSearch.Text, dateTimePicker2.Text, timeBox.Text, 6000.00, payment2.Text, statusBox.Text);
                updateSchedule.updateAppointment(appointmentUpdateSearch.Text);

                Patient updateEmp = new Patient(appointmentUpdateSearch.Text, firstNameBox2.Text, lastNameBox2.Text, genderBox2.Text, telephoneBox2.Text);
                updateEmp.updatePatient(appointmentUpdateSearch.Text);
            }
        }
        private void AddGlass_Click(object sender, EventArgs e)
        {
            int quantity = int.Parse(quantityUpDown.Text);

            double cost = 0.0;

            cost = Math.Round(Convert.ToDouble(costEntry.Text), 2);

            Crud clash = new Crud();

            clash.handleClash("glasses", "glassId", "glasses", glassIdEntry);

            Glasses addGlass = new Glasses(glassIdEntry.Text, brandEntry.Text, cost, quantity, glassImageEntryBox.Text);

            addGlass.addGlasses();

            if (glassImageEntryBox.Text == "" || glassImageEntryBox.Text == "glasses.jpg")
            {
                glassImageEntryBox.Text = "glasses.jpg";
            }
            else
            {
                try
                {
                    File.Copy(Crud.fileName, Crud.destination);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occured while uploading image");
                }
            }

            refreshInputs();
            glassImageEntryBox.Text = "glasses.jpg";

            Random rnd       = new Random();
            int    glassesId = rnd.Next(1, 9999);

            glassIdEntry.Text = "glasses" + glassesId.ToString();
        }