⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 useradd.cpp

📁 某公司资料管理系统
💻 CPP
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "UserAdd.h"
#include "Main.h"
#include "DataModule.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TUserAddForm *UserAddForm;
//---------------------------------------------------------------------------
__fastcall TUserAddForm::TUserAddForm(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TUserAddForm::StringGrid1SelectCell(TObject *Sender,
      int Col, int Row, bool &CanSelect)
{
   if(Col==1)
   {
      if(StringGrid1->Cells[Col][Row]!="Y")
      {  StringGrid1->Cells[Col][Row]="Y";}
      else
         {StringGrid1->Cells[Col][Row]=""; }
   }
}
//---------------------------------------------------------------------------
void __fastcall TUserAddForm::FormShow(TObject *Sender)
{
   Query1->Open();
   StringGrid1->Cells[0][0]="  用 户 组";
   StringGrid1->Cells[1][0]="选择";
   StringGrid1->Cells[2][0]="     说         明";
   StringGrid1->Cells[0][1]="SYSTEM";
   StringGrid1->Cells[2][1]="超级用户,所有删除修增加查询权限";
   StringGrid1->Cells[0][2]="PPE";
   StringGrid1->Cells[2][2]="新增,查询,修改未审核MI权限";
   StringGrid1->Cells[0][3]="PPEAPP";
   StringGrid1->Cells[2][3]="审核查询MI权限";
   StringGrid1->Cells[0][4]="QACHECK";
   StringGrid1->Cells[2][4]="查询MI,检查MI权限";
   StringGrid1->Cells[0][5]="QAAPP";
   StringGrid1->Cells[2][5]="查询MI,QA审查MI权限";
   StringGrid1->Cells[0][6]="SAMPLE";
   StringGrid1->Cells[2][6]="样板组";
   StringGrid1->Cells[0][7]="Guest";
   StringGrid1->Cells[2][7]="普通用户";

}
//---------------------------------------------------------------------------
void __fastcall TUserAddForm::BitBtn3Click(TObject *Sender)
{
   Close();
}
//---------------------------------------------------------------------------
void __fastcall TUserAddForm::BitBtn2Click(TObject *Sender)
{
  StringGrid1->Cells[1][1]="";
  StringGrid1->Cells[1][2]="";
  StringGrid1->Cells[1][3]="";
  StringGrid1->Cells[1][4]="";
  StringGrid1->Cells[1][5]="";
  StringGrid1->Cells[1][6]="";
  StringGrid1->Cells[1][7]="";

  Edit1->Text="";
  Edit2->Text="";
  Edit3->Text="";
  BitBtn1->Enabled=false;
  BitBtn2->Enabled=false;
  Edit1->SetFocus();

}
//---------------------------------------------------------------------------
void __fastcall TUserAddForm::Edit2KeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
   if(int(Key)==13&&Edit2->Text.Trim()!="")
   {
      Edit3->Enabled=true;
      Edit3->SetFocus();
   }
}
//---------------------------------------------------------------------------
void __fastcall TUserAddForm::Edit1KeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
   if(int(Key)==13 && Edit1->Text.Trim()!="")
   {
      Edit2->Enabled=true;
      Edit2->SetFocus();
   }
}
//---------------------------------------------------------------------------

void __fastcall TUserAddForm::Edit3Exit(TObject *Sender)
{
  if(Edit3->Enabled==true)
  {
    if(Edit2->Text.Trim()!=Edit3->Text.Trim())
    {
         Application->MessageBox("密码输入错误,请重输!","提示",MB_OK);
         Edit2->Text="";
         Edit3->Text="";
         Edit2->Enabled=true;
         Edit3->Enabled=false;
         Edit2->SetFocus();
    }
  }
}
//---------------------------------------------------------------------------

void __fastcall TUserAddForm::Edit3KeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    if(int(Key)==13&&Edit2->Text.Trim()!=Edit3->Text.Trim())
    {
       Application->MessageBox("密码输入错误,请重输!","提示",MB_OK);
       Edit2->Text="";
       Edit3->Text="";
       Edit3->Enabled=false;
       Edit2->SetFocus();
    }
    else
    {
        StringGrid1->Enabled=true;
        BitBtn1->Enabled=true;
        BitBtn2->Enabled=true;
    }
}
//---------------------------------------------------------------------------

void __fastcall TUserAddForm::Edit2Exit(TObject *Sender)
{
    Edit3->Enabled=true;
    Edit3->Text="";
    Edit3->SetFocus();
}
//---------------------------------------------------------------------------

void __fastcall TUserAddForm::Edit1Exit(TObject *Sender)
{
  if(Edit1->Text.Trim()!="")
   {
      Edit2->Enabled=true;
      Edit2->SetFocus();
   }
}
//---------------------------------------------------------------------------

void __fastcall TUserAddForm::BitBtn1Click(TObject *Sender)
{
  try
  {
    for(int i=1;i<=StringGrid1->RowCount-1;i++)
    {
      if(StringGrid1->Cells[1][i]=="Y")
      {
        StoredProc1->Params->Items[1]->AsString=Edit1->Text.Trim();
        StoredProc1->Params->Items[2]->AsString=Edit2->Text.Trim();
        StoredProc1->Params->Items[3]->AsString=StringGrid1->Cells[0][i];
        StoredProc1->Params->Items[4]->AsString=0;
        StringGrid1->Cells[1][i]="授权失败";
        StoredProc1->ExecProc();
        if(StoredProc1->Params->Items[4]->AsString==0)    //||StoredProc1->Params->Items[4]->AsString==1)
        {   StringGrid1->Cells[1][i]="授权成功"; }
        if(StoredProc1->Params->Items[4]->AsString==1)
        {    StringGrid1->Cells[1][i]="已有授权";}
        if(StoredProc1->Params->Items[4]->AsString==-1)
        {    StringGrid1->Cells[1][i]="授权失败";}
      }
    }
  }
  catch(...)
  {
     Application->MessageBox("授权不成功或您的权限不够!","提示",MB_OK);
  }
  Query1->Close();
  Query1->Open();
}
//---------------------------------------------------------------------------
void __fastcall TUserAddForm::FormClose(TObject *Sender,
      TCloseAction &Action)
{
   Query1->Close();
   Edit1->Text="";
   Edit2->Text="";
   Edit3->Text="";
   for(int i=0;i<=2;i++)
   {
     for(int j=0;j<=4;j++)
     {
        StringGrid1->Cells[i][j]="";
     }
    }
}
//---------------------------------------------------------------------------



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -