Coder Social home page Coder Social logo

cpp_used_vehicle_invocing_system's Introduction

Used Vehicle Invocing System Functions Doc

1. FileHandler

Read :

#include "FileHandler.h"
  1. Read everything in the csv file as an array.
vector<string> read_csv(const string& filename,bool keep_header = false)
vector<string> data = read_csv("carlist.csv");
cout << data[0] << endl;
  1. Read everything in the csv file as a two-dimensional array
vector<vector<string>> read_csv_2D(const string& filename, bool keep_header = false)
vector<vector<string>> data = read_csv_2D("carlist.csv");
cout << data[0][0] << endl;
  1. Read specific lines / line in the csv file.
vector<vector<string>> get_lines( const string& filename, int start, int range )
vector<vector<string>> data = get_lines("carlist.csv", 0, 2);
cout << data[0][0] << endl;
vector<string> get_line(const string& filename, int line)
vector<string> data = get_line("carlist.csv", 1);
cout << data[2] << endl;
  1. Read specific columns / column in the csv file.
vector<vector<string>> get_cols( const string& filename, int start, int range )
vector<vector<string>> data = get_cols("carlist.csv", 0, 2);
cout << data[7][1] << endl;
vector<string> get_col(const string& filename, int col)
vector<string> data = get_col("carlist.csv", 0);
cout << data[0][0] << endl;
  1. Read specific columns in the csv file.
string get_cell(const string& filename, int line, int col)
string data = get_cell("carlist.csv", 1, 2);
cout << data << endl;

Write :

  1. Append data to the end of the csv file.
bool append_line(const string& filename, vector<string> data)
vector<string> data = { "1", "2", "3" };
bool res = append_line("carlist.csv", data);
cout << res;
  1. Upload line to the csv file.
bool update_line(const string& filename, vector<string> data, int line)
vector<string> data = { "1", "2", "3" };
bool res = update_line("carlist.csv", data, 0);
cout << res;
  1. Delete the original data in the csv file.
bool delete_line(const string& filename, int line, int range =1 )
bool res = delete_line("carlist.csv", 0);
cout << res;
  1. Write data to specific cells.
bool update_cell(const string& filename, string value, int line, int row)
bool res = update_cell("carlist.csv", "666", 0, 0);
cout << res;

Sort:

  • A. Sort the data in the csv file by row in ascending order.
  • B. Sort the data in the csv file by row in descending order.

Inquiry:

vector<int> query(const string& filename, string condition[])
string condition[] = { "Registration Date", "==", "2007" };
vector<int> res = query("carlist.csv", condition);
cout << res.size() << endl;

2.Authentication

#include "Authentication.h"
#define USER_FILE "users.csv"
#define USER_Name_ROW 0
#define USER_Password_ROW 2
#include "FileHandler.h"
/// <summary>
/// user login function
/// </summary>
/// <param name="username"></param>
/// <param name="password"></param>
/// <returns>
/// 100 success 
/// 200 can't find user
/// 300 password incorrect
/// 400 unknown error
///</returns>
int login(string username, string password)

3.Console

#include "Console.h"
void Console::error(string message)
void Console::success(string message)
void Console::warning(string message) 

image-20230210011313416

4.DateTime

#include "DateTime.h"
cont << get_now() << endl;

// 2023-02-10 00:46:44

5.Form

#define SIGN "-"
// Sign used to orm the divider

int show_invoice(vector<string> data){
    int len = 61;
    // The length of this form
    string divider = "";
    for (int i = 0; i < len; i++)
    {
        divider += SIGN;
    }

    cout << center_print("Receipt", SIGN, len) << endl;
    
    cout << divider << endl;
    cout << setiosflags(ios::left) 
        << setw(12) << "Invoice ID" << "|" 
        << resetiosflags(ios::left)
        << setiosflags(ios::right) 
        << setw(10) << "car ID" << "|" 
        << setw(25) << "Booking Time" << "|"
        << setw(10) << "Price" << "|"  
        << resetiosflags(ios::right) << endl;
    
    cout << divider << endl;
    cout << setiosflags(ios::left)
        << setw(12) << data[0] << "|"
        << resetiosflags(ios::left)
        << setiosflags(ios::right)
        << setw(10) << data[1] << "|"
        << setw(25) << data[2] << "|"
        << setw(10) << data[3] << "|"
        << resetiosflags(ios::right) << endl;
    cout << divider << endl;
    return 1;
}

image-20230210011713457

6.Number

string number_to_string(int number)
int string_to_number(string str)

7.String

std::string zfill(std::string data, int length, char fill = '0')
std::string zfill(int data, int length, char fill = '0') 
string trade_id = zfill(1, 8);
cout << trade_id << endl;

// 00000001
string toLowerCase(string str)

8.User

class User {
public:
	string username = "unknown";
	string role = "saleperson";
	string password = "unknown";
	string phone =  "unknown";
	int login_status;
	User(string username, string password);
	void init_user();
};

9.Status Container

#include "User.h"

class StatusContainer
{
public:static User current_user;
};

User StatusContainer::current_user = User("unknown", "unknown");

cpp_used_vehicle_invocing_system's People

Contributors

yuenci avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.