como faço para adicionar um nomes na coluna nomes
como faço para adicionar um nomes na coluna nomes no banco sql server usando um dbedit e um dbgrid no delphi
Lucas
Curtidas 1
Respostas
Lucas
31/01/2020
como faço para adicionar um nomes na coluna nomes no banco sql server usando um dbedit e um dbgrid no delphi
melhor dizendo quero cadastrar alguns nomes dentro da da coluna
GOSTEI 0
Core2
31/01/2020
eu faço assi usando um StringGrid no C++ Builder no Delphi também tem o StringGrid
bool check_iso_name; // boolean para checa
for (int L = 0; L < 2000; L++) {
check_iso_name = False;// seta falso para o nome
AnsiString NAME_ISO = Return32(NAME, GameID); // nome da ISO formatada
for (int Z = 0; Z < 2000; Z++) {
if (AnsiContainsText(Form1->StringGrid1->Cells[2][Z], NAME_ISO)) // checa se existe o nome da ISO no row do StringGrid
{
check_iso_name = True; // seta true porque achou um row com mesmo nome da ISO checada
break;// quebra o loop
}
}
if ((Form1->StringGrid1->Cells[0][L] == "") &&
(Form1->StringGrid1->Cells[1][L] == "") &&
(Form1->StringGrid1->Cells[2][L] == "") &&
(Form1->StringGrid1->Cells[3][L] == "") &&
(Form1->StringGrid1->Cells[4][L] == "") &&
(Form1->StringGrid1->Cells[5][L] == "") &&
(Form1->StringGrid1->Cells[6][L] == "") &&
(Form1->StringGrid1->Cells[7][L] == "") &&
(check_iso_name == False) ) // chega se esta vazio os row para adciona // chega se o nome da ISO já existe StringGrid
{
AnsiString ERRO_R = "Excelente";
AnsiString parts = num_parts;
Form1->StringGrid1->Cells[0][L] = ERRO_R; // row 0 = casa 1 no StringGrid
Form1->StringGrid1->Cells[1][L] = GameID; // row 1 = casa 2 no StringGrid
Form1->StringGrid1->Cells[2][L] = Return32(NAME,GameID); // row 2 = casa 3 no StringGrid
Form1->StringGrid1->Cells[3][L] = CD_DVD; // row 3 = casa 4 no StringGrid
Form1->StringGrid1->Cells[4][L] = GetFileSizeISO(D); // row 4 = casa 5 no StringGrid
Form1->StringGrid1->Cells[5][L] = parts; // row 5 = casa 6 no StringGrid
Form1->StringGrid1->Cells[6][L] = 0; // row 6 = casa 7 no StringGrid
Form1->StringGrid1->Cells[7][L] = D; // row 7 = casa 8 no StringGrid
check_iso_name = False; // seta falso
break; // aqui ele quebra o loop
}
}
///////////////////////////////
se converter para delphi fica assim
var
check_iso_name : Boolean;
L : integer;
NAME_ISO : AnsiString;
Z : integer;
ERRO_R, parts : AnsiString;
begin
for L := 0 to 1999 do begin
check_iso_name := False;// seta falso para o nome
NAME_ISO := Return32(NAME, GameID);
for Z := 0 to 1999 do begin
if AnsiContainsText(Form1.StringGrid1.Cells[2][Z], NAME_ISO) then // checa se existe o nome da ISO no row do StringGrid
begin
check_iso_name := True; // seta true porque achou um row com mesmo nome da ISO checada
break;// quebra o loop
end;
end;
if ((Form1.StringGrid1.Cells[0][L] = '') and
(Form1.StringGrid1.Cells[1][L] = '') and
(Form1.StringGrid1.Cells[2][L] = '') and
(Form1.StringGrid1.Cells[3][L] = '') and
(Form1.StringGrid1.Cells[4][L] = '') and
(Form1.StringGrid1.Cells[5][L] = '') and
(Form1.StringGrid1.Cells[6][L] = '') and
(Form1.StringGrid1.Cells[7][L] = '') and
(check_iso_name = False) ) then // chega se esta vazio os row para adciona // chega se o nome da ISO já existe StringGrid
begin
ERRO_R := 'Excelente';
parts := num_parts;
Form1.StringGrid1.Cells[0][L] := ERRO_R; // row 0 = casa 1 no StringGrid
Form1.StringGrid1.Cells[1][L] := GameID; // row 1 = casa 2 no StringGrid
Form1.StringGrid1.Cells[2][L] := Return32(NAME,GameID); // row 2 = casa 3 no StringGrid
Form1.StringGrid1.Cells[3][L] := CD_DVD; // row 3 = casa 4 no StringGrid
Form1.StringGrid1.Cells[4][L] := GetFileSizeISO(D); // row 4 = casa 5 no StringGrid
Form1.StringGrid1.Cells[5][L] := parts; // row 5 = casa 6 no StringGrid
Form1.StringGrid1.Cells[6][L] := 0; // row 6 = casa 7 no StringGrid
Form1.StringGrid1.Cells[7][L] := D; // row 7 = casa 8 no StringGrid
check_iso_name := False; // seta falso
break; // aqui ele quebra o loop
end;
end;
end;
eu faço assim para verifica se o StringGrid está vazio antes de limpa ele
em C++ Builder
int P = 0;
for (int L = 0; L < 2000; L++)
{
if((Form1->StringGrid1->Cells[0][L].IsEmpty() == True) &&
(Form1->StringGrid1->Cells[1][L].IsEmpty() == True) &&
(Form1->StringGrid1->Cells[2][L].IsEmpty() == True) &&
(Form1->StringGrid1->Cells[3][L].IsEmpty() == True) &&
(Form1->StringGrid1->Cells[4][L].IsEmpty() == True) &&
(Form1->StringGrid1->Cells[5][L].IsEmpty() == True) &&
(Form1->StringGrid1->Cells[7][L].IsEmpty() == True)) {
P = P + 1;
}
}
if (P >= 2000) {
SMS(L"Erro: A lista de jogos já está vazia.");
Abort();
}
AnsiString M = L"Tem certeza de que deseja Limpar a Lista?";
MessageDlg(M, TMsgDlgType::mtInformation,
TMsgDlgButtons() << TMsgDlgBtn::mbYes << TMsgDlgBtn::mbNo, 0,
[this](const TModalResult AResult) {
if (AResult == mrYes) {
for (int L = 0; L < 2000; L++)
{
Form1->StringGrid1->Cells[0][L] = "";
Form1->StringGrid1->Cells[1][L] = "";
Form1->StringGrid1->Cells[2][L] = "";
Form1->StringGrid1->Cells[3][L] = "";
Form1->StringGrid1->Cells[4][L] = "";
Form1->StringGrid1->Cells[5][L] = "";
Form1->StringGrid1->Cells[6][L] = "";
Form1->StringGrid1->Cells[7][L] = "";
}
}
});
Convertido para Delphi
var
P, L : integer;
M : AnsiString;
L : integer;
begin
P := 0;
for L := 0 to 1999 do
begin
if Form1.StringGrid1.Cells[0][L].IsEmpty( then = True then and
(Form1.StringGrid1.Cells[1][L].IsEmpty() = True) and
(Form1.StringGrid1.Cells[2][L].IsEmpty() = True) and
(Form1.StringGrid1.Cells[3][L].IsEmpty() = True) and
(Form1.StringGrid1.Cells[4][L].IsEmpty() = True) and
(Form1.StringGrid1.Cells[5][L].IsEmpty() = True) and
(Form1.StringGrid1.Cells[7][L].IsEmpty() = True))begin
P := P + 1;
end;
end;
if P >= 2000 then
begin
SMS(L'Erro: A lista de jogos já está vazia.');
Abort();
end;
M := L'Tem certeza de que deseja Limpar a Lista?';
MessageDlg(M, TMsgDlgType.mtInformation,
TMsgDlgButtons() shl TMsgDlgBtn.mbYes shl TMsgDlgBtn.mbNo, 0,
[this](const TModalResult AResult) begin
if AResult = mrYes then
begin
for L := 0 to 1999 do
begin
Form1.StringGrid1.Cells[0][L] := '';
Form1.StringGrid1.Cells[1][L] := '';
Form1.StringGrid1.Cells[2][L] := '';
Form1.StringGrid1.Cells[3][L] := '';
Form1.StringGrid1.Cells[4][L] := '';
Form1.StringGrid1.Cells[5][L] := '';
Form1.StringGrid1.Cells[6][L] := '';
end;
end;
end;
);
GOSTEI 0
Core2
31/01/2020
uso faço assim para excluir só row selecionado no C++ Builder
if (Form1->StringGrid1->Cells[2][Form1->StringGrid1->Row] == "") {
SMS(
L"Erro: não é possível excluir este item. O item selecionado não está disponível");
Abort();
}
AnsiString X = Form1->StringGrid1->Cells[2][Form1->StringGrid1->Row];
AnsiString MM = L"Tem certeza de que deseja excluir " +
ExtractFileName(X) + L" da lista?";
MessageDlg(MM, TMsgDlgType::mtInformation,
TMsgDlgButtons() << TMsgDlgBtn::mbYes << TMsgDlgBtn::mbNo, 0,
[this](const TModalResult AResult) {
if (AResult == mrYes)
{
Form1->StringGrid1->Cells[0][Form1->StringGrid1->Row] = "";
Form1->StringGrid1->Cells[1][Form1->StringGrid1->Row] = "";
Form1->StringGrid1->Cells[2][Form1->StringGrid1->Row] = "";
Form1->StringGrid1->Cells[3][Form1->StringGrid1->Row] = "";
Form1->StringGrid1->Cells[4][Form1->StringGrid1->Row] = "";
Form1->StringGrid1->Cells[5][Form1->StringGrid1->Row] = "";
Form1->StringGrid1->Cells[6][Form1->StringGrid1->Row] = "";
Form1->StringGrid1->Cells[7][Form1->StringGrid1->Row] = "";
}
});
Convertido para delphi
var
X, MM : AnsiString;
begin
if Form1.StringGrid1.Cells[2][Form1.StringGrid1.Row] = '' then begin
SMS(
L'Erro: não é possível excluir este item. O item selecionado não está disponível');
Abort();
end;
X := Form1.StringGrid1.Cells[2][Form1.StringGrid1.Row];
AnsiString MM = L'Tem certeza de que deseja excluir ' +
ExtractFileName(X) + L' da lista?';
MessageDlg(MM, TMsgDlgType.mtInformation,
TMsgDlgButtons() shl TMsgDlgBtn.mbYes shl TMsgDlgBtn.mbNo, 0,
[this](const TModalResult AResult) begin
if AResult = mrYes then begin
Form1.StringGrid1.Cells[0][Form1.StringGrid1.Row] := '';
Form1.StringGrid1.Cells[1][Form1.StringGrid1.Row] := '';
Form1.StringGrid1.Cells[2][Form1.StringGrid1.Row] := '';
Form1.StringGrid1.Cells[3][Form1.StringGrid1.Row] := '';
Form1.StringGrid1.Cells[4][Form1.StringGrid1.Row] := '';
Form1.StringGrid1.Cells[5][Form1.StringGrid1.Row] := '';
Form1.StringGrid1.Cells[6][Form1.StringGrid1.Row] := '';
Form1.StringGrid1.Cells[7][Form1.StringGrid1.Row] := '';
end;
end;
);
GOSTEI 0