Example #1
0
        public static bool ImportCustomers()
        {
            string file = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName + "\\../companyData.csv";
            var    data = File.ReadAllText(file);
            int    i    = 0;

            foreach (string row in data.Split('\n'))
            {
                if (!string.IsNullOrEmpty(row))
                {
                    string[] customer = row.Split(',');
                    string   query    = $"INSERT INTO customers (name,phone,email) VALUES ('{customer[0]}','{customer[1]}','{customer[2]}')";
                    Console.WriteLine(query);
                    SQLFunctions.ExecuteNonQuery(query);
                    i++;
                }
            }
            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        public static bool CreateDBTablesAndProcedures()
        {
            string file  = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName + "\\../initialDatabaseSetup.txt";
            var    query = File.ReadAllText(file);

            return(SQLFunctions.ExecuteNonQuery(query));
        }
Example #3
0
        public static bool InsertDefaultStatus()
        {
            string[] data = { "Received", "Open", "In progress", "Awaiting Customer", "Awaiting Approval", "On Hold", "Closed" };
            int      i    = 0;

            foreach (string status in data)
            {
                Console.WriteLine($"Inserted \"{status}\" into Status table");
                string query = $"INSERT INTO status (title) VALUES ('{status}')";
                SQLFunctions.ExecuteNonQuery(query);
                i++;
            }
            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        public static bool ImportCases()
        {
            string file = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName + "\\../caseData.csv";
            var    data = File.ReadAllText(file);
            int    i    = 0;

            foreach (string row in data.Split('\n'))
            {
                if (!string.IsNullOrEmpty(row))
                {
                    string[] import_case = row.Split('*');
                    string   query       = $"INSERT INTO cases (short_description,description,customer,customer_user,case_employee,status) VALUES ('{import_case[0]}','{import_case[1]}',(SELECT customer FROM customer_users WHERE id={import_case[2]}),{import_case[2]},{import_case[3]},{import_case[4]})";
                    SQLFunctions.ExecuteNonQuery(query);
                }
            }
            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool CreateCase(string short_description, string description, int customer, int customer_user, int case_employee, int status)
        {
            var query = $"CALL create_case('{short_description}','{description}',{customer},{customer_user},{case_employee},{status})";

            return(SQLFunctions.ExecuteNonQuery(query));
        }
        public bool DeleteCase(int id)
        {
            var query = $"CALL delete_case({id})";

            return(SQLFunctions.ExecuteNonQuery(query));
        }
        public bool UpdateCase(int id, string short_description, string description, int customer, int customer_user, int case_employee, int status, float time_spent, string hidden_information)
        {
            var query = $"CALL update_case({id},'{short_description}','{description}',{customer},{customer_user},{case_employee},{status},{time_spent},'{hidden_information}')";

            return(SQLFunctions.ExecuteNonQuery(query));
        }
        public bool CreateCustomerUser(string fname, string lname, int company, string phone, string email)
        {
            var query = $"CALL create_customer_user('{fname}','{lname}',{company},'{phone}','{email}')";

            return(SQLFunctions.ExecuteNonQuery(query));
        }
        public bool DeleteCustomerUser(int id)
        {
            var query = $"CALL delete_customer_user({id})";

            return(SQLFunctions.ExecuteNonQuery(query));
        }
        public bool UpdateCustomerUser(int id, string fname, string lname, string phone, string email)
        {
            var query = $"CALL update_customer_user({id},'{fname}','{lname}','{phone}','{email}')";

            return(SQLFunctions.ExecuteNonQuery(query));
        }
Example #11
0
        public bool CreateEmployee(string fname, string lname, string phone, string email)
        {
            var query = $"CALL create_employee('{fname}','{lname}','{phone}','{email}')";

            return(SQLFunctions.ExecuteNonQuery(query));
        }
Example #12
0
        public bool UpdateEmployee(int id, string fname, string lname, string phone, string email)
        {
            var query = $"CALL update_employee({id},'{fname}','{lname}','{phone}','{email}')";

            return(SQLFunctions.ExecuteNonQuery(query));
        }
        public bool CreateStatus(string title)
        {
            var query = $"CALL create_status('{title}')";

            return(SQLFunctions.ExecuteNonQuery(query));
        }
Example #14
0
        public bool CreateCustomer(string name, string phone, string email)
        {
            var query = $"CALL create_customer('{name}','{phone}','{email}')";

            return(SQLFunctions.ExecuteNonQuery(query));
        }
Example #15
0
        public bool UpdateCustomerContactPerson(int id, int contact_person)
        {
            var query = $"CALL update_customer_contact_person({id},{contact_person})";

            return(SQLFunctions.ExecuteNonQuery(query));
        }
Example #16
0
        public bool UpdateCustomer(int id, string name, Nullable <int> contact_person, string phone, string email)
        {
            var query = $"CALL update_customer({id},'{name}',{contact_person},'{phone}','{email}')";

            return(SQLFunctions.ExecuteNonQuery(query));
        }