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