Дипломная работа: Автоматизация расчета заработной платы отдела технического сопровождения в ООО «DataPro»

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
103
if length(form_sotrudnik.Edit_secondname.Text) = 0 then
begin
run_procedure := False;
form_sotrudnik.Label8.Caption := 'Не введено отчество';
end;
if length(form_sotrudnik.Edit_phone.Text) = 0 then
begin
run_procedure := False;
form_sotrudnik.Label9.Caption := 'Не введен телефон';
end;
if (length(Form_sotrudnik.Edit_login.Text) <> 0) AND (length(form_sotrudnik.Edit_password.Text) <> 0) then
begin
if length(Form_sotrudnik.Edit_login.Text) = 0 then
begin
run_procedure := False;
form_sotrudnik.Label26.Caption := 'Не введен логин';
end
else
if form_sotrudnik.Button_add.Caption = 'Добавить' then
begin
buf_zapros := 'SELECT login FROM login_password WHERE login =
'+buf_kav+form_sotrudnik.Edit_login.Text+buf_kav+';';
datamodule1.Query_buf.Close;
datamodule1.Query_buf.SQL.Clear;
datamodule1.Query_buf.SQL.Text := buf_zapros;
datamodule1.Query_buf.Open;
if datamodule1.Query_buf.RecordCount <> 0 then
begin
run_procedure := False;
form_sotrudnik.Label26.Caption := 'Такой логин есть в БД';
end;
end;
if length(form_sotrudnik.Edit_password.Text) < 8 then
begin
run_procedure := False;
form_sotrudnik.Label27.Caption := 'Пароль меньше 8 символов';
end;
end;
104
if form_sotrudnik.DBGrid_dolgnost.DataSource.DataSet.RecordCount = 0 then
begin
run_procedure := False;
form_sotrudnik.Label10.Caption := 'Не выбрана должность';
end;
//проверка закнчена
if run_procedure then
begin
if form_sotrudnik.Button_add.Caption = 'Добавить' then
add_sotrudnik;
if form_sotrudnik.Button_add.Caption = 'Исправить' then
update_sotrudnik;
end;
end;
procedure TForm_sotrudnik.update_sotrudnik;
var buf_kav, buf_zapros : string;
begin
buf_kav := '''';
if (length(Form_sotrudnik.Edit_login.Text) <> 0) AND (length(form_sotrudnik.Edit_password.Text) <> 0) then
begin
buf_zapros := 'UPDATE login_password SET login = '+buf_kav+form_sotrudnik.Edit_login.Text+buf_kav+','
+'password_user= '+buf_kav+form_sotrudnik.Edit_password.Text+buf_kav
+' WHERE login = '+buf_kav+form_sotrudnik.Label_login.Caption+buf_kav+';';
datamodule1.Query_buf.Close;
datamodule1.Query_buf.SQL.Clear;
datamodule1.Query_buf.SQL.Text := buf_zapros;
datamodule1.Query_buf.ExecSQL;
buf_zapros :='UPDATE sotrudnik SET tabel_nomer = '+buf_kav+form_sotrudnik.Edit_tabel.Text+buf_kav+','
+'Family = '+buf_kav+form_sotrudnik.Edit_family.Text+buf_kav+','
+'First_name ='+buf_kav+form_sotrudnik.Edit_name.Text+buf_kav+','
+'second_name = '+buf_kav+form_sotrudnik.Edit_secondname.Text+buf_kav+','
+'id_dolgnost =
'+form_sotrudnik.DBGrid_dolgnost.DataSource.DataSet.FieldByName('id_dolgnost').AsString+','
+'phone = '+buf_kav+form_sotrudnik.Edit_phone.Text+buf_kav+','
+'login = '+buf_kav+form_sotrudnik.Edit_login.Text+buf_kav+','
+'dostup = ' +form_sotrudnik.DBGrid_dostup.DataSource.DataSet.FieldByName('id_dostup').AsString
+' WHERE tabel_nomer = '+buf_kav+form_sotrudnik.Label_tabel.Caption+buf_kav+';';
end
else
buf_zapros :='UPDATE sotrudnik SET tabel_nomer = '+buf_kav+form_sotrudnik.Edit_tabel.Text+buf_kav+','
105
+'Family = '+buf_kav+form_sotrudnik.Edit_family.Text+buf_kav+','
+'First_name ='+buf_kav+form_sotrudnik.Edit_name.Text+buf_kav+','
+'second_name = '+buf_kav+form_sotrudnik.Edit_secondname.Text+buf_kav+','
+'id_dolgnost =
'+form_sotrudnik.DBGrid_dolgnost.DataSource.DataSet.FieldByName('id_dolgnost').AsString+','
+'phone = '+buf_kav+form_sotrudnik.Edit_phone.Text+buf_kav
+' WHERE tabel_nomer = '+buf_kav+form_sotrudnik.Label_tabel.Caption+buf_kav+';';
datamodule1.Query_buf.Close;
datamodule1.Query_buf.SQL.Clear;
datamodule1.Query_buf.SQL.Text := buf_zapros;
datamodule1.Query_buf.ExecSQL;
//чищу поля ввода
form_sotrudnik.Edit_tabel.Text := '';
form_sotrudnik.Edit_family.Text := '';
form_sotrudnik.Edit_name.Text := '';
form_sotrudnik.Edit_secondname.Text := '';
form_sotrudnik.Edit_phone.Text := '';
form_sotrudnik.Edit_login.Text := '';
form_sotrudnik.Edit_password.Text := '';
//обновляю данные на фоме
datamodule1.Query_view_sotrudnik.Active := False;
datamodule1.Query_view_sotrudnik.Active := True;
view_dbgrid;
//переименовываю кнопку
form_sotrudnik.Button_add.Caption := 'Добавить';
end;
procedure TForm_sotrudnik.add_sotrudnik;
var buf_kav, buf_zapros : string;
begin
buf_kav := '''';
if (length(Form_sotrudnik.Edit_login.Text) <> 0) AND (length(form_sotrudnik.Edit_password.Text) <> 0) then
begin
buf_zapros := 'INSERT INTO login_password (login,password_user) VALUES ('
+buf_kav+form_sotrudnik.Edit_login.Text+buf_kav+','
+buf_kav+form_sotrudnik.Edit_password.Text+buf_kav+');';
datamodule1.Query_buf.Close;
106
datamodule1.Query_buf.SQL.Clear;
datamodule1.Query_buf.SQL.Text := buf_zapros;
datamodule1.Query_buf.ExecSQL;
buf_zapros :='INSERT INTO sotrudnik (tabel_nomer,Family,First_name,second_name, id_dolgnost, phone, log-
in,dostup) VALUES ('
+buf_kav+form_sotrudnik.Edit_tabel.Text+buf_kav+','
+buf_kav+form_sotrudnik.Edit_family.Text+buf_kav+','
+buf_kav+form_sotrudnik.Edit_name.Text+buf_kav+','
+buf_kav+form_sotrudnik.Edit_secondname.Text+buf_kav+','
+form_sotrudnik.DBGrid_dolgnost.DataSource.DataSet.FieldByName('id_dolgnost').AsString+','
+buf_kav+form_sotrudnik.Edit_phone.Text+buf_kav+','
+buf_kav+form_sotrudnik.Edit_login.Text+buf_kav+','
+form_sotrudnik.DBGrid_dostup.DataSource.DataSet.FieldByName('id_dostup').AsString+');';
end
else
buf_zapros :='INSERT INTO sotrudnik (tabel_nomer,Family,First_name,second_name, id_dolgnost, phone)
VALUES ('
+buf_kav+form_sotrudnik.Edit_tabel.Text+buf_kav+','
+buf_kav+form_sotrudnik.Edit_family.Text+buf_kav+','
+buf_kav+form_sotrudnik.Edit_name.Text+buf_kav+','
+buf_kav+form_sotrudnik.Edit_secondname.Text+buf_kav+','
+form_sotrudnik.DBGrid_dolgnost.DataSource.DataSet.FieldByName('id_dolgnost').AsString+','
+buf_kav+form_sotrudnik.Edit_phone.Text+buf_kav
+');';
datamodule1.Query_buf.Close;
datamodule1.Query_buf.SQL.Clear;
datamodule1.Query_buf.SQL.Text := buf_zapros;
datamodule1.Query_buf.ExecSQL;
//чищу поля ввода
form_sotrudnik.Edit_tabel.Text := '';
form_sotrudnik.Edit_family.Text := '';
form_sotrudnik.Edit_name.Text := '';
form_sotrudnik.Edit_secondname.Text := '';
form_sotrudnik.Edit_phone.Text := '';
form_sotrudnik.Edit_login.Text := '';
form_sotrudnik.Edit_password.Text := '';
//обновляю данные на фоме
datamodule1.Query_view_sotrudnik.Active := False;
datamodule1.Query_view_sotrudnik.Active := True;
107
view_dbgrid;
end;
procedure TForm_sotrudnik.Button_deleteClick(Sender: TObject);
var buf_zapros, buf_kav, buf_login : string;
begin
buf_kav := '''';
if form_sotrudnik.DBGrid_sotrudnik.DataSource.DataSet.RecordCount <> 0 then
begin
buf_login := form_sotrudnik.DBGrid_sotrudnik.DataSource.DataSet.FieldByName('Логин').AsString;
buf_zapros := 'DELETE FROM sotrudnik WHERE tabel_nomer
='+buf_kav+form_sotrudnik.DBGrid_sotrudnik.DataSource.DataSet.FieldByName('Табель_номер').AsString+buf_
kav+';';
datamodule1.Query_buf.Close;
datamodule1.Query_buf.SQL.Clear;
datamodule1.Query_buf.SQL.Text := buf_zapros;
datamodule1.Query_buf.ExecSQL;
datamodule1.Query_buf.Close;
buf_zapros := 'DELETE FROM login_password WHERE login = '+buf_kav+buf_login+buf_kav+';';
datamodule1.Query_buf.Close;
datamodule1.Query_buf.SQL.Clear;
datamodule1.Query_buf.SQL.Text := buf_zapros;
datamodule1.Query_buf.ExecSQL;
datamodule1.Query_buf.Close;
datamodule1.Query_view_sotrudnik.Active := False;
datamodule1.Query_view_sotrudnik.Active := True;
view_dbgrid;
end;
end;
procedure TForm_sotrudnik.Button_updateClick(Sender: TObject);
begin
form_sotrudnik.Edit_tabel.Text :=
form_sotrudnik.DBGrid_sotrudnik.DataSource.DataSet.FieldByName('Табель_номер').AsString;
form_sotrudnik.Label_tabel.Caption :=
form_sotrudnik.DBGrid_sotrudnik.DataSource.DataSet.FieldByName('Табель_номер').AsString;
form_sotrudnik.Edit_family.Text :=
Источник: https://baza.diplomsite.ru/previewfile/719