А хотя и так норм, приложение от этого не падает
parent
b85094320f
commit
35c83ed9eb
|
|
@ -1,11 +1,9 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use chrono::NaiveDate;
|
use egui::mutex::RwLock;
|
||||||
use egui::{WidgetText::RichText, mutex::RwLock};
|
|
||||||
use egui_dock::{DockArea, Style, TabViewer};
|
use egui_dock::{DockArea, Style, TabViewer};
|
||||||
use rust_decimal::prelude::Zero;
|
use sqlx::types::BigDecimal;
|
||||||
use sqlx::{Connection, MySqlConnection, MySqlPool, types::BigDecimal};
|
use crate::{database::DBOperator, models::{Equipment, Position, Worker}};
|
||||||
use crate::{database::DBOperator, models::{self, Equipment, Position, Salary, Worker}};
|
|
||||||
|
|
||||||
static TABS_CAN_BE_WINDOWS: bool = false;
|
static TABS_CAN_BE_WINDOWS: bool = false;
|
||||||
|
|
||||||
|
|
@ -33,7 +31,7 @@ pub struct App{
|
||||||
|
|
||||||
impl Default for App{
|
impl Default for App{
|
||||||
fn default() -> Self{
|
fn default() -> Self{
|
||||||
let mut tree = egui_dock::DockState::new(vec![
|
let tree = egui_dock::DockState::new(vec![
|
||||||
Tab{
|
Tab{
|
||||||
tab_type: TabTypes::Equipment,
|
tab_type: TabTypes::Equipment,
|
||||||
title:"Оборудование".to_owned(),
|
title:"Оборудование".to_owned(),
|
||||||
|
|
@ -82,8 +80,8 @@ impl eframe::App for App{
|
||||||
.style(Style::from_egui(ui.style().as_ref()))
|
.style(Style::from_egui(ui.style().as_ref()))
|
||||||
.show_inside(ui, &mut self.main_viewer);
|
.show_inside(ui, &mut self.main_viewer);
|
||||||
}
|
}
|
||||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||||
if (self.main_viewer.is_dark_theme){
|
if self.main_viewer.is_dark_theme {
|
||||||
ctx.set_visuals(egui::Visuals::dark());
|
ctx.set_visuals(egui::Visuals::dark());
|
||||||
}else{
|
}else{
|
||||||
ctx.set_visuals(egui::Visuals::light());
|
ctx.set_visuals(egui::Visuals::light());
|
||||||
|
|
@ -343,7 +341,7 @@ impl WorkerTabViewer{
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if(chrono::NaiveDate::parse_from_str(&self.add_worker_hire_date, "%d-%m-%Y").is_err()){
|
if chrono::NaiveDate::parse_from_str(&self.add_worker_hire_date, "%d-%m-%Y").is_err() {
|
||||||
ui.label(egui::RichText::new("ДАТА УКАЗАНА НЕВЕРНО").color(egui::Color32::RED));
|
ui.label(egui::RichText::new("ДАТА УКАЗАНА НЕВЕРНО").color(egui::Color32::RED));
|
||||||
self.can_add_worker = false;
|
self.can_add_worker = false;
|
||||||
}else{
|
}else{
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ use sqlx::mysql::MySqlPool;
|
||||||
|
|
||||||
|
|
||||||
use dotenvy::dotenv_override;
|
use dotenvy::dotenv_override;
|
||||||
use sqlx::mysql::MySqlQueryResult;
|
|
||||||
use std::env;
|
use std::env;
|
||||||
// use crate::schema::equipment::dsl::*;
|
// use crate::schema::equipment::dsl::*;
|
||||||
// use crate::schema::worker::dsl::*;
|
// use crate::schema::worker::dsl::*;
|
||||||
|
|
@ -64,13 +63,13 @@ impl DBOperator{
|
||||||
}
|
}
|
||||||
pub async fn add_worker(&self, worker: Worker) -> Result<bool,sqlx::Error>{
|
pub async fn add_worker(&self, worker: Worker) -> Result<bool,sqlx::Error>{
|
||||||
// sqlx::query!("INSERT INTO Brewery.worker (id, position_id, hire_date, is_fired, full_name) VALUES(0, ?, ?, ?, ?);",worker.position.id, worker.hire_date ,worker.is_fired,worker.full_name)
|
// sqlx::query!("INSERT INTO Brewery.worker (id, position_id, hire_date, is_fired, full_name) VALUES(0, ?, ?, ?, ?);",worker.position.id, worker.hire_date ,worker.is_fired,worker.full_name)
|
||||||
match(sqlx::query("INSERT INTO Brewery.worker (id, position_id, hire_date, is_fired, full_name) VALUES(0, ?, ?, ?, ?);")
|
match sqlx::query("INSERT INTO Brewery.worker (id, position_id, hire_date, is_fired, full_name) VALUES(0, ?, ?, ?, ?);")
|
||||||
.bind(worker.position.id)
|
.bind(worker.position.id)
|
||||||
.bind(worker.hire_date)
|
.bind(worker.hire_date)
|
||||||
.bind(worker.is_fired)
|
.bind(worker.is_fired)
|
||||||
.bind(worker.full_name)
|
.bind(worker.full_name)
|
||||||
.execute(&self.pool)
|
.execute(&self.pool)
|
||||||
.await){
|
.await {
|
||||||
Ok(_) =>{
|
Ok(_) =>{
|
||||||
return Ok(true)
|
return Ok(true)
|
||||||
},
|
},
|
||||||
|
|
@ -147,7 +146,7 @@ impl DBOperator{
|
||||||
pub async fn estabilish_connection() -> Result<(), sqlx::Error>{
|
pub async fn estabilish_connection() -> Result<(), sqlx::Error>{
|
||||||
dotenv_override().ok();
|
dotenv_override().ok();
|
||||||
let db_url = env::var("DATABASE_URL").expect("DATABASE_URL установи!");
|
let db_url = env::var("DATABASE_URL").expect("DATABASE_URL установи!");
|
||||||
let pool = MySqlPoolOptions::new()
|
let _pool = MySqlPoolOptions::new()
|
||||||
.max_connections(5)
|
.max_connections(5)
|
||||||
.connect(&db_url).await?;
|
.connect(&db_url).await?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,14 @@
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
use egui::mutex::RwLock;
|
|
||||||
use sqlx::MySqlPool;
|
|
||||||
|
|
||||||
use crate::database::DBOperator;
|
|
||||||
mod app;
|
mod app;
|
||||||
mod models;
|
mod models;
|
||||||
mod database;
|
mod database;
|
||||||
// mod schema;
|
// mod schema;
|
||||||
fn main()
|
fn main()
|
||||||
{
|
{
|
||||||
dotenvy::dotenv().ok(); database::estabilish_connection();
|
dotenvy::dotenv().ok();
|
||||||
|
database::estabilish_connection();
|
||||||
let native_opts = eframe::NativeOptions {
|
let native_opts = eframe::NativeOptions {
|
||||||
viewport: egui::ViewportBuilder::default()
|
viewport: egui::ViewportBuilder::default()
|
||||||
.with_inner_size([400.0,300.0])
|
.with_inner_size([400.0,300.0])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue