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

📄 pball.cpp

📁 企业员工考勤和工资管理系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "PbAll.h"
#include "DM1.h"
#include "stdio.h"
#include "SelectBC.h"
#include "Wait.h"
#include "ShowPb.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"

TFormPbAll *FormPbAll;

TDate DateStart,DateEnd;
int nPbfs,nBianhao;
AnsiString sMingcheng;
extern int nFlag;
extern AnsiString sBcXz;

//---------------------------------------------------------------------------
__fastcall TFormPbAll::TFormPbAll(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFormPbAll::RadioButton1Click(TObject *Sender)
{
    DBGrid1->Visible = true;
    StringGrid1->Visible = false;
    GroupBox3->Visible = true;
    GroupBox5->Visible = false;

}
//---------------------------------------------------------------------------



void __fastcall TFormPbAll::RadioButton3Click(TObject *Sender)
{
   DBGrid1->Visible = false;
   StringGrid1->Visible = true;
   GroupBox3->Visible = false;
   GroupBox5->Visible = true;
}
//---------------------------------------------------------------------------



void __fastcall TFormPbAll::FormShow(TObject *Sender)
{
  char szTemp1[300],szTemp2[50];
  TDate day1;
  int nSGRow = 1;
  try
    {
      pGdb->Open();
    }
  catch(...)
    {
     ShowMessage("规律排班表打开失败!");
    }
  try
    {
       pBc->Open();
    }
  catch(...)
    {
      ShowMessage("基础班次表打开失败!");
      BitBtnSave->Enabled = false;
    }
  try
    {
       pAdd->Open();
    }
  catch(...)
    {
       ShowMessage("排班表打开失败!");
       BitBtnSave->Enabled = false;
    }
  try
    {
      pJiari->Open();
    }
  catch(...)
    {
      ShowMessage("假日表打开失败!");
      BitBtnSave->Enabled = false;
    }

  strcpy(szTemp1,"select holderno,holdername,departmentno,departmentname,groupno,groupname,cardno from renshi where inservice = True");
  if (nPbfs == 1)
    {
      LabelPbfs->Caption = "全部";
      szTemp2[0] = 0;
    }
  else if (nPbfs == 2)
    {
      LabelPbfs->Caption = "按部门";
      LabelName->Caption = sMingcheng;
      sprintf(szTemp2," and departmentno = %d",nBianhao);
    }
  else if (nPbfs == 3)
    {
      LabelPbfs->Caption = "按班组";
      LabelName->Caption = sMingcheng;
      sprintf(szTemp2," and groupno = %d",nBianhao);
    }
  else if (nPbfs == 4)
    {
      LabelPbfs->Caption = "按个人";
      LabelName->Caption = sMingcheng;
      sprintf(szTemp2," and holderno = %d",nBianhao);
    }

  strcat(szTemp1,szTemp2);
  strcat(szTemp1," order by departmentno,groupno,holderno");
  pYg->Close();
  pYg->SQL->Clear();
  pYg->SQL->Add(szTemp1);
  try
    {
      pYg->Open();
    }
  catch(...)
    {
      ShowMessage("员工表打开失败!");
      BitBtnSave->Enabled = false;
    }

  LabelCount->Caption = IntToStr(pYg->RecordCount);
  LabelDayCount->Caption = IntToStr(DateEnd - DateStart + 1);
  LabelStart->Caption = FormatDateTime("yyyy-mm-dd",DateStart);
  LabelEnd->Caption = FormatDateTime("yyyy-mm-dd",DateEnd);
  StringGrid1->RowCount = LabelDayCount->Caption.ToInt() + 1;
  day1 = DateStart;
  StringGrid1->Cells[0][0] = "日期";
  StringGrid1->Cells[1][0] = "班次";
  while (day1 <= DateEnd)
    {
      StringGrid1->Cells[0][nSGRow] = FormatDateTime("yyyy-mm-dd",day1);
      day1++;
      nSGRow++;
    }

  pPb->Close();
  pPb->SQL->Clear();
  pPb->SQL->Add("select ygbh,riqi from kq_paiban where riqi >= '" + LabelStart->Caption  + "' and riqi <= '" + LabelEnd->Caption + "'");
  pPb->Open();

}
//---------------------------------------------------------------------------

void __fastcall TFormPbAll::FormCreate(TObject *Sender)
{
  pGdb = GetQuery("QPbGdb");
  pBc = GetQuery("QPbBc");
  pAdd = GetQuery("QPbAdd");
  pJiari = GetQuery("QPbJiari");
  pYg = GetQuery("QPbYg");
  pPb = GetQuery("Query3");
  DataSource1->DataSet = pGdb;
  FormSelectBC = new TFormSelectBC(this);
}
//---------------------------------------------------------------------------



void __fastcall TFormPbAll::FormClose(TObject *Sender,
      TCloseAction &Action)
{
  pGdb->Close();
  pBc->Close();
  pAdd->Close();
  pJiari->Close();
  pYg->Close();
  pPb->Close();
  pPb->SQL->Clear();
  delete FormSelectBC;
}
//---------------------------------------------------------------------------





void __fastcall TFormPbAll::BitBtnSaveClick(TObject *Sender)
{
  AnsiString sMonday,sTuesday,sWednesday,sThursday,sFriday,sSaturday,sSunday,sDateTemp,sDateTemp2;
  AnsiString sYgxm,sBmmc,sBzmc,sBanci;
  WBC wbc,wbc1,wbc2,wbc3,wbc4,wbc5,wbc6,wbc7,*pWbc;
  TDate daytemp;
  int nWeek,nJiari,nYgbh,nKpbh,nBmbh,nBzbh,nRow,nTs,nYs;
  TLocateOptions Opts;
  Opts.Clear();

  if (pYg->RecordCount < 1)
    {
      ShowMessage("没有人员参加排班!");
      return;
    }
  nTs = LabelDayCount->Caption.ToInt();
  nYs = LabelCount->Caption.ToInt();
  pYg->First();
  if (RadioButton1->Checked)
    {
      if (pGdb->RecNo < 1)
        {
          ShowMessage("预设排班不存在!");
          return;
        }
      sMonday = pGdb->FieldByName("monday")->AsString;
      sTuesday = pGdb->FieldByName("tuesday")->AsString;
      sWednesday = pGdb->FieldByName("wednesday")->AsString;
      sThursday = pGdb->FieldByName("thursday")->AsString;
      sFriday = pGdb->FieldByName("friday")->AsString;
      sSaturday = pGdb->FieldByName("saturday")->AsString;
      sSunday = pGdb->FieldByName("sunday")->AsString;
      if(!CheckBanciNo(&wbc1,sMonday))
        {
          ShowMessage("查找基础班次失败!");
          return;
        }
      if(!CheckBanciNo(&wbc2,sTuesday))
        {
          ShowMessage("查找基础班次失败!");
          return;
        }
      if(!CheckBanciNo(&wbc3,sWednesday))
        {
          ShowMessage("查找基础班次失败!");
          return;
        }
      if(!CheckBanciNo(&wbc4,sThursday))
        {
          ShowMessage("查找基础班次失败!");
          return;
        }
      if(!CheckBanciNo(&wbc5,sFriday))
        {
          ShowMessage("查找基础班次失败!");
          return;
        }
      if(!CheckBanciNo(&wbc6,sSaturday))
        {
          ShowMessage("查找基础班次失败!");
          return;
        }
      if(!CheckBanciNo(&wbc7,sSunday))
        {
          ShowMessage("查找基础班次失败!");
          return;
        }

⌨️ 快捷键说明

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