コード例 #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);
            }
        }
コード例 #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));
        }
コード例 #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);
            }
        }
コード例 #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);
            }
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        public bool DeleteCase(int id)
        {
            var query = $"CALL delete_case({id})";

            return(SQLFunctions.ExecuteNonQuery(query));
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        public bool DeleteCustomerUser(int id)
        {
            var query = $"CALL delete_customer_user({id})";

            return(SQLFunctions.ExecuteNonQuery(query));
        }
コード例 #10
0
        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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #13
0
        public bool CreateStatus(string title)
        {
            var query = $"CALL create_status('{title}')";

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

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

            return(SQLFunctions.ExecuteNonQuery(query));
        }
コード例 #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));
        }