Esempio n. 1
0
 private void btnCottageSearch_Click(object sender, EventArgs e)
 {
     try
     {
         //Get's data from form components, and does a query to the DB. Updates CottageDataGridView-component to show search results
         string query = "SELECT * FROM mokki " +
                        "WHERE toimintaalue_id = " + RegionUtils.RegionNameToIndex(cbCottageRegions.Text) + " " +
                        "AND postinro LIKE '%" + TextBoxUtils.ModifyInput(tbCottagePostNum.Text, 5) + "%' " +
                        "AND mokkinimi LIKE '%" + TextBoxUtils.ModifyInput(tbCottageName.Text, 45) + "%' " +
                        "AND katuosoite LIKE '%" + TextBoxUtils.ModifyInput(tbCottageStreetAddress.Text, 45) + "%' " +
                        "AND kuvaus LIKE '%" + TextBoxUtils.ModifyInput(tbCottageDescription.Text, 500) + "%' " +
                        "AND henkilomaara > '" + (nudCottageCapacity.Value - 1) + "' " +
                        "AND varustelu LIKE '%" + cbCottageEqupment.Text + "%' " +
                        "AND hinta <(" + Convert.ToDouble(nudCottagePrice.Value + 1) + ");";
         try
         {
             DataTable        table   = new DataTable();
             MySqlDataAdapter adapter = new MySqlDataAdapter(query, ConnectionUtils.connection);
             adapter.Fill(table);
             dgvCottage.DataSource = table;
         }
         catch (Exception ex)
         {
             MessageBox.Show("Virhe tietojen hakemisessa. Tarkista tiedot ja yritä uudelleen. Lisätietoja: " + ex.Message);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Virhe haun tekemisessä. Tarkista tiedot ja yritä uudelleen. Lisätietoja: " + ex.Message);
     }
 }
Esempio n. 2
0
 private void tcMain_SelectedIndexChanged(object sender, EventArgs e)
 {
     //Update each tabs components when switching to the tab
     if (tcMain.SelectedTab.Name == "tSearch")
     {
         RegionUtils.PopulateCBRegion(cbSearchAluet);
     }
     else if (tcMain.SelectedTab.Name == "tRentControl")
     {
         PopulateDGVOrder();
     }
     else if (tcMain.SelectedTab.Name == "tAreaControl")
     {
         PopulateDGVRegion();
     }
     else if (tcMain.SelectedTab.Name == "tCustomerControl")
     {
         PopulateDGVCustomer();
     }
     else if (tcMain.SelectedTab.Name == "tServiceControl")
     {
         PopulateDGVCottage();
         PopulateDGVService();
         RegionUtils.PopulateCBRegion(cbCottageRegions);
         RegionUtils.PopulateCBRegion(cbServiceRegion);
     }
     else if (tcMain.SelectedTab.Name == "tBilling")
     {
         PopulateDGVBilling();
     }
 }
Esempio n. 3
0
 private void btnServiceSearch_Click(object sender, EventArgs e)
 {
     try
     {
         //Get's data from form components, and does a query to the DB. Updates ServiceDataGridView-component to show search results
         string query = "SELECT * FROM palvelu " +
                        "WHERE toimintaalue_id = " + RegionUtils.RegionNameToIndex(cbServiceRegion.Text) + " " +
                        "AND nimi LIKE '%" + TextBoxUtils.ModifyInput(tbServiceName.Text, 40) + "%' " +
                        "AND tyyppi LIKE '%" + tbServiceType.Text + "%' " +
                        "AND kuvaus LIKE '%" + TextBoxUtils.ModifyInput(tbServiceDescription.Text, 500) + "%' " +
                        "AND hinta <(" + (nudServicePrice.Value + 1) + ");";
         try
         {
             DataTable        table   = new DataTable();
             MySqlDataAdapter adapter = new MySqlDataAdapter(query, ConnectionUtils.connection);
             adapter.Fill(table);
             dgvService.DataSource            = table;
             dgvService.Columns[0].HeaderText = "Palvelu ID";
             dgvService.Columns[1].HeaderText = "Toiminta-alue ID";
             dgvService.Columns[2].HeaderText = "Nimi";
             dgvService.Columns[3].HeaderText = "Tyyppi";
             dgvService.Columns[4].HeaderText = "Kuvaus";
             dgvService.Columns[5].HeaderText = "Hinta (€)";
             dgvService.Columns[6].HeaderText = "Alv (%)";
         }
         catch (Exception ex)
         {
             MessageBox.Show("Virhe tietojen hakemisessa. Tarkista tiedot ja yritä uudelleen. Lisätietoja: " + ex.Message);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Virhe haun tekemisessä. Tarkista tiedot ja yritä uudelleen. Lisätietoja: " + ex.Message);
     }
 }
Esempio n. 4
0
        float ComputeDotPosY(Beacon foundBeacon)
        {
            // Put the dot at the end of the scale when it's further than 6m.
            double x = RegionUtils.ComputeAccuracy(foundBeacon);

            Log.Debug(Tag, "Beacon is approx. {0:N1} metres away", x);
            double distance = Math.Min(x, 6.0);

            return(_startY + (int)(_segmentLength * (distance / 6.0)));
        }
 public ModifyServiceForm(Service s)
 {
     //Used to import services data to from
     InitializeComponent();
     RegionUtils.PopulateCBRegion(cbModifyServiceRegion);
     lblModifyServiceID.Text         = s.ServiceID.ToString();
     cbModifyServiceRegion.Text      = RegionUtils.RegionIndexToName(s.RegionID);
     tbModifyServiceName.Text        = s.Name;
     tbModifyServiceType.Text        = s.Type.ToString();
     nudModifyServicePrice.Value     = (int)s.Price;
     nudModifyServiceVAT.Value       = (int)s.Vat;
     tbModifyServiceDescription.Text = s.Description;
 }
Esempio n. 6
0
        private void btnModifyCottageModify_Click(object sender, EventArgs e)
        {
            //Make sure the data should be modified
            DialogResult result = MessageBox.Show("Haluatko varmasti muuttaa valitun mökin tietoja?", "Muuta mökin tietoja",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result == DialogResult.Yes)
            {
                try
                {
                    //Updates cottages information in the database. Gets data from form components, cottage is uniquely identified by cottageID, which can't be modified
                    string query = "START TRANSACTION; " +
                                   "UPDATE mokki " +
                                   "SET toimintaalue_id=" + RegionUtils.RegionNameToIndex(cbModifyCottageRegion.Text) +
                                   ",postinro='" + TextBoxUtils.ModifyInput(tbModifyCottagePostNum.Text, 5) +
                                   "',mokkinimi='" + TextBoxUtils.ModifyInput(tbModifyCottageName.Text, 45) +
                                   "',katuosoite='" + TextBoxUtils.ModifyInput(tbModifyCottageStreet.Text, 45) + "'," +
                                   "kuvaus='" + TextBoxUtils.ModifyInput(tbModifyCottageDescription.Text, 500) +
                                   "',henkilomaara=" + nudModifyCottageCapacity.Value +
                                   " ,varustelu='" + TextBoxUtils.ModifyInput(cbModifyCottageEquipment.Text, 100) +
                                   "', hinta=" + Convert.ToDouble(nudModifyCottagePrice.Value) + " " +
                                   "WHERE mokki_id=" + Convert.ToInt32(lblModifyCottageID.Text) + "; " +
                                   "COMMIT;";
                    try
                    {
                        ConnectionUtils.OpenConnection();
                        MySqlCommand command = new MySqlCommand(query, ConnectionUtils.connection);
                        command.ExecuteNonQuery();
                        ConnectionUtils.CloseConnection();
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        //Incase of database-connection problems
                        ConnectionUtils.CloseConnection();
                        MessageBox.Show("Virhe tietojen syöttämisessä tietokantaan. Tarkista kenttien tiedot, ja yritä uudelleen myöhemmin. Lisätietoja virheestä: "
                                        + ex.Message.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Incase of variable conversion problems
                    ConnectionUtils.CloseConnection();
                    MessageBox.Show("Virhe tietojen muuntamisessa. Onhan kaikkien kenttien syötteet oikein? Lisätietoja virheestä: " + ex.Message.ToString());
                }
            }
        }
Esempio n. 7
0
        public ModifyCottageForm(Cottage c)
        {
            //Used to import cottage data to form
            InitializeComponent();

            RegionUtils.PopulateCBRegion(cbModifyCottageRegion);

            lblModifyCottageID.Text         = c.CottageID.ToString();
            cbModifyCottageRegion.Text      = RegionUtils.RegionIndexToName(c.RegionID);
            tbModifyCottagePostNum.Text     = c.Postal;
            tbModifyCottageName.Text        = c.Name;
            tbModifyCottageStreet.Text      = c.Address;
            nudModifyCottageCapacity.Value  = c.Capacity;
            cbModifyCottageEquipment.Text   = c.Equipment;
            nudModifyCottagePrice.Value     = (int)c.Price;
            tbModifyCottageDescription.Text = c.Description;
        }
        private void btnModifyServiceModify_Click(object sender, EventArgs e)
        {
            //Make sure the data should be modified
            DialogResult result = MessageBox.Show("Haluatko varmasti muuttaa valitun palvelun tietoja?", "Muuta palvelun tietoja",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result == DialogResult.Yes)
            {
                try
                {
                    //Updates services information in the database. Gets data from form components, service is uniquely identified by serviceID, which can't be modified
                    string query = "START TRANSACTION; " +
                                   "UPDATE palvelu " +
                                   "SET toimintaalue_id=" + RegionUtils.RegionNameToIndex(cbModifyServiceRegion.Text) +
                                   ",nimi='" + TextBoxUtils.ModifyInput(tbModifyServiceName.Text, 40) +
                                   "',tyyppi=" + Convert.ToInt32(tbModifyServiceType.Text) +
                                   ",kuvaus='" + TextBoxUtils.ModifyInput(tbModifyServiceDescription.Text, 40) + "'," +
                                   "hinta=" + Convert.ToDouble(nudModifyServicePrice.Value) +
                                   ",alv=" + Convert.ToDouble(nudModifyServiceVAT.Value) + " " +
                                   "WHERE palvelu_id=" + Convert.ToInt32(lblModifyServiceID.Text) + "; " +
                                   "COMMIT;";
                    try
                    {
                        ConnectionUtils.OpenConnection();
                        MySqlCommand command = new MySqlCommand(query, ConnectionUtils.connection);
                        command.ExecuteNonQuery();
                        ConnectionUtils.CloseConnection();
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        //Incase of database-connection problems
                        ConnectionUtils.CloseConnection();
                        MessageBox.Show("Virhe tietojen syöttämisessä tietokantaan. Tarkista kenttien tiedot, ja yritä uudelleen myöhemmin. Lisätietoja virheestä: "
                                        + ex.Message.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Incase of variable conversion problems
                    ConnectionUtils.CloseConnection();
                    MessageBox.Show("Virhe tietojen muuntamisessa. Onhan kaikkien kenttien syötteet oikein? Lisätietoja virheestä: " + ex.Message.ToString());
                }
            }
        }
Esempio n. 9
0
 private void RentCottage_Load(object sender, EventArgs e)
 {
     PopulateDGVRegion();
     PopulateDGVOrder();
     PopulateDGVCustomer();
     PopulateDGVService();
     PopulateDGVCottage();
     PopulateDGVBilling();
     RegionUtils.PopulateCBRegion(cbSearchAluet);
     RegionUtils.PopulateCBRegion(cbCottageRegions);
     RegionUtils.PopulateCBRegion(cbServiceRegion);
     cbSearchAluet.SelectedIndex     = 0;
     cbSearchVarustelu.SelectedIndex = 0;
     cbBillingPaid.SelectedIndex     = 2;
     tbOrderSearch.Tag        = tbOrderSearch.Text = "Kirjoita hakusana...";
     tbOrderSearch.ForeColor  = Color.Gray;
     tbOrderSearch.Font       = new Font("Microsoft Sans Serif", 8, FontStyle.Italic);
     BillingUtils.rentCottage = this;
 }
Esempio n. 10
0
 private void btnAddCottageAdd_Click(object sender, EventArgs e)
 {
     //Add a cottage to the database, gets data from form components
     try
     {
         PostUtils.CheckPostal(tbAddCottagePostNum.Text, tbAddCottagePostRegion.Text);
         string query = "START TRANSACTION; " +
                        "INSERT INTO mokki(mokki_id,toimintaalue_id,postinro,mokkinimi,katuosoite,kuvaus,henkilomaara,varustelu,hinta) " +
                        "VALUES(default," +
                        RegionUtils.RegionNameToIndex(cbAddCottageRegion.Text) + ",'" +
                        TextBoxUtils.ModifyInput(tbAddCottagePostNum.Text, 5) + "','" +
                        TextBoxUtils.ModifyInput(tbAddCottageName.Text, 45) + "','" +
                        TextBoxUtils.ModifyInput(tbAddCottageStreet.Text, 45) + "','" +
                        TextBoxUtils.ModifyInput(tbAddCottageDescription.Text, 500) + "'," +
                        (int)nudAddCottageCapacity.Value + ",'" +
                        TextBoxUtils.ModifyInput(cbAddCottageEquipment.Text, 100) + "'," +
                        (double)nudAddCottagePrice.Value + "); " +
                        "COMMIT;";
         try
         {
             ConnectionUtils.OpenConnection();
             MySqlCommand command = new MySqlCommand(query, ConnectionUtils.connection);
             command.ExecuteNonQuery();
             ConnectionUtils.CloseConnection();
             this.Close();
         }
         catch (Exception ex)
         {
             //Incase of connction problems
             ConnectionUtils.CloseConnection();
             MessageBox.Show("Virhe tietojen syöttämisessä tietokantaan. Tarkista kenttien tiedot. Lisätietoja: " + ex.Message.ToString());
         }
     }
     catch (Exception ex)
     {
         //Incase of exceptions in variable conversion
         ConnectionUtils.CloseConnection();
         MessageBox.Show("Virhe tietojen muuntamisessa. Tarkista kenttien tiedot. Lisätietoja: " + ex.Message.ToString());
     }
 }
Esempio n. 11
0
        private void btnAddServiceAdd_Click(object sender, EventArgs e)
        {
            try
            {
                //Add a service to the database, gets data from form components
                string query = "START TRANSACTION; " +
                               "INSERT INTO palvelu(palvelu_id,toimintaalue_id,nimi,tyyppi,kuvaus,hinta,alv) " +
                               "VALUES(default," +
                               RegionUtils.RegionNameToIndex(cbAddServiceRegion.Text) + ",'" +
                               TextBoxUtils.ModifyInput(tbAddServiceName.Text, 40) + "'," +
                               Convert.ToInt32(tbAddServiceType.Text) + ",'" +
                               TextBoxUtils.ModifyInput(tbAddServiceDescription.Text, 500) + "'," +
                               (double)nudAddServicePrice.Value + "," +
                               (double)nudAddServiceVAT.Value + "); " +
                               "COMMIT;";

                try
                {
                    ConnectionUtils.OpenConnection();
                    MySqlCommand command = new MySqlCommand(query, ConnectionUtils.connection);
                    command.ExecuteNonQuery();
                    ConnectionUtils.CloseConnection();
                    this.Close();
                }
                catch (Exception ex)
                {
                    //Incase of database-connection problems
                    ConnectionUtils.CloseConnection();
                    MessageBox.Show("Virhe tietojen syöttämisessä tietokantaan. Tarkista kenttien tiedot. Lisätietoja: " + ex.Message.ToString());
                }
            }
            catch (Exception ex)
            {
                //Incase of variable conversion problems
                ConnectionUtils.CloseConnection();
                MessageBox.Show("Virhe tietojen muuntamisessa. Tarkista kenttien tiedot. Lisätietoja: " + ex.Message.ToString());
            }
        }
Esempio n. 12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            beaconManager           = new BeaconManager(this);
            beaconManager.Nearable += (sender, e) =>
            {
                if (e.Nearables.Count == 0)
                {
                    return;
                }

                RunOnUiThread(() =>
                {
                    var items   = e.Nearables.Select(n => "Id: " + n.Identifier + "Proximity: " + RegionUtils.ComputeProximity(n));
                    ListAdapter = new ArrayAdapter <string>(this,
                                                            Android.Resource.Layout.SimpleListItem1,
                                                            Android.Resource.Id.Text1,
                                                            items.ToArray());



                    ActionBar.Subtitle = string.Format("Found {0} nearables.", items.Count());
                });
            };
        }
 public ModifyServiceForm()
 {
     InitializeComponent();
     RegionUtils.PopulateCBRegion(cbModifyServiceRegion);
 }
Esempio n. 14
0
        public ModifyCottageForm()
        {
            InitializeComponent();

            RegionUtils.PopulateCBRegion(cbModifyCottageRegion);
        }
Esempio n. 15
0
 public void Display(Beacon beacon)
 {
     _macTextView.Text           = string.Format("MAC: {0} ({1:N2})", beacon.MacAddress, RegionUtils.ComputeAccuracy(beacon));
     _majorTextView.Text         = string.Format("Major: {0}", beacon.Major);
     _minorTextView.Text         = string.Format("Minor: {0}", beacon.Minor);
     _measuredPowerTextView.Text = string.Format("MPower: {0}", beacon.MeasuredPower);
     _rssiTextView.Text          = string.Format("RSSI: {0}", beacon.Rssi);
 }
Esempio n. 16
0
 public AddCottageForm()
 {
     InitializeComponent();
     RegionUtils.PopulateCBRegion(cbAddCottageRegion);
     cbAddCottageEquipment.Text = "Hyvä";
 }