예제 #1
0
        public void loadAllProducts()
        {
            try
            {
                ProductLazy    productLazy = new ProductLazy();
                List <Product> allOfDem    = productLazy.loadAllProducts();
                allProductList = new ObservableCollection <Product>();
                foreach (Product prod in allOfDem)
                {
                    if (!productList.Contains(prod))
                    {
                        allProductList.Add(prod);
                    }
                }

                List <ExpandoObject> productListView = new List <ExpandoObject>();
                foreach (Product product in allProductList)
                {
                    dynamic javascript = new ExpandoObject();
                    javascript.Name    = product.Name;
                    javascript.InStock = product.InStock ? "Yes" : "No";
                    javascript.Guid    = product.GUID;
                    productListView.Add(javascript);
                }

                lvAllProducts.ItemsSource = productListView;
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true, true);
            }
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="query"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public DataTable returnQuery(string query, Dictionary <string, string> parameters)
        {
            dataTable  = new DataTable();
            connection = null;
            using (connection = new SqlConnection(connectionStringSHS))
            {
                try
                {
                    if (connection.State != ConnectionState.Open)
                    {
                        connection.Open();
                    }

                    command             = new SqlCommand(query, connection);
                    command.CommandType = CommandType.StoredProcedure;

                    foreach (KeyValuePair <string, string> item in parameters)
                    {
                        command.Parameters.Add(new SqlParameter(item.Key, item.Value));
                    }


                    dataAdapter = new SqlDataAdapter(command);
                    dataAdapter.Fill(dataTable);
                }
                catch (Exception exception)
                {
                    ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                    error.handle(exception, true);
                }
            }

            return(dataTable);
        }
예제 #3
0
        List <string> LoadFunctionsForOption(Guid guid)
        {
            List <string> functionsList = new List <string>();

            try
            {
                string query = string.Format(QueryStrings.getFunctionsBasedOnOptionGuid, guid);

                DataTable systemData = DatabaseHandler.getInstance().getFromStringQuery(query);

                if (systemData.Rows.Count != 0)
                {
                    foreach (DataRow row in systemData.Rows)
                    {
                        functionsList.Add(row["function"].ToString());
                    }
                }
                else
                {
                    return(new List <string>());
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true);
                functionsList = new List <string>();
            }
            return(functionsList);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public DataTable getFromStringQuery(string query)
        {
            dataTable  = new DataTable();
            connection = null;

            using (connection = new SqlConnection(connectionStringSHS))
            {
                try
                {
                    if (connection.State != ConnectionState.Open)
                    {
                        connection.Open();
                    }
                    command = new SqlCommand(query, connection);


                    dataAdapter = new SqlDataAdapter(command);
                    dataAdapter.Fill(dataTable);
                }
                catch (Exception exception)
                {
                    ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                    error.handle(exception, true, true);
                }
            }

            return(dataTable);
        }
        private void lvAllOptions_Click(object sender, RoutedEventArgs e)
        {
            var item = (sender as ListView).SelectedItem;

            if (item != null)
            {
                try
                {
                    //dynamic selectedClient = (ExpandoObject)item;

                    selectedOptions          = (OptionLazy)item;
                    btnAllProducts.IsEnabled = true;

                    lvFunctions.ItemsSource = selectedOptions.Functions;


                    btnUpdateOption.IsEnabled  = (Global.ADUser.IsAdministrator == true) ? true : false;
                    btnDeleteProduct.IsEnabled = (Global.ADUser.IsAdministrator == true) ? true : false;

                    // Needs to be moved to Products
                    //ClientOptions CO = new ClientOptions(selectedOptions.GUID);
                    //CO.Show();
                }
                catch (Exception exception)
                {
                    ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                    error.handle(exception, true, true);
                }
            }
        }
예제 #6
0
        public List <Appointment> lazyLoad(Guid guid)
        {
            List <Appointment> appointmentLazylist = new List <Appointment>();

            try
            {
                lock (locker)
                {
                    string query = string.Format(functions.QueryStrings.Client.getClientAppointmentsOnGuid, guid);

                    DataTable appointmentData = DatabaseHandler.getInstance().getFromStringQuery(query);

                    if (appointmentData.Rows.Count != 0)
                    {
                        foreach (DataRow row in appointmentData.Rows)
                        {
                            appointmentLazylist.Add(new Appointment(new Guid(row["guid"].ToString()), Convert.ToDateTime(row["date"].ToString()), Convert.ToDateTime(row["date"].ToString()).Date.Add(Convert.ToDateTime(row["time"].ToString()).TimeOfDay), (string)row["operation"], new Guid(row["client_guid"].ToString()), Convert.ToDecimal(row["cost"]), (string)row["extra_details"], Convert.ToBoolean(row["confirmed"]), Convert.ToBoolean(row["completed"])));
                        }
                    }
                    else
                    {
                        appointmentLazylist = DefaultAppointmentLazy;
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true);
                appointmentLazy = DefaultAppointmentLazy;
            }


            return(appointmentLazylist);
        }
예제 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="DataToAppend"></param>
        public void appendDataToTextFile(List <string> DataToAppend)
        {
            if (File.Exists(this.txtFilePath) == false)
            {
                createFileIfNotExist(this.txtFilePath);
            }

            using (stream = new FileStream(this.txtFilePath, FileMode.Append, System.IO.FileAccess.Write))
            {
                using (writer = new StreamWriter(stream))
                {
                    try
                    {
                        foreach (string item in DataToAppend)
                        {
                            writer.WriteLine(item);
                            writer.Flush();
                        }
                    }
                    catch (Exception exception)
                    {
                        ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                        error.handle(exception, true);
                    }
                }
            }
        }
예제 #8
0
        Guid getGuidFromOptionAndProduct()
        {
            Guid guid = new Guid();

            try
            {
                lock (locker)
                {
                    string query = string.Format(QueryStrings.OptionProduct.getGuidFromOptionAndProduct, this.optionGuid, this.productGuid);

                    DataTable systemData = DatabaseHandler.getInstance().getFromStringQuery(query);

                    if (systemData.Rows.Count == 1)
                    {
                        DataRow row = systemData.Rows[0];
                        return(new Guid(row["guid"].ToString()));
                    }
                    else
                    {
                        ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                        error.handle(new Exception("No Rows"), true);
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true);
            }

            return(guid);
        }
예제 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <string> getRawDataFromTextFile()
        {
            List <string> rawData = new List <string>();

            using (stream = new FileStream(this.txtFilePath, FileMode.Open, System.IO.FileAccess.Read))
            {
                using (reader = new StreamReader(stream))
                {
                    try
                    {
                        while (!reader.EndOfStream)
                        {
                            rawData.Add(reader.ReadLine());
                        }
                    }
                    catch (Exception exception)
                    {
                        ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                        error.handle(exception, true);
                    }
                }
            }

            return(rawData);
        }
예제 #10
0
        public List <OptionLazy> LoadAllOptions()
        {
            List <OptionLazy> functionsList = new List <OptionLazy>();

            try
            {
                string query = string.Format(QueryStrings.Option.getAllOptions);

                DataTable systemData = DatabaseHandler.getInstance().getFromStringQuery(query);

                if (systemData.Rows.Count != 0)
                {
                    foreach (DataRow row in systemData.Rows)
                    {
                        functionsList.Add(
                            new OptionLazy(
                                new Guid(row["guid"].ToString()), (string)row["name"], (string)row["description"], new List <GeoData>(), new List <Product>(), LoadFunctionsForOption(new Guid(row["guid"].ToString())), Convert.ToDecimal(row["price"]), Convert.ToInt32(row["installation_time"]), Convert.ToDecimal(row["install_by_company_cost"]), Convert.ToDecimal(row["combined_price"])
                                )
                            );
                    }
                }
                else
                {
                    return(new List <OptionLazy>());
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true);
                functionsList = new List <OptionLazy>();
            }
            return(functionsList);
        }
예제 #11
0
        public void updateView(Guid guid)
        {
            try
            {
                ProductLazy productLazy = new ProductLazy(guid);
                productList = new ObservableCollection <Product>(productLazy.ProductList);


                List <ExpandoObject> productListView = new List <ExpandoObject>();
                foreach (Product product in productList)
                {
                    dynamic javascript = new ExpandoObject();
                    javascript.Name    = product.Name;
                    javascript.InStock = product.InStock ? "Yes" : "No";
                    javascript.Guid    = product.GUID;
                    productListView.Add(javascript);
                }

                lvOptionProducts.ItemsSource = productListView;

                updateOptionCost();
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true, true);
            }
        }
예제 #12
0
        private void btnMoveLeft_Click(object sender, RoutedEventArgs e)
        {
            if (currentSelectedProduct != null && !productList.Contains(currentSelectedProduct))
            {
                try
                {
                    OptionProduct optionToMove = new OptionProduct(selectedOptionGuid, currentSelectedProduct.GUID);
                    optionToMove.InsertProductToOption();
                    // Do SQL here

                    allProductList.Remove(currentSelectedProduct);
                    productList.Add(currentSelectedProduct);


                    lvAllProducts.ItemsSource = null;
                    List <ExpandoObject> productListViewAll = new List <ExpandoObject>();
                    foreach (Product product in allProductList)
                    {
                        dynamic javascript = new ExpandoObject();
                        javascript.Name    = product.Name;
                        javascript.InStock = product.InStock ? "Yes" : "No";
                        javascript.Guid    = product.GUID;
                        productListViewAll.Add(javascript);
                    }
                    lvAllProducts.ItemsSource = productListViewAll;
                    if (allProductList.Count != 0)
                    {
                        lvAllProducts.SelectedIndex = 0;
                        currentSelectedProduct      = allProductList.ElementAt(0);
                        updateInnerView(allProductList.ElementAt(0));
                    }


                    lvOptionProducts.ItemsSource = null;
                    List <ExpandoObject> productListView = new List <ExpandoObject>();
                    foreach (Product product in productList)
                    {
                        dynamic javascript = new ExpandoObject();
                        javascript.Name    = product.Name;
                        javascript.InStock = product.InStock ? "Yes" : "No";
                        javascript.Guid    = product.GUID;
                        productListView.Add(javascript);
                    }

                    lvOptionProducts.ItemsSource = productListView;



                    updateOptionCost();
                    EventBus.EventBus.Instance.PostEvent(new CustomEvent("OptionInserted"));
                }
                catch (InvalidOperationException exception)
                {
                    ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                    error.handle(exception, false, true);
                }
            }
        }
예제 #13
0
        public DetailsLazy lazyLoad(Guid guid)
        {
            DetailsLazy details;

            try
            {
                lock (locker)
                {
                    string clientAddressQuery = string.Format(QueryStrings.Client.getClientAddressesOnGuid, guid);

                    List <Address> addresses      = new List <Address>();
                    DataTable      resultsAddress = DatabaseHandler.getInstance().getFromStringQuery(clientAddressQuery);

                    if (resultsAddress.Rows.Count != 0)
                    {
                        foreach (DataRow row in resultsAddress.Rows)
                        {
                            addresses.Add(new Address(new Guid(row["guid"].ToString()), (string)row["address1"], (string)row["address2"], (string)row["suburb"], (string)row["postalCode"], (string)row["city"], (string)row["country"]));
                        }
                    }

                    string ClientDetailsQuery = string.Format(QueryStrings.Client.getClientDetailsOnGuid, guid);

                    DataTable results = DatabaseHandler.getInstance().getFromStringQuery(ClientDetailsQuery);

                    if (results.Rows.Count == 1)
                    {
                        Dictionary <string, object> idDecoded = new Dictionary <string, object>();
                        idDecoded = functions.functions.decodeID((string)results.Rows[0]["identification"]);

                        string   gend       = (string)idDecoded["gender"];
                        DateTime dated      = (DateTime)idDecoded["date"];
                        Guid     clientGuid = new Guid(results.Rows[0]["guid"].ToString());

                        Login   login   = new Login((string)results.Rows[0]["login_string"]).decryptString();
                        Contact contact = new Contact(new Guid(results.Rows[0]["contact_guid"].ToString()), (string)results.Rows[0]["contact_number"], (string)results.Rows[0]["email_address"], (string)results.Rows[0]["android_device_id"], (string)results.Rows[0]["apple_device_id"], results.Rows[0]["contact_methods"].ToString().Split(',').Select(n => int.Parse(n)).ToArray());


                        details = new DetailsLazy(gend, clientGuid, addresses, login, contact, (string)results.Rows[0]["client_identifier"], (string)results.Rows[0]["identification"], (string)results.Rows[0]["name"], (string)results.Rows[0]["surname"], dated, gend);
                    }
                    else
                    {
                        details = DefaultDetails;
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true);
                details = DefaultDetails;
            }

            return(details);
        }
예제 #14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fileName"></param>
 void createFileIfNotExist(string fileName)
 {
     try
     {
         stream = new FileStream(fileName, FileMode.Create);
     }
     catch (Exception exception)
     {
         ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
         error.handle(exception, true, false, string.Format("Cannot create {0}", fileName));
     }
     finally
     {
         stream.Close();
     }
 }
예제 #15
0
        public AccountLazy lazyLoad(Guid guid)
        {
            AccountLazy accountL;

            try
            {
                lock (locker)
                {
                    string    queryBills = string.Format(QueryStrings.getAllBillsOnClientGuid, guid);
                    DataTable bills      = DatabaseHandler.getInstance().getFromStringQuery(queryBills);

                    Dictionary <string, string> directories = new Dictionary <string, string>();

                    if (bills.Rows.Count != 0)
                    {
                        foreach (DataRow row in bills.Rows)
                        {
                            directories.Add((string)row["bill_name"], (string)row["bill_directory"]);
                        }
                    }

                    string query = string.Format(QueryStrings.getClientAccountOnGuid, guid);

                    DataTable accountData = DatabaseHandler.getInstance().getFromStringQuery(query);

                    if (accountData.Rows.Count == 1)
                    {
                        Card card = new Card((string)accountData.Rows[0]["card_object_encrypted_string"]).decryptString();

                        accountL = new AccountLazy(new Guid(accountData.Rows[0]["guid"].ToString()), (string)accountData.Rows[0]["accountType"], Convert.ToDecimal(accountData.Rows[0]["costperMonth"]), directories, Convert.ToBoolean(accountData.Rows[0]["is_late"]), Convert.ToDecimal(accountData.Rows[0]["credit"]), Convert.ToDateTime(accountData.Rows[0]["registered_on"].ToString()), card);
                    }
                    else
                    {
                        accountL = DefaultAccountL;
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true);
                accountL = DefaultAccountL;
            }

            return(accountL);
        }
예제 #16
0
        private void lvClientSystems_Click(object sender, RoutedEventArgs e)
        {
            var item = (sender as ListView).SelectedItem;

            if (item != null)
            {
                try
                {
                    dynamic selectedClient = (ExpandoObject)item;
                    currentSystem = systems.First(system => system.Contract.GUID == selectedClient.Guid);
                    updateInnerView(currentSystem);
                }
                catch (InvalidOperationException exception)
                {
                    ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                    error.handle(exception, true, true);
                }
            }
        }
예제 #17
0
        private void lvOptionsToChooseFrom_MouseUp(object sender, MouseButtonEventArgs e)
        {
            var item = (sender as ListView).SelectedItem;

            if (item != null)
            {
                try
                {
                    //dynamic selectedClient = (ExpandoObject)item;

                    currentOption = (OptionLazy)item;
                }
                catch (Exception exception)
                {
                    ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                    error.handle(exception, true);
                }
            }
        }
예제 #18
0
        public List <Client> lazyLoad()
        {
            List <Client> cList = new List <Client>();

            try
            {
                //

                lock (locker)
                {
                    string query = string.Format(QueryStrings.Client.getAllClients);

                    DataTable clientData = DatabaseHandler.getInstance().getFromStringQuery(query);

                    if (clientData.Rows.Count != 0)
                    {
                        foreach (DataRow row in clientData.Rows)
                        {
                            Dictionary <string, object> idDecoded = new Dictionary <string, object>();
                            idDecoded = functions.functions.decodeID((string)row["identification"]);

                            cList.Add(
                                new ClientLazy(new Guid(row["client_guid"].ToString()), new Guid(row["account_guid"].ToString()), new Guid(row["login_guid"].ToString()), (string)row["client_identifier"], (string)row["identification"], (string)row["name"], (string)row["surname"], (DateTime)idDecoded["date"], (string)idDecoded["gender"])
                                );
                        }
                    }
                    else
                    {
                        cList = DefaultClientList;
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true);
                cList = DefaultClientList;
            }

            return(cList);
        }
예제 #19
0
        private void lvAllProducts_Click(object sender, RoutedEventArgs e)
        {
            var item = (sender as ListView).SelectedItem;

            if (item != null)
            {
                btnMoveLeft.IsEnabled  = true;
                btnMoveRight.IsEnabled = false;
                try
                {
                    dynamic selectedClient = (ExpandoObject)item;
                    currentSelectedProduct = allProductList.First(product => product.GUID == selectedClient.Guid);
                    updateInnerView(currentSelectedProduct);
                }
                catch (InvalidOperationException exception)
                {
                    ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                    error.handle(exception, true, true);
                }
            }
        }
예제 #20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="RawDataToWrite"></param>
 public void readDataToTextFile(List <string> RawDataToWrite)
 {
     using (stream = new FileStream(this.txtFilePath, FileMode.OpenOrCreate, System.IO.FileAccess.Write))
     {
         using (writer = new StreamWriter(stream))
         {
             try
             {
                 foreach (string item in RawDataToWrite)
                 {
                     writer.WriteLine(item);
                     writer.Flush();
                 }
             }
             catch (Exception exception)
             {
                 ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                 error.handle(exception, true);
             }
         }
     }
 }
예제 #21
0
        public List <System> lazyLoad(Guid guid)
        {
            List <System> systemList = new List <System>();

            try
            {
                lock (locker)
                {
                    string query = string.Format(QueryStrings.getSystemBasedOnClientGuid, guid);

                    DataTable systemData = DatabaseHandler.getInstance().getFromStringQuery(query);

                    if (systemData.Rows.Count != 0)
                    {
                        foreach (DataRow row in systemData.Rows)
                        {
                            systemList.Add(new System(
                                               new Guid(row["system_guid"].ToString()),
                                               new List <Option>(),
                                               new Status(new Guid(row["status_guid"].ToString()), Convert.ToInt32(row["critical"]), Convert.ToInt32(row["warning"]), (string)row["message"], null, null),
                                               new Contract(new Guid(row["contract_guid"].ToString()), Convert.ToBoolean(row["is_active"]), (string)row["contract_identifier"], (string)row["service_level"], Convert.ToDateTime(row["start_date"]), Convert.ToDateTime(row["end_date"]), (string)row["upgrade_options"])
                                               )
                                           );
                        }
                    }
                    else
                    {
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true);
                systemList = DefaultSystemList;
            }
            return(systemList);
        }
예제 #22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public bool insertQueryFromString(string query)
        {
            connection = null;
            using (connection = new SqlConnection(connectionStringSHS))
            {
                try
                {
                    if (connection.State != ConnectionState.Open)
                    {
                        connection.Open();
                    }
                    command = new SqlCommand(query, connection);
                }
                catch (Exception exception)
                {
                    ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                    error.handle(exception, true);
                    return(false);
                }
            }

            return(true);
        }
예제 #23
0
        public List <Product> loadAllProducts()
        {
            List <Product> productstList = new List <Product>();

            try
            {
                lock (locker)
                {
                    string query = string.Format(QueryStrings.getAllProducts);

                    DataTable systemData = DatabaseHandler.getInstance().getFromStringQuery(query);

                    if (systemData.Rows.Count != 0)
                    {
                        foreach (DataRow row in systemData.Rows)
                        {
                            productstList.Add(
                                new Product(
                                    new Guid(row["guid"].ToString()), (string)row["product_code"], (string)row["name"], (string)row["description"], Convert.ToDecimal(row["price"]), (string)row["type"], Convert.ToInt32(row["warrenty_period"]), Convert.ToBoolean(row["in_stock"]), Convert.ToDateTime(row["arrival_date"]), (string)row["manufacturer"], (string)row["model"], (string)row["serial_number"]
                                    )
                                );
                        }
                    }
                    else
                    {
                        return(DefaultProduct);
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true);
                productstList = DefaultProduct;
            }
            return(productstList);
        }
예제 #24
0
        public OptionLazy getSingleOption(Guid guid)
        {
            OptionLazy opt = null;


            try
            {
                lock (locker)
                {
                    string query = string.Format(QueryStrings.Option.getSingleOptionOnGuid, guid);

                    DataTable systemData = DatabaseHandler.getInstance().getFromStringQuery(query);

                    if (systemData.Rows.Count == 1)
                    {
                        DataRow row = systemData.Rows[0];
                        opt = new OptionLazy(
                            new Guid(row["option_guid"].ToString()), (string)row["name"], (string)row["description"], new List <GeoData>(), new List <Product>(), LoadFunctionsForOption(new Guid(row["option_guid"].ToString())), Convert.ToDecimal(row["price"]), Convert.ToInt32(row["installation_time"]), Convert.ToDecimal(row["install_by_company_cost"]), Convert.ToDecimal(row["combined_price"])
                            );
                    }
                    else
                    {
                        ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                        error.handle(new Exception("No Rows"), true);
                        opt = new OptionLazy();
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true);
                opt = new OptionLazy();
            }

            return(opt);
        }
예제 #25
0
        private void listView_Click(object sender, RoutedEventArgs e)
        {
            var item = (sender as ListView).SelectedItem;

            if (item != null)
            {
                try
                {
                    dynamic selectedClient = (ExpandoObject)item;
                    currentSelectedOption      = new OptionLazy();
                    currentSelectedOption.GUID = selectedClient.Guid;
                    // Needs to be moved to Products
                    //ClientOptions CO = new ClientOptions(selectedClient.Guid);
                    //CO.Show();

                    btnRemoveOption.IsEnabled = (Global.ADUser.IsAdministrator == true || Global.ADUser.IsEmployee == true) ? true : false;
                }
                catch (Exception exception)
                {
                    ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                    error.handle(exception, true, true);
                }
            }
        }
예제 #26
0
        public List <Option> lazyLoad(Guid guid)
        {
            List <Option> optionsList = new List <Option>();

            try
            {
                lock (locker)
                {
                    string query = string.Format(QueryStrings.getOptionsBasedOnSystemtGuid, guid);

                    DataTable systemData = DatabaseHandler.getInstance().getFromStringQuery(query);

                    if (systemData.Rows.Count != 0)
                    {
                        foreach (DataRow row in systemData.Rows)
                        {
                            optionsList.Add(
                                new OptionLazy(
                                    new Guid(row["option_guid"].ToString()), (string)row["name"], (string)row["description"], new List <GeoData>(), new List <Product>(), LoadFunctionsForOption(new Guid(row["option_guid"].ToString())), Convert.ToDecimal(row["price"]), Convert.ToInt32(row["installation_time"]), Convert.ToDecimal(row["install_by_company_cost"]), Convert.ToDecimal(row["combined_price"])
                                    )
                                );
                        }
                    }
                    else
                    {
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                error.handle(exception, true);
                optionsList = DefaultOptionList;
            }
            return(optionsList);
        }
예제 #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="query"></param>
        /// <param name="parameters"></param>
        public bool nonQuery(string query, Dictionary <string, KeyValuePair <string, string> > parameters)
        {
            connection = null;

            using (SqlConnection connection = new SqlConnection(connectionStringSHS))
            {
                try
                {
                    if (connection.State != ConnectionState.Open)
                    {
                        connection.Open();
                    }

                    command             = new SqlCommand(query, connection);
                    command.CommandType = CommandType.StoredProcedure;

                    foreach (KeyValuePair <string, KeyValuePair <string, string> > parameter in parameters)
                    {
                        switch (parameter.Value.Value)
                        {
                        case "GUID":
                            string value = (parameter.Value.Key); command.Parameters.Add(new SqlParameter(parameter.Key, new Guid(value)));
                            break;

                        case "DOUBLE":
                            command.Parameters.Add(new SqlParameter(parameter.Key, Convert.ToDouble(parameter.Value.Key)));
                            break;

                        case "STRING":
                            command.Parameters.Add(new SqlParameter(parameter.Key, SqlDbType.VarChar, 1699)); command.Parameters[parameter.Key].Value = parameter.Value.Key;
                            break;

                        case "INT":
                            command.Parameters.Add(new SqlParameter(parameter.Key, Convert.ToInt32(parameter.Value.Key)));
                            break;

                        case "DATETIME":
                            command.Parameters.Add(new SqlParameter(parameter.Key, Convert.ToDateTime(parameter.Value.Key)));
                            break;

                        case "BOOL":
                            command.Parameters.Add(new SqlParameter(parameter.Key, Convert.ToBoolean(parameter.Value.Key)));
                            break;

                        case "DECIMAL":
                            command.Parameters.Add(new SqlParameter(parameter.Key, Convert.ToDecimal(parameter.Value.Key)));
                            break;

                        case "MONEY":
                            command.Parameters.Add(new SqlParameter(parameter.Key, SqlDbType.SmallMoney)); command.Parameters[parameter.Key].Value = parameter.Value.Key;
                            break;

                        default:
                            command.Parameters.Add(new SqlParameter(parameter.Key, parameter.Value.Key));
                            break;
                        }
                    }


                    command.ExecuteNonQuery();
                }
                catch (Exception exception)
                {
                    ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance();
                    error.handle(exception, true);
                    return(false);
                }
            }

            return(true);
        }