Анализ потерь рабочего времени сорудников предприятия

Обзор существующих систем учета рабочего времени. Разработка базы данных типовых проектов по монтажу охранной сигнализации. Разработка базы данных фактического исполнения работ по проектам и причин простоев. Выбор программно-технических средств.

Рубрика Программирование, компьютеры и кибернетика
Вид курсовая работа
Язык русский
Дата добавления 31.10.2016
Размер файла 718,9 K

Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже

Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.

try

{

DM->Conn->Open();

// DM->PConn->Open();

}

catch (Exception &e)

{ MessageBox(NULL, e.Message.c_str(), "Не правильный пароль", 0);

LoginForm->Free();

return 0;

}

if (!DM->Conn->Connected)

{ MessageBox(NULL, "Не правильный логин", "text", 0);

LoginForm->Free();

return 0;

}

if(Upass[0]==0) err=LoginForm->ShowModal();

while (counter&&!State)

{ if(mrOk==err)

{ GlUser=LoginForm->Login->Text;GlPassword=LoginForm->Password->Text;

try

{

State=DM->Conn->AppServer.Exec(Function("SetConnect")<< WideString(GlUser)<<WideString(GlPassword));

//DM->PConn->AppServer.Exec(Function("SetConnect")<< WideString("turbogenerators")<<WideString("AscV_gr_09q"));

}

catch (Exception &e)

{

MessageBox(NULL, e.Message.c_str(), "Ошибка", 0);

}

counter--;

if (!State)

{ AnsiString temp="Осталось "+IntToStr(counter)+counter==1?" попытка!!!":!counter?" попыток!!!":" попытки!!!";

MessageBox(NULL, " \n Проверьте имя пользователя/пароль и попробуйте еще раз.", temp.c_str(),0);

}

else break;

}

else break;

err=LoginForm->ShowModal();

}

MessageBox(NULL, "Данные введены верно.", "OK",0);

if (State)

{ try {

DM->UserList->CommandText="SELECT * FROM WHOUS.ACCOMODATION WHERE USER_='"+GlUser+"' ORDER BY SKLAD";

DM->UserList->Open();

}

catch (Exception& e)

{

MessageBox(NULL, e.Message.c_str(), "", 0);

}

if(DM->UserList->Eof) State=0;

else {

DM->m_SkladSet = DM->UserList;

if (IsBug&&!DM->UserList->FieldByName("bug")->AsInteger) State=0;

else

{ UserID=DM->UserList->FieldByName("USER_")->AsString;

strcpy(Uname, UserID.c_str());strcpy(Upass, GlPassword.c_str());

if(DM->UserList->FieldByName("READONLY")->AsInteger) State=1;

else State=2;

}

}

}

LoginForm->Free();

//MessageBox(NULL, " Данные введены верно.", "OK",0);

return State;

/* UserID=LoginForm->Login->Text;

DM->UserList->Params->ParamValues["UName"]=UserID;

DM->UserList->Params->ParamValues["Passw"]=LoginForm->Password->Text;

DM->UserList->Open();

strcpy(Uname, UserID.c_str());

*/

}

bool GetSklad(char* pName, long &pCode, bool &pIsDateProd, bool &pIsLux, int pStart, int pcex)

{

static bool part=false, allskl=false;

/* if(pStart!=2)

{

if (DM->m_SkladSet && DM->m_SkladSet->Eof && gleof)

{ DM->m_SkladSet->First();gleof=0;

DM->m_SkladSet->Filtered=false;

return 1;

}

else

if (DM->m_SkladSet->Eof &&!gleof)//&&pStart)

{ strcpy(pName," Все склады");

pCode=0;

gleof=pStart&!part;

if (!pStart) DM->m_SkladSet->First();

return !gleof;

}

if (DM->m_SkladSet->Bof)

if (pStart==1)

if (DM->UserList->FieldByName("SKLAD")->AsInteger)

{ DM->m_SkladSet=DM->UserList;

part=true;

}

else

{ DM->m_SkladSet=DM->SkladList;

DM->m_SkladSet->Filter="cex=0";//break;

part=false;DM->m_SkladSet->Filtered=true;

}

else

if (!pStart)

{ DM->m_SkladSet=DM->SkladList;

DM->m_SkladSet->Filter="cex<>"+IntToStr(pcex);//break;

DM->m_SkladSet->Filtered=(pcex!=2);

}

}

if(!DM->m_SkladSet->Active) DM->m_SkladSet->Open();

if(pStart==2)

{ DM->m_SkladSet->Filtered=false;

TLocateOptions Opts;

DM->m_SkladSet->Locate("sklad", pCode, Opts);

}

strcpy(pName,DM->m_SkladSet->FieldByName("Name")->AsString.c_str());

pCode=DM->m_SkladSet->FieldByName("sklad")->AsInteger;

DM->m_SkladSet->Next();

if(pStart==2) DM->m_SkladSet->First();

return 0; */

//MessageBox(NULL, "1", "1", 0);

if(pStart!=2)

// загрузка списка сотрудников

{ if (!part) //первый вход

{ if (pStart==1)

{ if (DM->UserList->FieldByName("SKLAD")->AsInteger)

{ DM->m_SkladSet=DM->UserList;

allskl=false;

}

else

{ DM->m_SkladSet=DM->SkladList;

DM->m_SkladSet->Filter="cex<>1";//break;

DM->m_SkladSet->Filtered=true;allskl=true;

}

}

else

// список складов

{ DM->m_SkladSet=DM->SkladList;

if (!pcex) DM->m_SkladSet->Filter="cex=1";

else DM->m_SkladSet->Filter="cex<>1";

DM->m_SkladSet->Filtered=(pcex!=2);

}

part=true;

}

}

else

{ DM->m_SkladSet=DM->SkladList;

DM->m_SkladSet->Filter="Sklad="+IntToStr(pCode);

DM->m_SkladSet->Filtered=true;

}

if (!DM->m_SkladSet->Active) DM->m_SkladSet->Open();

if (DM->m_SkladSet->Eof)

{ strcpy(pName," Все сотрудники");

pCode=0;

if (allskl)

{ allskl=false;

return 0;

}

part=false;

DM->m_SkladSet->First();

//MessageBox(NULL, "Загружены списки", "", 0);

return 1;

}

strcpy(pName,DM->m_SkladSet->FieldByName("Name")->AsString.c_str());

pCode=DM->m_SkladSet->FieldByName("sklad")->AsInteger;

pIsDateProd=DM->m_SkladSet->FieldByName("IsDateProd")->AsInteger;

pIsLux=DM->m_SkladSet->FieldByName("Islux")->AsInteger;

DM->m_SkladSet->Next();

return 0;

}

void __fastcall TDM::LuxContDeleteError(TDataSet *DataSet,

EDatabaseError *E, TDataAction &Action)

{

AnsiString qq=E->Message;

}

void __fastcall TDM::LuxContPostError(TDataSet *DataSet, EDatabaseError *E,

TDataAction &Action)

{

AnsiString qq=E->Message;

}

/*

void __fastcall TDM::PartySetAfterScroll(TDataSet *DataSet)

{

if ((LuxForm==NULL) || (DM->PartySet->Eof)) return;

DM->LuxContView->Filter="CodeMaterial="+DM->PartySet->FieldByName("CodeMaterial")->AsString+

" and PartyNo="+DM->PartySet->FieldByName("PartyNo")->AsString;

DM->LuxContView->Filtered=true;

} */

void SaveDoc(BPodrobn &podr, int pAction)

/* pAction -

0 - Append update

1 - Edit

*/

{ Screen->Cursor=crHourGlass; try {

AnsiString temp, temp1;

DM->Conn->AppServer.Exec(Function("Transact")<< 1);

TDateTime qqq;bool AddAcc=false;gAction=pAction;

qqq=qqq.CurrentDate();StringNum=2;glRefresh=1;

if (gAction)

{

// обновляем старые данные

DM->Conn->AppServer.Exec(Function("UpdateOstatki")<< 0 << WideString(podr.m_User) << gAction);

// очистить старые nakl

DM->SysQuery->CommandText.printf("DELETE FROM WHOUS.NAKL WHERE USER_='%s' AND CODEDOC=%ld", DM->tblDoc->FieldByName("USER_")->AsString,DM->tblDoc->FieldByName("codedoc")->AsInteger);

DM->SysQuery->Execute();

DM->SysQuery->Close();

temp.printf("UPDATE WHOUS.HATDOC SET "

"DOC_NOMER='%s', TIPDOC=%ld, DATA=TO_DATE('%s', 'DD.MM.YYYY'), contractor=%ld,"

"USERMODY='%s', SIFRDOC='%s', VIDOPER='%s', ACTI=1, KORR='%s', SUMSUMNDS=%.2lf, SUMOPL=%.2lf "

"WHERE USER_='%s' AND CODEDOC=%ld",

podr.m_DocNomer, podr.m_TipDoc, FormatDateTime("dd.mm.yyyy", podr.m_DataDoc), podr.m_Partner,

podr.m_User, podr.m_SifrDoc, podr.m_VidOper, podr.m_Korr, podr.m_SumSumNDS, podr.m_SumOpl,

DM->tblDoc->FieldByName("USER_")->AsString,DM->tblDoc->FieldByName("codedoc")->AsInteger);

DM->SysQuery->CommandText=temp;

DM->SysQuery->Execute();

DM->SysQuery->Close();

glUser_=DM->tblDoc->FieldByName("USER_")->AsString;

glCodeDoc=DM->tblDoc->FieldByName("CODEdoc")->AsInteger;

if (podr.m_TipDoc==3)

{ // удаляем сопроводительную информацию

temp.printf("DELETE FROM WHOUS.ACCOMPDOC WHERE USER_='%s' AND CODEDOC=%ld", DM->tblDoc->FieldByName("USER_")->AsString,DM->tblDoc->FieldByName("codedoc")->AsInteger);

DM->SysQuery->CommandText=temp;

DM->SysQuery->Execute();

DM->SysQuery->Close();

}

}

else

{

// добавляем новый

glUser_=DM->UserList->FieldByName("USER_")->AsString;

glCodeDoc=DM->UserList->FieldByName("LASTDOC")->AsInteger;

temp.printf("INSERT INTO WHOUS.HATDOC (DOC_NOMER, TIPDOC, DATA, contractor, USERMODY, SIFRDOC, VIDOPER, ACTI, KORR, SUMSUMNDS, SUMOPL, TIPOPER, SKLAD, NDSIN, USER_, CODEDOC)"

" VALUES ('%s', %ld, TO_DATE('%s', 'DD.MM.YYYY'), %ld, '%s', '%s', '%s', 1, '%s', %.2lf, %.2lf , %d, %ld, %d, '%s', %ld)",

podr.m_DocNomer, podr.m_TipDoc, FormatDateTime("dd.mm.yyyy", podr.m_DataDoc), podr.m_Partner,

podr.m_User, podr.m_SifrDoc, podr.m_VidOper, podr.m_Korr, podr.m_SumSumNDS, podr.m_SumOpl, podr.m_TipOp, podr.m_Sklad, podr.m_NDSin, glUser_, glCodeDoc);

DM->SysQuery->CommandText=temp;

//MessageBox(NULL, temp.c_str(), "fuck", 0);

DM->SysQuery->Execute();

DM->SysQuery->Close();

}

// загружаем сопроводительную информацию

glTipDoc=podr.m_TipDoc;

if (podr.m_TipDoc==3)

{

DM->SysQuery->CommandText.printf("INSERT INTO WHOUS.ACCOMPDOC (USER_, CODEDOC, DOGOVORCODE, DOGOVORNUM, DOGDATA, NAKLNO, NAKLDATA, SFAKTNO, SFAKTDATA, PLDOCNO, PLDOCDATA, PLDOCSUM, PLDOCNO2, PLDOCDATA2, PLDOCSUM2, PLDOCNO3, PLDOCDATA3, PLDOCSUM3, PLDOCNO4, PLDOCDATA4, PLDOCSUM4, PLDOCNO5, PLDOCDATA5, PLDOCSUM5)"

" VALUES ('%s', %ld, ", glUser_, glCodeDoc);

AddAcc=0;

if (!podr.m_DogovorCode)

DM->SysQuery->CommandText+="0, ' ', NULL, ";

else

{ temp1.printf("%ld, '%s', TO_DATE('%s', 'dd.mm.yyyy'), ", podr.m_DogovorCode, podr.m_DogovorNum, FormatDateTime("dd.mm.yyyy", podr.m_DogData));

DM->SysQuery->CommandText+=temp1;

AddAcc=1;

}

if (podr.m_NaklNo[0]==0)

DM->SysQuery->CommandText+="' ', NULL, ";

else

{ temp1.printf("'%s', TO_DATE('%s', 'dd.mm.yyyy'), ", podr.m_NaklNo, FormatDateTime("dd.mm.yyyy", podr.m_NaklData));

DM->SysQuery->CommandText+=temp1;

AddAcc=1;

}

if (podr.m_SFaktNo[0]==0)

DM->SysQuery->CommandText+="' ', NULL, ";

else

{ temp1.printf("'%s', TO_DATE('%s', 'dd.mm.yyyy'), ", podr.m_SFaktNo, FormatDateTime("dd.mm.yyyy", podr.m_SFaktData));

DM->SysQuery->CommandText+=temp1;

AddAcc=1;

}

if (podr.m_PlDocNo[0]==0)

DM->SysQuery->CommandText+="' ', NULL, 0, ";

else

{ temp1.printf("'%s', TO_DATE('%s', 'dd.mm.yyyy'), %.2lf, ", podr.m_PlDocNo, FormatDateTime("dd.mm.yyyy", podr.m_PlDocData), podr.m_PlDocSum);

DM->SysQuery->CommandText+=temp1;

AddAcc=1;

}

if (podr.m_PlDocNo2[0]==0)

DM->SysQuery->CommandText+="' ', NULL, 0, ";

else

{ temp1.printf("'%s', TO_DATE('%s', 'dd.mm.yyyy'), %.2lf, ", podr.m_PlDocNo2, FormatDateTime("dd.mm.yyyy", podr.m_PlDocData2), podr.m_PlDocSum2);

DM->SysQuery->CommandText+=temp1;

AddAcc=1;

}

if (podr.m_PlDocNo3[0]==0)

DM->SysQuery->CommandText+="' ', NULL, 0, ";

else

{ temp1.printf("'%s', TO_DATE('%s', 'dd.mm.yyyy'), %.2lf, ", podr.m_PlDocNo3, FormatDateTime("dd.mm.yyyy", podr.m_PlDocData3), podr.m_PlDocSum3);

DM->SysQuery->CommandText+=temp1;

AddAcc=1;

}

if (podr.m_PlDocNo4[0]==0)

DM->SysQuery->CommandText+="' ', NULL, 0, ";

else

{ temp1.printf("'%s', TO_DATE('%s', 'dd.mm.yyyy'), %.2lf, ", podr.m_PlDocNo4, FormatDateTime("dd.mm.yyyy", podr.m_PlDocData4), podr.m_PlDocSum4);

DM->SysQuery->CommandText+=temp1;

AddAcc=1;

}

if (podr.m_PlDocNo5[0]==0)

DM->SysQuery->CommandText+="' ', NULL, 0) ";

else

{ temp1.printf("'%s', TO_DATE('%s', 'dd.mm.yyyy'), %.2lf) ", podr.m_PlDocNo5, FormatDateTime("dd.mm.yyyy", podr.m_PlDocData5), podr.m_PlDocSum5);

DM->SysQuery->CommandText+=temp1;

AddAcc=1;

}

// dogovorcode

if (AddAcc)

{ //MessageBox(NULL, DM->SysQuery->CommandText.c_str(), "fuck", 0);

DM->SysQuery->Execute();

DM->SysQuery->Close();

}

} } catch (Exception &e) { MessageBox(NULL, e.Message.c_str(), "dfdgtgf", 0); }

return;

}

void SaveTraffic(BPodrobn &podr, int pAction)

{ //if(DM->tblDoc->FieldByName("CODEDOC")->AsInteger!=0)

TDateTime dt; try {

AnsiString temp;

temp.printf("INSERT INTO WHOUS.V_TRAFFIC (CODECARD, PARTYNO, DATECARD, TIPCARD, KOLPODOC, LIMIT, TOOTP, KOL, NSP, DISCOUNT, CENADOC, NDS, CENA, PARTYLUX, DATEPROD, TIPDOC, USER_, CODEDOC, KUDA, ACCEPTED)"

" VALUES (%ld, %ld, TO_DATE('%s', 'DD.MM.YYYY'), %ld, %lf, %lf, %lf, %lf, %lf, %lf, %lf, %ld, %lf, %ld, TO_DATE('%s', 'DD.MM.YYYY'), %ld, '%s', %ld, %ld, %d) ",

podr.m_CodeCard, podr.m_Party, FormatDateTime("dd.mm.yyyy", dt=podr.m_DataDoc), podr.m_TipCard,

podr.m_KolPoDoc, podr.m_Limit, podr.m_ToOtp, podr.m_Kol, podr.m_NSP, podr.m_Discount, podr.m_CenaDoc, podr.m_NDS, podr.m_Cena, podr.m_PartyLux,

FormatDateTime("dd.mm.yyyy", dt=podr.m_DateProd), podr.m_TipDoc, glUser_, glCodeDoc, podr.m_Kuda, podr.m_Accepted);

DM->SysQuery->CommandText=temp;

// MessageBox(NULL, temp.c_str(), "fuck", 0);

DM->SysQuery->Execute();

DM->SysQuery->Close(); } catch (Exception &e) { MessageBox(NULL, e.Message.c_str(), "dfdgtgf", 0); }

}

int ApplyDoc()

{ //AnsiString tip;

int err;

try { err=DM->Conn->AppServer.Exec(Function("UpdateOstatki")<< 1 << WideString(glUser_) << glCodeDoc);

if(!gAction)

{ DM->SysQuery->CommandText="UPDATE WHOUS.USERLIST SET LASTDOC=LASTDOC+1 WHERE USER_='"+glUser_+"'";

DM->SysQuery->Execute();

}

/* DM->tblDoc->Close();

DM->tblDoc->Close();

DM->tblDoc->Close();

8*/ DM->Conn->AppServer.Exec(Function("Transact")<< 2);}

catch (Exception &e)

{ MessageBox(NULL, e.Message.c_str(), "dfdgtgf", 0);

DM->Conn->AppServer.Exec(Function("Transact")<< 3);

}

DM->UserList->Close();

DM->UserList->Open();

err=0;

if (glTipDoc==5)

{ err=VidPrint->ShowModal();

switch (err) {

case 1: // требование

DM->PrintTreb->Params->ParamByName("user")->Value=glUser_;

DM->PrintTreb->Params->ParamByName("code")->Value=glCodeDoc;

DM->PrintTreb->Open();

Application->CreateForm(__classid(TTrebRpt), &TrebRpt);

TrebRpt->QuickRep1->Preview();// ShowModal();

DM->PrintTreb->Close();

TrebRpt->Free();

err=0;break;

case 2: // расшифровка

err=1;break;

case 3: // не печатать

err=0;break;

}

}

else err=IDYES==MessageBox(NULL, "Просмотреть документ?", "Вопрос", MB_ICONQUESTION | MB_YESNO);

if (err)

{ Screen->Cursor=crHourGlass;

err=DM->Conn->AppServer.Exec(Function("CreateReport")<< glTipDoc << WideString(glUser_) << glCodeDoc );

AnsiString sf, rn=glTipDoc==3?"PRORDER":"RORDER";

// sf.printf("{%s.USER_}=%s AND {%s.CODEDOC}=%ld", rn, user, rn, err); // web

sf.printf("{%s.USERpr}=\"%s\"", rn, DM->UserList->FieldByName("USER_")->AsString);

DM->PrintReport(0, glTipDoc==3?(err?pPRORDERLUX:pPRORDER):err?pRORDERLUX:pRORDER, sf);//==IDOK);//SetPrinted();

}

Screen->Cursor=crArrow;

return 0;//err;

}

int ValidateOst(long Sklad, short TipOper, long Code, BYTE Type, double Cena, int partyno, double & Kol)

{ // Формирование отчета

if(Type==3) return TRUE;

if(TipOper && !partyno) return TRUE;

return DM->Conn->AppServer.Exec(Function("ValidateOst")<<(int)Sklad << TipOper << (int)Code << Type << partyno << &Kol);

}

bool DivideOst(long Sklad, long Code, BYTE Type, double & Cena, double & Kol, long & Party)

{

if(!dividic)

{ DM->Divider->Params->ParamByName("Sklad")->Value = Sklad;

DM->Divider->Params->ParamByName("Code")->Value = Code;

DM->Divider->Params->ParamByName("Tip")->Value = Type;

DM->Divider->Close();

DM->Divider->Open();

dividic++;

}

Cena=DM->Divider->FieldByName("Cena")->AsFloat;

if (Kol>DM->Divider->FieldByName("Kol")->AsFloat)

{ Kol=DM->Divider->FieldByName("Kol")->AsFloat;

DM->Divider->Next();

}

else dividic=0;

return true;

}

int TDM::OpenDocum(BPodrobn &podr)

{/* tblDoc->Filter="USER_ = '"+Docs->FieldByName("USER_")->AsString+"' and "+

"CODEDOC = "+Docs->FieldByName("CODEDOC")->AsString;

if (!tblDoc->Active) tblDoc->Open();

tblDoc->Filtered=true;

*/

AnsiString user, user1;int code;

user=Docs->FieldByName("USER_")->AsString;

code=Docs->FieldByName("CODEDOC")->AsInteger;

user1=Docs->FieldByName("CODEDOC")->AsString;

Docs->Close();

tblDoc->Close();

tblDoc->Params->ParamByName("user")->AsString=user;

tblDoc->Params->ParamByName("codedoc")->AsString=code;

tblDoc->Open();

strcpy(podr.m_User,DM->tblDoc->FieldByName("USER_")->AsString.c_str());

podr.m_CodeDoc=DM->tblDoc->FieldByName("CodeDoc")->AsInteger;

podr.m_TipDoc=DM->tblDoc->FieldByName("TIPDOC")->AsInteger;

strcpy(podr.m_DocNomer, DM->tblDoc->FieldByName("DOC_NOMER")->AsString.c_str());

podr.m_DataDoc=DM->tblDoc->FieldByName("DATA")->AsDateTime;

podr.m_Sklad=DM->tblDoc->FieldByName("SKLAD")->AsInteger;

podr.m_Partner=DM->tblDoc->FieldByName("contractor")->AsInteger;

podr.m_TipOp=DM->tblDoc->FieldByName("TIPOPER")->AsInteger;

podr.m_Acti=DM->tblDoc->FieldByName("ACTI")->AsInteger;

strcpy(podr.m_Korr,DM->tblDoc->FieldByName("KORR")->AsString.c_str());

strcpy(podr.m_VidOper,DM->tblDoc->FieldByName("vidoper")->AsString.c_str());

strcpy(podr.m_SifrDoc,DM->tblDoc->FieldByName("sifrdoc")->AsString.c_str());

podr.m_SumSumNDS=DM->tblDoc->FieldByName("SUMSUMNDS")->AsFloat;

podr.m_SumOpl=DM->tblDoc->FieldByName("SUMOPL")->AsFloat;

podr.m_NDSin=DM->tblDoc->FieldByName("NDSIN")->AsInteger;

if (DM->tblDoc->FieldByName("NOACC")->AsString!="NOACC")

{

strcpy(podr.m_DogovorNum, DM->tblDoc->FieldByName("DOGOVORNUM")->AsString.c_str());

podr.m_DogData=DM->tblDoc->FieldByName("DOGDATA")->AsDateTime;

strcpy(podr.m_NaklNo,DM->tblDoc->FieldByName("NAKLNO")->AsString.c_str());

podr.m_NaklData=DM->tblDoc->FieldByName("NAKLDATA")->AsDateTime;

strcpy(podr.m_SFaktNo,DM->tblDoc->FieldByName("SFAKTNO")->AsString.c_str());

podr.m_SFaktData=DM->tblDoc->FieldByName("SFAKTDATA")->AsDateTime;

strcpy(podr.m_PlDocNo,DM->tblDoc->FieldByName("PLDOCNO")->AsString.c_str());

if (podr.m_PlDocNo!="")

{ podr.m_PlDocData=DM->tblDoc->FieldByName("PLDOCDATA")->AsDateTime;

podr.m_PlDocSum=DM->tblDoc->FieldByName("PLDOCSUM")->AsFloat;

}

strcpy(podr.m_PlDocNo2,DM->tblDoc->FieldByName("PLDOCNO2")->AsString.c_str());

if (podr.m_PlDocNo2!="")

{ podr.m_PlDocData2=DM->tblDoc->FieldByName("PLDOCDATA2")->AsDateTime;

podr.m_PlDocSum2=DM->tblDoc->FieldByName("PLDOCSUM2")->AsFloat;

}

strcpy(podr.m_PlDocNo3,DM->tblDoc->FieldByName("PLDOCNO3")->AsString.c_str());

if (podr.m_PlDocNo3!="")

{ podr.m_PlDocData3=DM->tblDoc->FieldByName("PLDOCDATA3")->AsDateTime;

podr.m_PlDocSum3=DM->tblDoc->FieldByName("PLDOCSUM3")->AsFloat;

}

strcpy(podr.m_PlDocNo4,DM->tblDoc->FieldByName("PLDOCNO4")->AsString.c_str());

if (podr.m_PlDocNo4!="")

{ podr.m_PlDocData4=DM->tblDoc->FieldByName("PLDOCDATA4")->AsDateTime;

podr.m_PlDocSum4=DM->tblDoc->FieldByName("PLDOCSUM4")->AsFloat;

}

strcpy(podr.m_PlDocNo5,DM->tblDoc->FieldByName("PLDOCNO5")->AsString.c_str());

if (podr.m_PlDocNo5!="")

{ podr.m_PlDocData5=DM->tblDoc->FieldByName("PLDOCDATA5")->AsDateTime;

podr.m_PlDocSum5=DM->tblDoc->FieldByName("PLDOCSUM5")->AsFloat;

}

}

}

bool LoadTraffic(BPodrobn &podr)

{

if (DM->tblDoc->Eof)

{ //DM->tblDoc->Close();

return true;

}

podr.m_CodeCard=DM->tblDoc->FieldByName("CODECARD")->AsInteger;

podr.m_TipCard=DM->tblDoc->FieldByName("TIPCARD")->AsInteger;

if (podr.m_TipCard==1)

{ DM->MatCode->Params->ParamByName("code")->Value=podr.m_CodeCard;

DM->MatCode->Open();

strcpy(podr.m_NameCard,DM->MatCode->FieldByName("NAMEM")->AsString.c_str());

strcpy(podr.m_tEdIzm,DM->MatCode->FieldByName("UNITSN")->AsString.c_str());

DM->MatCode->Close();

}

else

{ DM->OtCode->Params->ParamByName("code")->Value=podr.m_CodeCard;

DM->OtCode->Open();

strcpy(podr.m_NameCard,DM->OtCode->FieldByName("OTHERNAME")->AsString.c_str());

DM->OtCode->Close();

}

podr.m_KolPoDoc=DM->tblDoc->FieldByName("KOLPODOC")->AsFloat;

podr.m_Party=DM->tblDoc->FieldByName("PartyNo")->AsInteger;

podr.m_PartyLux=DM->tblDoc->FieldByName("PartyLux")->AsInteger;

podr.m_Limit=DM->tblDoc->FieldByName("Limit")->AsFloat;

podr.m_ToOtp=DM->tblDoc->FieldByName("TOOTP")->AsFloat;

podr.m_Kol=DM->tblDoc->FieldByName("KOL")->AsFloat;

podr.m_Cena=DM->tblDoc->FieldByName("CENA")->AsFloat;

podr.m_NDS=DM->tblDoc->FieldByName("NDS")->AsInteger;

podr.m_NSP=DM->tblDoc->FieldByName("NSP")->AsFloat;

podr.m_Discount=DM->tblDoc->FieldByName("DISCOUNT")->AsFloat;

podr.m_CenaDoc=DM->tblDoc->FieldByName("CENADOC")->AsFloat;

podr.m_DateProd=DM->tblDoc->FieldByName("DATEPROD")->AsDateTime;

podr.m_Kuda=DM->tblDoc->FieldByName("KUDA")->AsInteger;

podr.m_Accepted=DM->tblDoc->FieldByName("ACCEPTED")->AsInteger;

DM->tblDoc->Next();

return false;

}

int GetNDS(char * pText)

{ int rcode;

if (!DM->NDS->Active) DM->NDS->Open();

if (DM->NDS->Eof)

{ DM->NDS->Close();

return -1;

}

strcpy(pText, (DM->NDS->FieldByName("Percent")->AsString+"%").c_str());

rcode = DM->NDS->FieldByName("Nds")->AsInteger;

DM->NDS->Next();

return rcode;

}

void __fastcall TDM::LuxContViewBeforeDelete(TDataSet *DataSet)

{

LuxContChanged=true;

}

void __fastcall TDM::LuxContViewBeforeCancel(TDataSet *DataSet)

{

LuxContChanged=false;

}

void __fastcall TDM::tOthersReconcileError(TCustomClientDataSet *DataSet,

EReconcileError *E, TUpdateKind UpdateKind, TReconcileAction &Action)

{

AnsiString qq=E->Message;

MessageBox(NULL, qq.c_str(), "Others", 0);

}

void __fastcall TDM::DocsReconcileError(TCustomClientDataSet *DataSet,

EReconcileError *E, TUpdateKind UpdateKind, TReconcileAction &Action)

{

AnsiString qq=E->Message;

MessageBox(NULL, qq.c_str(), "Docs", 0);

}

void __fastcall TDM::LuxContViewAfterOpen(TDataSet *DataSet)

{

LuxContView->LogChanges=false;

}

void __fastcall TDM::LuxContViewReconcileError(

TCustomClientDataSet *DataSet, EReconcileError *E,

TUpdateKind UpdateKind, TReconcileAction &Action)

{

AnsiString qq=E->Message;

MessageBox(NULL, qq.c_str(), "LuxContView", 0);

}

void __fastcall TDM::UserListReconcileError(TCustomClientDataSet *DataSet,

EReconcileError *E, TUpdateKind UpdateKind, TReconcileAction &Action)

{

AnsiString qq=E->Message;

MessageBox(NULL, qq.c_str(), "UserList", 0);

}

void __fastcall TDM::TOstWithLuxAfterOpen(TDataSet *DataSet)

{

TOstWithLux->LogChanges=false;

}

void __fastcall TDM::AccReconcileError(TCustomClientDataSet *DataSet,

EReconcileError *E, TUpdateKind UpdateKind, TReconcileAction &Action)

{

AnsiString qq=E->Message;

MessageBox(NULL, qq.c_str(), "Acc", 0);

}

void __fastcall TDM::StdAccDReconcileError(TCustomClientDataSet *DataSet,

EReconcileError *E, TUpdateKind UpdateKind, TReconcileAction &Action)

{

AnsiString qq=E->Message;

MessageBox(NULL, qq.c_str(), "StdAccD", 0);

}

void __fastcall TDM::StdAccKReconcileError(TCustomClientDataSet *DataSet,

EReconcileError *E, TUpdateKind UpdateKind, TReconcileAction &Action)

{

AnsiString qq=E->Message;

MessageBox(NULL, qq.c_str(), "StdAccK", 0);

}

void __fastcall TDM::SysQueryReconcileError(TCustomClientDataSet *DataSet,

EReconcileError *E, TUpdateKind UpdateKind, TReconcileAction &Action)

{

AnsiString qq=E->Message;

MessageBox(NULL, qq.c_str(), "Sys", 0);

}

void __fastcall TDM::ResetLogChanges(TDataSet *DataSet)

{

((TClientDataSet*)DataSet)->LogChanges=false;

}

void ClosePeriod()

{ if (DM->UserList->FieldByName("Admin")->AsInteger)

{ Screen->Cursor=crHourGlass;

DM->ClosePer->Execute();

Screen->Cursor=crArrow;

}

else MessageBox(NULL, "Время выполнения проекта превышает срок", "Ошибка", 0);

}

void LoadOstatki()

{

Screen->Cursor=crHourGlass;

try {

DM->Conn->AppServer.Exec(Procedure("LoadOstatki"));

} catch (Exception &e)

{ MessageBox(NULL, e.Message.c_str(), "Ошибка", 0);

}

Screen->Cursor=crArrow;

}

void __fastcall TDM::TOstatkiAfterScroll(TDataSet *DataSet)

{ if (!DM->TOstatki->Active) return;

Screen->Cursor=crHourGlass;

DM->TOstWithLux->DisableControls();

DM->TOstWithLux->CommandText="select sklad, codecard, tipcard,partyno,cena,dateprod,kol,fixed,partylux,star, KOL AS OLDKOL, "+DM->ViewName+" where sklad="+

DM->TOstatki->FieldByName("SKLAD")->AsString+" and codecard="+

DM->TOstatki->FieldByName("CODECARD")->AsString+" and TIPCARD="+

DM->TOstatki->FieldByName("TIPCARD")->AsString;

DM->TOstWithLux->Active=false;

DM->TOstWithLux->Active=true;

DM->TOstWithLux->EnableControls();

Screen->Cursor=crArrow;

}

void __fastcall TDM::TOstatkiReconcileError(TCustomClientDataSet *DataSet,

EReconcileError *E, TUpdateKind UpdateKind, TReconcileAction &Action)

{

AnsiString qq=E->Message;

MessageBox(NULL, qq.c_str(), "TOstatki", 0);

}

// ------- печать отчетов ----------------------

const AnsiString cFCARDREP="http://fatboy/wareweb/Card.rpt?user0=%s&password0=%s&user0@PerOst=%s&password0@PerOst=%s",

cFCARDTRAF="http://fatboy/wareweb/Cardtraf.rpt?user0=%s&password0=%s&user0@PerOst=%s&password0@PerOst=%s",

cFCARDCONT="http://fatboy/wareweb/CONTINUE.RPT?user0=%s&password0=%s",

cFPRORDER="http://fatboy/wareweb/PRORDER.RPT?user0=%s&password0=%s",

cFRORDER="http://fatboy/wareweb/rorder.RPT?user0=%s&password0=%s",

cFRORDERLUX="http://fatboy/wareweb/rorder.RPT?user0=%s&password0=%s",

cFCTRAFFIC="http://fatboy/wareweb/traffic.rpt?user0=%s&password0=%s",

cFCSVODNA="http://fatboy/wareweb/svodna.rpt?user0=%s&password0=%s";

const AnsiString lFCARDREP="s:\\database\\exe\\sklad\\ora\\Card.rpt",

lFCARDTRAF="s:\\database\\exe\\sklad\\ora\\Cardtraf.rpt",

lFCARDCONT="s:\\database\\exe\\sklad\\ora\\CONTINUE.RPT",

lFPRORDER="s:\\database\\exe\\sklad\\ora\\PRORDER.RPT",

lFPRORDERLUX="s:\\database\\exe\\sklad\\ora\\PRORDERLUX.RPT",

lFRORDER="s:\\database\\exe\\sklad\\ora\\RORDER.RPT",

lFRORDERLUX="s:\\database\\exe\\sklad\\ora\\RORDERLUX.RPT",

lFCARDLUX="s:\\database\\exe\\sklad\\ora\\CARDLUX.RPT",

lFCARDTRAFLUX="s:\\database\\exe\\sklad\\ora\\CARDLUXTRAF.RPT";

TDM::PrintReport(int Output, PRINTS repTip, AnsiString pFormula)

{ // Output - направление вывода 0 - на экран, 1 - на принтер

if (Report==NULL)

{

int (WINAPI *lpDllEntryPoint)();

try {

Application->CreateForm(__classid(TReport), &Report);

}

catch ( ... )

{ HINSTANCE hLib = LoadLibrary("crystl32.ocx");

(FARPROC&)lpDllEntryPoint = GetProcAddress(hLib, _T("DllRegisterServer"));

if (lpDllEntryPoint != NULL)

(*lpDllEntryPoint)();

}

}

switch (repTip)

{ case pCARDFORM: Report->Caption="Карточка учета рабочего времени";

Report->RepView->ReportFileName=lFCARDREP;

break;

case pCARDTRAF: Report->Caption="Информация о сотруднике";

Report->RepView->ReportFileName=lFCARDTRAF;

break;

case pCARDCONT: Report->Caption="Информация о проекте";

Report->RepView->ReportFileName=lFCARDCONT;

break;

case pPRORDER: Report->Caption="Информация о типовых задачах";

Report->RepView->ReportFileName=lFPRORDER;

break;

case pPRORDERLUX: Report->Caption="Общая настройка программы";

Report->RepView->ReportFileName=lFPRORDERLUX;

break;

case pRORDER: Report->Caption="Настройка столбцов";

Report->RepView->ReportFileName=lFRORDER;

break;

case pRORDERLUX: Report->Caption="Настройка цветов";

Report->RepView->ReportFileName=lFRORDERLUX;

break;

case pCARDLUX: Report->Caption="Настройка баз данных";

Report->RepView->ReportFileName=lFCARDLUX;

break;

Report->RepView->ReportFileName=lFCARDTRAFLUX;

break;

default: break;

}

printf("");

Report->RepView->ReplaceSelectionFormula(WideString(pFormula.c_str()));

Report->RepView->Destination=Output;

if (!Output) Report->ShowModal();

else Report->RepView->PrintReport();

Report->Free();Report=NULL;

Screen->Cursor=crArrow;

}

void PrintRep(int Output, PRINTS repTip, char * psql, char * pFormula)

{

if (psql!="")

{ DM->SysQuery->CommandText=psql;

DM->SysQuery->Execute();

}

DM->WebReportPrint(Output, repTip, pFormula);

}

TDM::WebReportPrint(int Output, PRINTS repTip, AnsiString pFormula)

{

/* AnsiString ReportText;

//web

int (WINAPI *lpDllEntryPoint)();

try {

Application->CreateForm(__classid(TReport1), &Report1);

}

catch ( ... )

{ HINSTANCE hLib = LoadLibrary("crviewer.dll");

(FARPROC&)lpDllEntryPoint = GetProcAddress(hLib, _T("DllRegisterServer"));

if (lpDllEntryPoint != NULL)

(*lpDllEntryPoint)();

Application->CreateForm(__classid(TReport1), &Report1);

}

switch (repTip)

{ case pCARDFORM:{ Report->Caption="Карточка учета рабочего времени";

ReportText.printf(cFCARDREP.c_str(), GlUser.c_str(), GlPassword.c_str(), GlUser.c_str(), GlPassword.c_str());

}break;

/* case pCARDTRAF:{ Report->Caption="Информация о сотрудниках";

ReportText.printf(cFCARDTRAF.c_str(), GlUser.c_str(), GlPassword.c_str(), GlUser.c_str(), GlPassword.c_str());

}break;

case pCARDCONT:{ Report->Caption="Информация о проекте";

ReportText.printf(cFCARDCONT.c_str(), GlUser.c_str(), GlPassword.c_str());

}break; */

/* case pPRORDER:{ Report->Caption="Информация о типовых задачах";

ReportText.printf(cFPRORDER.c_str(), GlUser.c_str(), GlPassword.c_str());

}break;

case pRORDER: { Report->Caption="Общая настройка программы";

ReportText.printf(cFRORDER.c_str(), GlUser.c_str(), GlPassword.c_str());

}break;

case pRORDERLUX: { Report->Caption="Настройка столбцов";

ReportText.printf(cFRORDERLUX.c_str(), GlUser.c_str(), GlPassword.c_str());

}break;

case pCTRAFFIC:{ Report1->Caption="Настройка цветов";

ReportText.printf(cFCTRAFFIC.c_str(), GlUser.c_str(), GlPassword.c_str());

}break;

case pCSVODNA:{ Report1->Caption="Настройка баз данных";

ReportText.printf(cFCSVODNA.c_str(), GlUser.c_str(), GlPassword.c_str());

}break;

}

if (isWebRefresh[repTip]) Report1->IsRefresh=true;

else Report1->IsRefresh=false;

isWebRefresh[repTip]=1;

if (pFormula!="") ReportText+=pFormula;

Report1->ReportText=ReportText;

Report1->ShowModal();

Report1->Free();*/

return 1;

}

void CloseCex(int pSklad, double pLo, double pHi)

{

DM->CloseCex->Params->ParamByName("PSKLAD")->Value=pSklad;

DM->CloseCex->Params->ParamByName("PLO")->Value=pLo;

DM->CloseCex->Params->ParamByName("PHI")->Value=pHi;

DM->CloseCex->Execute();

}

void PrintRepPrep(int Output, PRINTS repTip, int pSklad, double pLo, double pHi, char * pFormula)

{

DM->PrepRep->Params->ParamByName("PSKLAD")->Value=pSklad;

DM->PrepRep->Params->ParamByName("PLO")->Value=pLo;

DM->PrepRep->Params->ParamByName("PHI")->Value=pHi;

DM->PrepRep->Execute();

//DM->WebReportPrint(Output, repTip, pFormula);

}

void __fastcall TDM::TOstArchAfterScroll(TDataSet *DataSet)

{

Screen->Cursor=crHourGlass;

DM->TOstWithLux->DisableControls();

DM->TOstWithLux->CommandText="select sklad, codecard, tipcard,partyno,cena,dateprod,kol,fixed,partylux,cont1,cont2, cont3, cont4,cont5, star, KOL AS OLDKOL from WHOUS.ostwithlux where sklad="+

DM->TOstatki->FieldByName("SKLAD")->AsString+" and codecard="+

DM->TOstatki->FieldByName("CODECARD")->AsString+" and TIPCARD="+

DM->TOstatki->FieldByName("TIPCARD")->AsString;

DM->TOstWithLux->Active=false;

DM->TOstWithLux->Active=true;

DM->TOstWithLux->EnableControls();

Screen->Cursor=crArrow;

}

__fastcall TFrmSpravoch::TFrmSpravoch(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TFrmSpravoch::Button1Click(TObject *Sender)

{

DM->SysQuery->Close();

DM->SysQuery->CommandText.printf("select max(a.codeassm) as max from WHOUS.Assembler a");

DM->SysQuery->Open();

int MCod= DM->SysQuery->FieldByName("max")->AsInteger;

DM->SysQuery->Close();

AnsiString dn=Edit1->Text+Edit2->Text ;

float f= StrToFloat(Edit3->Text);

DM->SysQuery->CommandText.printf("INSERT INTO WHOUS.Assembler (CodeAssm, IndAssm, NumAssm, Uch, Cena, "

" NameAssm, DecNum, OstCeh, OstUch, CodeCeh ) "

" values (%d , '%s', '%s', %d, %f, '%s', '%s', %d, %d, %d) ",

MCod+1 , Edit1->Text, Edit2->Text, StrToInt(Edit4->Text), f,

Memo1->Text, dn, 0, StrToInt(Edit5->Text), FrmKomplAssm->Skl);

DM->SysQuery->Execute();

DM->SysQuery->Close();

FrmSpravoch->Close();

}

void __fastcall TFrmSpravoch::Button2Click(TObject *Sender)

{

DM->SysQuery->Close();

FrmSpravoch->Close();

}

__fastcall TFrmDef::TFrmDef(TComponent* Owner)

: TForm(Owner)

{

}

void __fastcall TFrmDef::FormCreate(TObject *Sender)

{

DM->Prim->Close();

DM->Prim->CommandText.printf("select nomnum, namem, mark, proizv, def, ptr from "

"(select it.nomnum, it.namem, it.mark, t.proizv, t.prim*n.kolneed as ptr, "

"t.prim*(n.kolkompl+n.koldef)-(t.rashkompl+t.ostuch) as def from WHOUS.primpkiassm t, WHOUS.nomenklassm n, WHOUS.item it "

"where n.codeassm=t.assmcode and t.codecard=it.codrec and t.codeceh=%d and t.assmcode=%d "

"order by it.nomnum) where def>0 ", FrmKomplAssm->Skl, DM->NomAssm->FieldByName("CodeAssm")->AsInteger);

DM->Prim->Open();

}

void __fastcall TFrmDef::FormClose(TObject *Sender, TCloseAction &Action)

{

DM->Prim->Close();

}

__fastcall TFrmOperAssm::TFrmOperAssm(TComponent* Owner)

: TForm(Owner)

{

}

void __fastcall TFrmOperAssm::Edit1KeyPress(TObject *Sender, char &Key)

{

if (Key==13)

{

DM->Prim->Close();

if (Edit1->Text=="")

{

DM->Prim->CommandText.printf("select a.decnum, t.ndoc, t.datedoc, t.kol, "

" decode(t.tipoper,1,'skomplektovano',2,'skomplektovano s deficitom',3,'vidano na uchastok',4,'vidano na uchastok s deficitom',5,'dokomplektovano',6,'izgotovleno','') as komentar "

" from whous.uchassm t, whous.assembler a where t.codeassm=a.codeassm and a.codeceh=%d order by t.codeassm ",

FrmKomplAssm->Skl);

}

else

{

DM->Prim->CommandText.printf("select a.decnum, t.ndoc, t.datedoc, t.kol, "

" decode(t.tipoper,1,'skomplektovano',2,'skomplektovano s deficitom',3,'vidano na uchastok',4,'vidano na uchastok s deficitom',5,'dokomplektovano',6,'izgotovleno','') as komentar "

" from whous.uchassm t, whous.assembler a where t.codeassm=a.codeassm and a.codeceh=%d and a.decnum like('%s%') "

" order by t.codeassm ", FrmKomplAssm->Skl, Edit1->Text);

}

DM->Prim->Open();

}

}

void __fastcall TFrmOperAssm::Edit2KeyPress(TObject *Sender, char &Key)

{

if (Key==13)

{

DM->Prim->Close();

if (Edit2->Text=="")

{

DM->Prim->CommandText.printf("select a.decnum, t.ndoc, t.datedoc, t.kol, "

" decode(t.tipoper,1,'skomplektovano',2,'skomplektovano s deficitom',3,'vidano na uchastok',4,'vidano na uchastok s deficitom',5,'dokomplektovano',6,'izgotovleno','') as komentar "

" from whous.uchassm t, whous.assembler a where t.codeassm=a.codeassm and a.codeceh=%d order by t.codeassm ",

FrmKomplAssm->Skl);

}

else

{

DM->Prim->CommandText.printf("select a.decnum, t.ndoc, t.datedoc, t.kol, "

" decode(t.tipoper,1,'skomplektovano',2,'skomplektovano s deficitom',3,'vidano na uchastok',4,'vidano na uchastok s deficitom',5,'dokomplektovano',6,'izgotovleno','') as komentar "

" from whous.uchassm t, whous.assembler a where t.codeassm=a.codeassm and a.codeceh=%d and t.datedoc=TO_DATE('%s','dd.mm.yyyy') "

" order by t.codeassm ", FrmKomplAssm->Skl, Edit2->Text);

}

DM->Prim->Open();

}

}

void __fastcall TFrmOperAssm::RadioButton1Click(TObject *Sender)

{

if (RadioButton1->Checked)

{

DM->Prim->Close();

DM->Prim->CommandText.printf("select a.decnum, t.ndoc, t.datedoc, t.kol, "

" decode(t.tipoper,1,'skomplektovano',2,'skomplektovano s deficitom',3,'vidano na uchastok',4,'vidano na uchastok s deficitom',5,'dokomplektovano',6,'izgotovleno','') as komentar "

" from whous.uchassm t, whous.assembler a where t.codeassm=a.codeassm and t.datedoc=TO_DATE('%s','dd.mm.yyyy') order by t.codeassm ",

FrmKomplAssm->Skl);

}

DM->Prim->Open();

}

void __fastcall TFrmOperAssm::RadioButton4Click(TObject *Sender)

{

if (RadioButton4->Checked)

{

DM->Prim->Close();

AnsiString str=" order by t.codeassm ";

if (Edit2->Text=="") {str=" order by t.codeassm ";}

else {str.printf(" and t.datedoc=TO_DATE('%s','dd.mm.yyyy') order by t.codeassm ", Edit2->Text);};

DM->Prim->CommandText.printf("select a.decnum, t.ndoc, t.datedoc, t.kol, "

" decode(t.tipoper,1,'skomplektovano',2,'skomplektovano s deficitom',3,'vidano na uchastok',4,'vidano na uchastok s deficitom',5,'dokomplektovano',6,'izgotovleno','') as komentar "

" from whous.uchassm t, whous.assembler a where t.codeassm=a.codeassm and t.tipoper=6 ",

FrmKomplAssm->Skl);

DM->Prim->CommandText=DM->Prim->CommandText + str;

}

DM->Prim->Open();

}

void __fastcall TFrmOperAssm::RadioButton2Click(TObject *Sender)

{

if (RadioButton2->Checked)

{

DM->Prim->Close();

AnsiString str=" order by t.codeassm ";

if (Edit2->Text=="") {str=" order by t.codeassm ";}

else {str.printf(" and t.datedoc=TO_DATE('%s','dd.mm.yyyy') order by t.codeassm ", Edit2->Text);};

DM->Prim->CommandText.printf("select a.decnum, t.ndoc, t.datedoc, t.kol, "

" decode(t.tipoper,1,'skomplektovano',2,'skomplektovano s deficitom',3,'vidano na uchastok',4,'vidano na uchastok s deficitom',5,'dokomplektovano',6,'izgotovleno','') as komentar "

" from whous.uchassm t, whous.assembler a where t.codeassm=a.codeassm and (t.tipoper=1 or t.tipoper=2) ",

FrmKomplAssm->Skl);

DM->Prim->CommandText=DM->Prim->CommandText + str;

}

DM->Prim->Open();

}

void __fastcall TFrmOperAssm::RadioButton3Click(TObject *Sender)

{

if (RadioButton3->Checked)

{

DM->Prim->Close();

AnsiString str=" order by t.codeassm ";

if (Edit2->Text=="") {str=" order by t.codeassm ";}

else {str.printf(" and t.datedoc=TO_DATE('%s','dd.mm.yyyy') order by t.codeassm ", Edit2->Text);};

DM->Prim->CommandText.printf("select a.decnum, t.ndoc, t.datedoc, t.kol, "

" decode(t.tipoper,1,'skomplektovano',2,'skomplektovano s deficitom',3,'vidano na uchastok',4,'vidano na uchastok s deficitom',5,'dokomplektovano',6,'izgotovleno','') as komentar "

" from whous.uchassm t, whous.assembler a where t.codeassm=a.codeassm and (t.tipoper=3 or t.tipoper=4) ",

FrmKomplAssm->Skl);

DM->Prim->CommandText=DM->Prim->CommandText + str;

}

DM->Prim->Open();

}

void __fastcall TFrmOperAssm::RadioButton5Click(TObject *Sender)

{

if (RadioButton5->Checked)

{

DM->Prim->Close();

AnsiString str=" order by t.codeassm ";

if (Edit2->Text=="") {str=" order by t.codeassm ";}

else {str.printf(" and t.datedoc=TO_DATE('%s','dd.mm.yyyy') order by t.codeassm ", Edit2->Text);};

DM->Prim->CommandText.printf("select a.decnum, t.ndoc, t.datedoc, t.kol, "

" decode(t.tipoper,1,'skomplektovano',2,'skomplektovano s deficitom',3,'vidano na uchastok',4,'vidano na uchastok s deficitom',5,'dokomplektovano',6,'izgotovleno','') as komentar "

" from whous.uchassm t, whous.assembler a where t.codeassm=a.codeassm ",

FrmKomplAssm->Skl);

DM->Prim->CommandText=DM->Prim->CommandText + str;

}

DM->Prim->Open();

}

__fastcall TFrmSostA::TFrmSostA(TComponent* Owner)

: TForm(Owner)

{

}

void __fastcall TFrmSostA::Button1Click(TObject *Sender)

{

/* Application->CreateForm(__classid(TCardFT), &CardFT);

if(CardFT->ShowModal()==mrOk)

{ if(IDYES==MessageDlg("Сейчас отчеты будут отправлены на принтер. Продолжить?", mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, 0))

{ AnsiString sf, tmp=(GlSklad?AnsiString("SKLAD="+IntToStr(GlSklad)+" and "):AnsiString(""))+"NOMERCARD BETWEEN "+CardFT->CardF->Text+" AND "+CardFT->CardT->Text;

DM->Conn->AppServer.Exec(Procedure("CreateCardsRep")<<0<<0<<0<<0 << WideString(tmp));

DM->RepView->Output=toPrinter;

sf=(GlSklad?AnsiString("{CARDFORM.SKLAD}="+IntToStr(GlSklad)+" and "):AnsiString(""))+"({CARDFORM.NOMERCARD} in "+CardFT->CardF->Text+" to "+CardFT->CardT->Text+") AND {CARDFORM.USERpr}='"+DM->UserList->FieldByName("USER_")->AsString+"'";

DM->PrintReport(1, pCARDFORM, sf);

}

} */

}

__fastcall TFrmVidKol::TFrmVidKol(TComponent* Owner)

: TForm(Owner)

{

}

void __fastcall TFrmVidKol::Button1Click(TObject *Sender)

{

if (DM->NomAssm->FieldByName("flagvid")->AsInteger)

{

}

else

{

DM->Conn->AppServer.Exec(Function("Transact")<< 1);

try

{ //Установить галочки в нужных полях программы

Screen->Cursor=crHourGlass;

DM->SysQuery->CommandText.printf("UPDATE WHOUS.NomenklAssm SET NomenklAssm.FlagVid=1 where NomenklAssm.CodeAssm=%d",

DM->NomAssm->FieldByName("codeassm")->AsInteger);

DM->SysQuery->Execute();

DM->SysQuery->Close();

//Уменьшить время простоев

DM->SysQuery->CommandText.printf("UPDATE WHOUS.Assembler SET Assembler.OstUch=Assembler.OstUch + %d + %d "

" WHERE Assembler.CodeAssm=%d ", DM->NomAssm->FieldByName("KolKompl")->AsInteger,

DM->NomAssm->FieldByName("KolDef")->AsInteger, DM->NomAssm->FieldByName("codeassm")->AsInteger);

DM->SysQuery->Execute();

DM->SysQuery->Close();

if (DM->NomAssm->FieldByName("kolkompl")->AsInteger)

{

DM->SysQuery->CommandText.printf("INSERT INTO WHOUS.UchAssm (SELECT t.CodeAssm,"

"'%s' as NDoc, TO_DATE('%s','dd.mm.yyyy') as DateDoc, %d as kol, %d as cehuch, 3 as tipoper"

" from WHOUS.NomenklAssm t WHERE t.codeceh=%d and t.codeassm=%d)", FrmVidKol->Edit1->Text,

DateToStr(Date()),DM->NomAssm->FieldByName("kolkompl")->AsInteger,

FrmKomplAssm->Skl, FrmKomplAssm->Skl, DM->NomAssm->FieldByName("CodeAssm")->AsInteger);

DM->SysQuery->Execute();

DM->SysQuery->Close();

}

if (DM->NomAssm->FieldByName("koldef")->AsInteger)

{

DM->SysQuery->CommandText.printf("INSERT INTO WHOUS.UchAssm (SELECT t.CodeAssm,"

"'%s' as NDoc, TO_DATE('%s','dd.mm.yyyy') as DateDoc, %d as kol, %d as cehuch, 4 as tipoper"

" from WHOUS.NomenklAssm t WHERE t.codeceh=%d and t.codeassm=%d)", FrmVidKol->Edit1->Text,

DateToStr(Date()),DM->NomAssm->FieldByName("koldef")->AsInteger, FrmKomplAssm->Skl,

FrmKomplAssm->Skl, DM->NomAssm->FieldByName("CodeAssm")->AsInteger);

DM->SysQuery->Execute();

DM->SysQuery->Close();

}

// добавляем новую позицию в SHOPNEEDS

DM->SysQuery->CommandText.printf("select a.NumAssm, a.IndAssm from WHOUS.Assembler a where a.CodeAssm=%d ",

DM->NomAssm->FieldByName("CodeAssm")->AsInteger);

DM->SysQuery->Open();

AnsiString ind, dn;

ind=DM->SysQuery->FieldByName("IndAssm")->AsString;

dn=DM->SysQuery->FieldByName("NumAssm")->AsString;

DM->SysQuery->Close();

DM->SysQuery->CommandText.printf("select t.name from WHOUS.sklad t where t.sklad=%d ", FrmKomplAssm->Skl);

DM->SysQuery->Open();

AnsiString s=DM->SysQuery->FieldByName("name")->AsString.SubString(1,3);

AnsiString s1=DM->SysQuery->FieldByName("name")->AsString;

DM->SysQuery->Close();

DM->SysQuery->CommandText.printf("select CODENEED FROM WHOUS.SHOPNEEDS WHERE "

"CEX='%s' AND IND='%s' AND DNUM='%s' AND TIP=0 ", s, ind, dn);

DM->SysQuery->Open();

bool flg=DM->SysQuery->Eof;

int maxcod= !flg ? DM->SysQuery->FieldByName("codeneed")->AsInteger : 0;

DM->SysQuery->Close();

if (flg)

{ DM->SysQuery->CommandText.printf("SELECT decnum from WHOUS.Assembler where codeassm=%d",

DM->NomAssm->FieldByName("CodeAssm")->AsInteger);

DM->SysQuery->Open();

AnsiString str="'"+DM->SysQuery->FieldByName("decnum")->AsString+"'";

DM->SysQuery->Close();

DM->SysQuery->CommandText="SELECT max(codeneed) as max from WHOUS.SHOPNEEDS ";

DM->SysQuery->Open();

maxcod=DM->SysQuery->FieldByName("max")->AsInteger+1;

DM->SysQuery->Close();

//Надо изменить данные о сотрудниках !!!!!

DM->SysQuery->CommandText.printf("INSERT INTO WHOUS.SHOPNEEDS (CODENEED, DNUM, IND, CEX, TIP) "

" VALUES (%d ,'%s', '%s', '%s', 0)", maxcod, dn, ind, s );

DM->SysQuery->Execute();

DM->SysQuery->Close();

}

// Добавляем записи в поле задач

DM->Prim->Close();

DM->Prim->CommandText.printf("select PrimPKIAssm.CodeCard, PrimPKIAssm.OstUch, PrimPKIAssm.RashKompl "

" from WHOUS.PrimPKIAssm WHERE PrimPKIAssm.AssmCode=%d ", DM->NomAssm->FieldByName("codeassm")->AsInteger);

DM->Prim->Open();

DM->UchAssm->Close();

AnsiString USER=DM->UserList->FieldByName("USER_")->AsString;

int CODEDOC=DM->UserList->FieldByName("LASTDOC")->AsInteger;

DM->SysQuery->CommandText.printf("select t.codedoc from WHOUS.HATDOC t "

"where t.tipdoc=7 and t.sklad=%d and t.tipoper=0 and t.user_='%s'",

FrmKomplAssm->Skl, USER );

DM->SysQuery->Open();

int coddoc=0;

if (DM->SysQuery->Eof)

{

DM->SysQuery->Close();

DM->SysQuery->CommandText.printf("INSERT INTO WHOUS.HATDOC (DOC_NOMER, TIPDOC, DATA, contractor, USERMODY, SIFRDOC, VIDOPER, ACTI, KORR, SUMSUMNDS, SUMOPL, TIPOPER, SKLAD, USER_, CODEDOC)"

" VALUES ('%s', %ld, TO_DATE('%s', 'DD.MM.YYYY'), 690, '%s', '', '', 1, '', 0, 0, 0, %ld, '%s', %ld)",

s1, 7, FormatDateTime("dd.mm.yyyy", Date()),USER, FrmKomplAssm->Skl, USER, CODEDOC);

DM->SysQuery->Execute();

DM->SysQuery->Close();

DM->SysQuery->CommandText="UPDATE WHOUS.USERLIST SET LASTDOC=LASTDOC+1 WHERE USER_='"+USER+"'";

DM->SysQuery->Execute();DM->SysQuery->Close();

DM->UserList->Close();

DM->UserList->Open();

coddoc=CODEDOC;

}

else

{

coddoc=DM->SysQuery->FieldByName("codedoc")->AsInteger;

DM->SysQuery->Close();

}

while (!(DM->Prim->Eof)) //Для каждого сотрудника

{

DM->UchAssm->CommandText.printf("select t.codecard, t.kol, p.rashkompl, "

" t.partyno, t.data, pt.cena, p.proizv, p.prim from WHOUS.ostatki t, WHOUS.primpkiassm p, WHOUS.partys pt "

" where t.codecard=p.codecard and pt.codecard=t.codecard and pt.partyno=t.partyno and "

" p.assmcode=%d and t.sklad=%d and t.kol>0 and t.codecard=%d order by t.codecard, pt.cena desc ",

DM->NomAssm->FieldByName("CodeAssm")->AsInteger, FrmKomplAssm->Skl,

DM->Prim->FieldByName("codecard")->AsInteger);

DM->UchAssm->Open();

// int flag=1;

int rash=0;

int sum=0;

//Просмотр по каждой операции

while ((!(DM->UchAssm->Eof))&(sum<DM->UchAssm->FieldByName("rashkompl")->AsInteger))

{

if ((DM->UchAssm->FieldByName("kol")->AsInteger-DM->UchAssm->FieldByName("rashkompl")->AsInteger+sum)>=0)

{

rash = DM->UchAssm->FieldByName("rashkompl")->AsInteger-sum;

// flag=0;

sum=sum+rash;

}

else

{

rash = DM->UchAssm->FieldByName("kol")->AsInteger;

// flag=1;

sum=sum+rash;

}

DM->SysQuery->Close();

DM->SysQuery->CommandText.printf("INSERT INTO WHOUS.Nakl ( codecard, partyno, datecard, "

" tipcard, kolpodoc, limit, tootp, kol,nsp,discount, cenadoc, codedoc, user_, nds, prvo, accepted, kuda ) "

" values ( %d,%d,TO_DATE('%s','dd.mm.yyyy'), 1, 0, 0, 0, %d, 0, 0, 0, %d, '%s', 0, '%s', 1, %d )",

DM->Prim->FieldByName("codecard")->AsInteger, DM->UchAssm->FieldByName("partyno")->AsInteger,

DateToStr(Date()), rash, coddoc, DM->UserList->FieldByName("USER_")->AsString, DM->UchAssm->FieldByName("proizv")->AsString, maxcod);

DM->SysQuery->Execute();

DM->SysQuery->Close();

DM->SysQuery->CommandText.printf("UPDATE WHOUS.PrimPKIAssm SET PrimPKIAssm.OstUch=PrimPKIAssm.OstUch + %d, "

" PrimPKIAssm.RashKompl=PrimPKIAssm.RashKompl - %d "

" WHERE PrimPKIAssm.AssmCode=%d and PrimPKIAssm.CodeCard=%d", rash,rash,

DM->NomAssm->FieldByName("codeassm")->AsInteger, DM->Prim->FieldByName("codecard")->AsInteger);

DM->SysQuery->Execute();

DM->SysQuery->Close();

DM->ShopAccProc->Params->ParamByName("pAction")->Value=3;

DM->ShopAccProc->Params->ParamByName("pSklad")->Value=FrmKomplAssm->Skl;

DM->ShopAccProc->Params->ParamByName("pCode")->Value=DM->Prim->FieldByName("codecard")->AsFloat;

DM->ShopAccProc->Params->ParamByName("pTip")->Value=1;

DM->ShopAccProc->Params->ParamByName("pPartyNo")->Value=DM->UchAssm->FieldByName("partyno")->AsFloat;

DM->ShopAccProc->Params->ParamByName("pKol")->Value= rash;

DM->ShopAccProc->Params->ParamByName("pPrvoFrom")->Value="";

DM->ShopAccProc->Params->ParamByName("pPrvoTo")->Value=DM->UchAssm->FieldByName("proizv")->AsString;

Screen->Cursor=crHourGlass;

DM->ShopAccProc->Execute();

DM->UchAssm->Next();

}

DM->UchAssm->Close();

DM->Prim->Next();

}

DM->Prim->Close();

FrmVidKol->Close();

}

catch (Exception &e)

{ //MessageBox(NULL, e.Message.c_str(), "Ошибка ! Работа прервана !", 0);

FrmVidKol->Free();

//return 0;

}

Screen->Cursor=crArrow;

FrmVidKol->Close();

Application->MessageBox("Вывод монтажников на работу ", "Сообщение", MB_OK);

DM->Conn->AppServer.Exec(Function("Transact")<< 2);

DM->NomAssm->Close();

DM->NomAssm->Open();

}

}

void __fastcall TFrmVidKol::Button2Click(TObject *Sender)

{

FrmVidKol->Close();

}

_fastcall TFrmKomplAssm::TFrmKomplAssm(TComponent* Owner)

: TForm(Owner)

{

}

void __fastcall TFrmKomplAssm::AddButtonClick(TObject *Sender)

{

ComboBox1->Visible=true;

DM->NomAssm->Insert();

}

void __fastcall TFrmKomplAssm::FormActivate(TObject *Sender)

{

DM->SysQuery->CommandText.printf("select a.decnum from whous.assembler a"

" where CodeCeh=%d and decnum not in (SELECT a.DecNum FROM WHOUS.Assembler a, WHOUS.NomenklAssm n "

" WHERE a.CodeAssm=n.CodeAssm and (n.flagvid<2 or n.kolneed>n.kolkompl)) order by a.decnum", Skl);

DM->SysQuery->Open();

DM->SysQuery->First();

while (!DM->SysQuery->Eof)

{ ComboBox1->Items->Add(DM->SysQuery->FieldByName("DecNum")->AsString);

DM->SysQuery->Next();

}

DM->SysQuery->Close();

DM->NomAssm->CommandText.printf("select a.decnum, n.codeassm, n.kolneed, n.kolkompl, n.koldef, "

" n.flagvid, n.kolizg, decode(n.flagvid,1,'над операцией',2,'монтажника','') as kom, "

" n.datekompl, n.dateinsert from WHOUS.assembler a, WHOUS.nomenklassm n where a.codeceh=%d "

" and a.codeassm=n.codeassm and (n.flagvid<2 or n.kolizg<n.kolneed) order by n.datekompl, n.dateinsert, n.flagvid ", Skl);

DM->NomAssm->Open();

DM->NomAssm->First();

}

void __fastcall TFrmKomplAssm::FormClose(TObject *Sender,

TCloseAction &Action)

{

DM->NomAssm->Close();

DM->Assembler->Close();

}

void __fastcall TFrmKomplAssm::RaschButtonClick(TObject *Sender)

{

DM->Prim->CommandText.printf("select decnum, nomnum, namem, mark, proizv, def from "

"(select a.decnum, it.nomnum, it.namem, it.mark, t.proizv,"

"t.prim*(n.kolkompl+n.koldef)-(t.rashkompl+t.ostuch) as def from whous.primpkiassm t, "

" whous.nomenklassm n, whous.item it, whous.assembler a "

"where n.codeassm=t.assmcode and t.codecard=it.codrec and t.codeceh=%d "

"and a.codeassm=t.assmcode "

"order by a.decnum, it.nomnum) where def>0 ", FrmKomplAssm->Skl);

DM->Prim->Open();

DM->SysQuery->CommandText="select max(def) as MaxDef from( "+ DM->Prim->CommandText +" )";

DM->SysQuery->Open();

int MaxDef=DM->SysQuery->FieldByName("MaxDef")->AsInteger;

DM->SysQuery->Close();

Application->CreateForm(__classid(TFrmPotrDef), &FrmPotrDef);


Подобные документы

Работы в архивах красиво оформлены согласно требованиям ВУЗов и содержат рисунки, диаграммы, формулы и т.д.
PPT, PPTX и PDF-файлы представлены только в архивах.
Рекомендуем скачать работу.