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

📄 noname.c

📁 影碟出租系统
💻 C
字号:
/*---------------------------------------------------------------------------*/
#include "stdio.h"
#include "vcl.h"
#pragma hdrstop
#include "main.h"
#include "newclient.h"
#include"newvideo.h"
#include  "client.h"
#include "video.h"
/*---------------------------------------------------------------------------*/
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
/*---------------------------------------------------------------------------*/
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
/*---------------------------------------------------------------------------*/
void __fastcall TForm1:NewClentButtonClick(TObject *Sender)
{
   NewClientF->ShowModal();
}
/*---------------------------------------------------------------------------*/
void __fastcall TForm1::LandButtonClick(TObject *Sender)
{
      AnsiString sqlstring;
     /*获取用户租用影碟信息*/
     /*当输入用户信息为用户编号时*/
     if(ClientNumEdit->Text != "")
     {
         m_ClientID = StrToInt(ClientNumEdit->Text);
         ADOQueryClient->SQL->Clear();
         sqlstring = "select 客户姓名,客户电话,已租碟片数 from 客户信息表 where 客户ID= "+ IntToStr(m_ClientID);
         ADOQueryClient->SQL->Add(sqlstring);
         ADOQueryClient->Open();
         ADOQueryClient->ExecSQL();
         m_ClientName = ADOQueryClient->FieldByName("客户姓名")->AsString;
         Edit1->Text = m_ClientID;
         Edit2->Text = m_ClientName;
         Edit3->Text = ADOQueryClient->FieldByName("客户电话")->AsString;
         Edit4->Text = ADOQueryClient->FieldByName("已租碟片数")->AsString;
         ADOQueryClient->Close();
         sqlstring = "select * from 租借信息表 where 客户ID = " + IntToStr(m_ClientID);
         ADOQuery1->Active = false;
         ADOQuery1->SQL->Clear();
         ADOQuery1->SQL->Add(sqlstring);
         ADOQuery1->Active = true;

     }
      /*当输入用户信息为用户姓名时*/
     else if (ClientNameEdit->Text != "")
     {
         m_ClientName = ClientNameEdit->Text;
         sqlstring = "select 客户ID,客户电话,已租碟片数 from 客户信息表 where 客户姓名 = '"+ m_ClientName+"';";
         ADOQueryClient->SQL->Clear();
         ADOQueryClient->SQL->Add(sqlstring);
         ADOQueryClient->Open();
         ADOQueryClient->ExecSQL();
         m_ClientID  = StrToInt(ADOQueryClient->FieldByName("客户ID")->AsString);
         Edit1->Text = m_ClientID;
         Edit2->Text = m_ClientName;
         Edit3->Text = ADOQueryClient->FieldByName("客户电话")->AsString;
         Edit4->Text = ADOQueryClient->FieldByName("已租碟片数")->AsString;
         ADOQueryClient->Close();
         sqlstring = "select * from 租借信息表 where 客户ID = " + IntToStr(m_ClientID);
         ADOQuery1->Active = false;
         ADOQuery1->SQL->Clear();
         ADOQuery1->SQL->Add(sqlstring);
         ADOQuery1->Active = true;
         
}
}
/*---------------------------------------------------------------------------*/
void __fastcall TForm1::DeleteClientButtonClick(TObject *Sender)
{
  if (Edit1->Text == "")
      {
           Application->MessageBoxA("请用户先登录!",NULL,MB_OK==IDOK);
           return;
       }
      client *deleteclient = new client(m_ClientID);

      deleteclient->m_Query = ADOQueryClient;   //

      deleteclient->DeleteClient();
      ClientNumEdit->Text = "";
      Edit1->Text = "";
      ClientNameEdit->Text = "";
      Edit2->Text = "";
      Edit3->Text = "";
      Edit4->Text = "";
}
/*---------------------------------------------------------------------------*/


void __fastcall TForm1::NewVideoButtonClick(TObject *Sender)
{
NewVideoF->ShowModal();        
}
/*---------------------------------------------------------------------------*/
void __fastcall TForm1::okButtonClick(TObject *Sender)
{
  if(GetVideoMessageEdit->Text == "" && FilmQueryRG->ItemIndex != 3)
      {
         if(Application->MessageBoxA("请输入查询信息或选择查询电影类型!",NULL,MB_OK==IDOK))
              return;
       }
       AnsiString message = GetVideoMessageEdit->Text;
       AnsiString sqlstring;
       switch( FilmQueryRG->ItemIndex)
       {
           case 0:sqlstring = "select * from 影碟信息表 where 电影名 = '"+message+"'";
                  break;
           case 1:sqlstring = "select * from 影碟信息表 where 影星1 = '"+message+"'or 影星2 = '"+message+"'";
                  break;
           case 2:sqlstring = "select * from 影碟信息表 where 导演 = '"+message+"'";
                  break;
           case 3:message = FilmTypeCB->Text;
                  sqlstring = "select * from 影碟信息表 where 电影类型 = '"+message+"'";
                  break;
       }
       ADOQuery2->Active = false;
       ADOQuery2->SQL->Clear();
       ADOQuery2->SQL->Add(sqlstring);
       ADOQuery2->Active = true;

}
/*---------------------------------------------------------------------------*/

void __fastcall TForm1::RentVideoButtenClick(TObject *Sender)
{
   if(DBGridVideo->SelectedRows->Count == 0)
       return;
   TDataSet *pDS = DBGridVideo->DataSource->DataSet; /*获取DBGrid中选定行的信息*/

   pDS->GotoBookmark((void *)DBGridVideo->SelectedRows->Items[0].c_str()); //?

   if(StrToInt(pDS->Fields->Fields[10]->AsString) == 0)  /*当库存为零时,不允许继续借出*/
   {
       Application->MessageBoxA("库存影碟数为空!",NULL,MB_OK==IDOK);
       return;
    }
}

⌨️ 快捷键说明

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