айяйяйяй
parent
4c97e8f322
commit
30ad04e444
|
|
@ -280,12 +280,9 @@ impl WorkerTabViewer{
|
||||||
ui.label("Должность:");
|
ui.label("Должность:");
|
||||||
});
|
});
|
||||||
ui.vertical(|ui|{
|
ui.vertical(|ui|{
|
||||||
ui.text_edit_singleline(&mut self.add_worker_name);
|
ui.add(egui::TextEdit::singleline(&mut self.add_worker_name).hint_text("Напр: Иванов Иван"));
|
||||||
|
ui.add(
|
||||||
|
egui::TextEdit::singleline(&mut self.add_worker_hire_date).hint_text("Напр: 12-02-2010"));
|
||||||
ui.text_edit_singleline(&mut self.add_worker_hire_date);
|
|
||||||
|
|
||||||
|
|
||||||
egui::ComboBox::from_label("Выбрать!")
|
egui::ComboBox::from_label("Выбрать!")
|
||||||
.selected_text(format!("{}",self.selected_position))
|
.selected_text(format!("{}",self.selected_position))
|
||||||
.show_ui(ui, |ui|{
|
.show_ui(ui, |ui|{
|
||||||
|
|
@ -306,7 +303,7 @@ impl WorkerTabViewer{
|
||||||
ui.vertical_centered(|ui|{
|
ui.vertical_centered(|ui|{
|
||||||
let resp = ui.add_enabled(self.can_add, egui::Button::new("Добавить"));
|
let resp = ui.add_enabled(self.can_add, egui::Button::new("Добавить"));
|
||||||
if resp.clicked(){
|
if resp.clicked(){
|
||||||
println!("Гойда!!");
|
todo!();
|
||||||
}
|
}
|
||||||
// if ui.button("Добавить").clicked(){
|
// if ui.button("Добавить").clicked(){
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,20 @@ impl DBOperator{
|
||||||
}
|
}
|
||||||
Ok(rets)
|
Ok(rets)
|
||||||
}
|
}
|
||||||
|
pub async fn check_worker(&self, worker: Worker) -> Result<bool, sqlx::Error>{
|
||||||
|
let ret = sqlx::query(&format!("SELECT * FROM `worker` WHERE full_name = {}, position_id = {}, hire_date = {}", worker.full_name, worker.position.id, worker.hire_date.to_string())).fetch_all(&self.pool).await?;
|
||||||
|
if ret.len() > 0{
|
||||||
|
return Ok(true)
|
||||||
|
}
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
|
pub async fn add_worker(&self, worker: Worker){
|
||||||
|
match 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).fetch(&self.pool).{
|
||||||
|
Ok(_) =>{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue