private void GetAppointmentListMonth()
        {
            int      apptId     = 0;
            int      custId     = 0;
            int      userId     = 0;
            string   type       = "type";
            DateTime start      = DateTime.UtcNow;
            DateTime end        = DateTime.UtcNow;
            DateTime startUTC   = DateTime.UtcNow;
            DateTime endUTC     = DateTime.UtcNow;
            DateTime createDate = DateTime.UtcNow;
            string   createdBy  = "test";
            DateTime lastUpdate = DateTime.UtcNow;



            con.Open();
            string          query = "select appointmentId, customerId, userId, type, start, end, createDate, createdBy, lastUpdate, lastUpdateBy from appointment";
            MySqlDataReader row;

            row = con.ExecuteReader(query);
            if (row.HasRows)
            {
                while (row.Read())
                {
                    apptId     = Convert.ToInt32(row["appointmentId"]);
                    custId     = Convert.ToInt32(row["customerId"]);
                    userId     = Convert.ToInt32(row["userId"]);
                    type       = (row["type"]).ToString();
                    startUTC   = Convert.ToDateTime(row["start"]);
                    endUTC     = Convert.ToDateTime(row["end"]);
                    createdBy  = (row["createdBy"]).ToString();
                    lastUpdate = Convert.ToDateTime((row["lastUpdate"]));
                    start      = TimeZone.CurrentTimeZone.ToLocalTime(startUTC);
                    end        = TimeZone.CurrentTimeZone.ToLocalTime(endUTC);



                    Appointment newAppointment = new Appointment(apptId, custId, userId, type, start, end, createDate, createdBy, lastUpdate);

                    if (newAppointment.Start.Month == DateTime.Now.Month)
                    {
                        Appointments.Add(newAppointment);
                    }
                }
            }
            else
            {
                MessageBox.Show("No appointments found for this month!", "Information");
            }

            con.Close();
        }
Exemple #2
0
        public string FindCityName()
        {
            string cityName = null;

            DatabaseConnection con = new DatabaseConnection();

            con.Open();
            MySqlDataReader row;
            string          query = "select * from city WHERE cityId in (select cityID from address where addressId = " + TrackSelected.SelectedAddressId + ")";

            row = con.ExecuteReader(query);

            if (row.HasRows)
            {
                while (row.Read())
                {
                    cityName = row["city"].ToString();
                }
            }
            else
            {
                MessageBox.Show("City Query not working!", "Information");
            }

            return(cityName);
        }
Exemple #3
0
        public string FindCountry()
        {
            string findCountry = null;
            string city        = cityComboBox.Text;

            DatabaseConnection con = new DatabaseConnection();

            con.Open();
            MySqlDataReader row;
            string          query = "select * from country WHERE countryId in (select countryId from city where city =  '" + city + "')";

            row = con.ExecuteReader(query);

            if (row.HasRows)
            {
                while (row.Read())
                {
                    findCountry = row["country"].ToString();
                }
            }
            else
            {
                MessageBox.Show("Country Query not working!", "Information");
            }

            return(findCountry);
        }
Exemple #4
0
        private void GetAppointment()
        {
            int      apptId     = passedAppointmentID;
            int      custId     = 0;
            int      userId     = 0;
            string   type       = "type";
            DateTime start      = DateTime.UtcNow;
            DateTime end        = DateTime.UtcNow;
            DateTime startUTC   = DateTime.UtcNow;
            DateTime endUTC     = DateTime.UtcNow;
            DateTime createDate = DateTime.UtcNow;
            string   createdBy  = "test";
            DateTime lastUpdate = DateTime.UtcNow;



            con.Open();
            string          query = "select appointmentId, customerId, userId, type, start, end, createDate, createdBy, lastUpdate, lastUpdateBy from appointment where appointmentId = " + passedAppointmentID;
            MySqlDataReader row;

            row = con.ExecuteReader(query);
            if (row.HasRows)
            {
                while (row.Read())
                {
                    apptId     = Convert.ToInt32(row["appointmentId"]);
                    custId     = Convert.ToInt32(row["customerId"]);
                    userId     = Convert.ToInt32(row["userId"]);
                    type       = (row["type"]).ToString();
                    startUTC   = Convert.ToDateTime((row["start"]));
                    endUTC     = Convert.ToDateTime((row["end"]));
                    createdBy  = (row["createdBy"]).ToString();
                    lastUpdate = Convert.ToDateTime((row["lastUpdate"]));
                    start      = ConvertFromUTCLocalTime(startUTC);
                    end        = ConvertFromUTCLocalTime(endUTC);

                    Appointment editAppointment = new Appointment(apptId, custId, userId, type, start, end, createDate, createdBy, lastUpdate);

                    appointmentIDTextBox.Text    = editAppointment.AppointmentID.ToString();
                    customerIDComboBox.Text      = editAppointment.CustomerID.ToString();
                    customerNameTextBox.Text     = lookupCustomerById(editAppointment.CustomerID);
                    appointmentTypeComboBox.Text = editAppointment.Type;
                    startDateTimePicker.Text     = editAppointment.Start.ToString();
                    endDateTimePicker.Text       = editAppointment.End.ToString();
                }
            }
            else
            {
                MessageBox.Show("Error loading appointment or no appointment found!", "Information");
            }
            con.Close();
        }
Exemple #5
0
        public bool customerHasAppt(int custId)
        {
            bool hasAppt = false;

            con.Open();
            string          query = "select * from appointment where customerId =" + custId;
            MySqlDataReader row;

            row = con.ExecuteReader(query);
            if (row.HasRows)
            {
                throw new CustomerDeletionException("Cannot delete a customer who has an existing appointment! Please delete appointment first.");
            }
            else
            {
                return(hasAppt);
            }
        }
Exemple #6
0
        private void btnLogin_Click_1(object sender, EventArgs e)
        {
            try
            {
                UserOrPWBlank();
            }
            catch (LoginException loginException)
            {
                Console.WriteLine("\n" + loginException.Message);
                return;
            }

            con.Open();
            string          query = "select userId,username,password from user WHERE username ='******' AND password ='******'";
            MySqlDataReader row;

            row = con.ExecuteReader(query);
            if (row.HasRows)
            {
                while (row.Read())
                {
                    id       = row["userId"].ToString();
                    username = row["username"].ToString();
                    password = row["password"].ToString();
                }

                CurrentOnlineUser.currentOnlineUserName = username;
                CurrentOnlineUser.currentOnlineUserID   = id;

                FifteenMinutePrompt.checkSchedule();

                this.Hide();
                MainForm mainForm = new MainForm();
                mainForm.Show();
                WriteToLog(Int32.Parse(id), username);
            }
            else
            {
                errorLabel.Show();
            }

            con.Close();
        }
        public int findNextAppointmentID()
        {
            int nextAppointmentID = 0;


            DatabaseConnection con = new DatabaseConnection();

            con.Open();
            MySqlDataReader row;
            string          query = "SELECT MAX(appointmentId) FROM appointment";

            row = con.ExecuteReader(query);

            if (row.HasRows)
            {
                while (row.Read())
                {
                    nextAppointmentID = Convert.ToInt32(row[0]);
                }
            }

            return(nextAppointmentID + 1);
        }
Exemple #8
0
        private void saveCustomerButton_Click(object sender, EventArgs e)
        {
            DatabaseConnection con = new DatabaseConnection();

            string custNameValue, add1Value, add2Value, postalCodeValue, phoneValue, city;
            int    cityId    = 0;
            int    countryId = 0;


            custNameValue   = custNameTextBox.Text;
            add1Value       = add1TextBox1.Text;
            add2Value       = add2TextBox2.Text;
            postalCodeValue = postalCodeTxtBox.Text;
            phoneValue      = phoneTextBox.Text;
            DateTime updateDate = DateTime.UtcNow;


            con.Open();

            try
            {
                MySqlDataReader row;
                string          query = "select countryId, cityId, city from city where city = '" + cityComboBox.Text + "'";
                row = con.ExecuteReader(query);


                if (row.HasRows)
                {
                    while (row.Read())
                    {
                        cityId    = Convert.ToInt32(row["cityId"]);
                        countryId = Convert.ToInt32(row["countryId"]);
                        city      = row["city"].ToString();
                    }

                    U069LrDataSetTableAdapters.customerTableAdapter customerTableAdapter = new U069LrDataSetTableAdapters.customerTableAdapter();
                    customerTableAdapter.UpdateQuery(custNameValue, updateDate, CurrentOnlineUser.currentOnlineUserName, TrackSelected.SelectedCustomerId);



                    U069LrDataSetTableAdapters.addressTableAdapter addressTableAdapter = new U069LrDataSetTableAdapters.addressTableAdapter();
                    addressTableAdapter.UpdateQuery(add1Value, add2Value, cityId, postalCodeValue, phoneValue, updateDate, CurrentOnlineUser.currentOnlineUserName, TrackSelected.SelectedAddressId);
                }
                else
                {
                    MessageBox.Show("Customer Record not Saved!", "Information");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Information");
            }


            con.Close();

            this.Hide();
            CustomersForm customerForm = new CustomersForm();

            customerForm.Show();
        }
        private void saveBtn_Click(object sender, EventArgs e)
        {
            int      appointmentId      = Int32.Parse(appointmentIDTextBox.Text);
            int      customerId         = Int32.Parse(customerIDComboBox.Text);
            string   appointmentType    = appointmentTypeComboBox.Text;
            DateTime startTimeDateLocal = startDateTimePicker.Value;
            DateTime endTimeDateLocal   = endDateTimePicker.Value;



            DateTime startTimeUTC = TimeZoneInfo.ConvertTimeToUtc(startTimeDateLocal, TimeZoneInfo.Local);
            DateTime endTimeUTC   = TimeZoneInfo.ConvertTimeToUtc(endTimeDateLocal, TimeZoneInfo.Local);

            string startTimeUTCstring = startTimeUTC.ToString("yyyy-M-dd HH:mm:ss");
            string endTimeUTCstring   = endTimeUTC.ToString("yyyy-M-dd HH:mm:ss");


            try
            {
                appointmentType = getAppointmentType();
            }
            catch (AppointmentTypeException appointmentTypeException)
            {
                Console.WriteLine("\n" + appointmentTypeException.Message);
                return;
            }
            try
            {
                checkCustomerName();
            }
            catch (CustomerIDDoesNotMatchException customerIdDoesNotMatchException)
            {
                Console.WriteLine("\n" + customerIdDoesNotMatchException.Message);
                return;
            }
            try
            {
                if (outsideBusinessHoursCheck())
                {
                    ;
                }
            }
            catch (AppointmentSchedulingException outsideBusinessHoursException)
            {
                Console.WriteLine("\n" + outsideBusinessHoursException.Message);
                return;
            }
            try
            {
                if (!overLappingAppointmentsCheck())
                {
                    ;
                }
            }
            catch (AppointmentSchedulingException appointmentOverlappingException)
            {
                Console.WriteLine("\n" + appointmentOverlappingException.Message);
                return;
            }

            con.Open();

            string query = "insert into appointment values ( " + appointmentId + ", " + customerId + ", " + CurrentOnlineUser.currentOnlineUserID + ",  'not needed', 'not needed', 'not needed', 'not needed', '" + appointmentType + "',  'not needed', '" + startTimeUTCstring + "', '" + endTimeUTCstring + "', '" + DateTime.UtcNow.ToString("yyyy-M-dd HH:mm:ss") + "', '" + CurrentOnlineUser.currentOnlineUserName + "', '" + DateTime.UtcNow.ToString("yyyy-M-dd HH:mm:ss") + "',  '" + CurrentOnlineUser.currentOnlineUserName + "' )";

            MySqlDataReader row;

            row = con.ExecuteReader(query);


            con.Close();


            this.Hide();
            AppointmentsListScreen appointmentsListScreen = new AppointmentsListScreen();

            appointmentsListScreen.Show();
        }