Version18.103

This commit is contained in:
Antonio Cañas Vargas 2019-04-09 00:24:50 +02:00
parent de4074523e
commit 778a89bff1
7 changed files with 141 additions and 71 deletions

View File

@ -1779,10 +1779,10 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
/* ActChgCtrSta */{1209,-1,TabUnk,ActSeeCtr , 0, 0, 0, 0,0x300, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Ctr_ChangeCtrStatus ,Ctr_ContEditAfterChgCtr ,NULL}, /* ActChgCtrSta */{1209,-1,TabUnk,ActSeeCtr , 0, 0, 0, 0,0x300, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Ctr_ChangeCtrStatus ,Ctr_ContEditAfterChgCtr ,NULL},
/* ActEdiPlc */{ 704,-1,TabUnk,ActSeePlc , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plc_EditPlaces ,NULL}, /* ActEdiPlc */{ 704,-1,TabUnk,ActSeePlc , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plc_EditPlaces ,NULL},
/* ActNewPlc */{ 705,-1,TabUnk,ActSeePlc , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plc_RecFormNewPlace ,NULL}, /* ActNewPlc */{ 705,-1,TabUnk,ActSeePlc , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Plc_RecFormNewPlace ,Plc_ContEditAfterChgPlc ,NULL},
/* ActRemPlc */{ 776,-1,TabUnk,ActSeePlc , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plc_RemovePlace ,NULL}, /* ActRemPlc */{ 776,-1,TabUnk,ActSeePlc , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Plc_RemovePlace ,Plc_ContEditAfterChgPlc ,NULL},
/* ActRenPlcSho */{ 894,-1,TabUnk,ActSeePlc , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plc_RenamePlaceShort ,NULL}, /* ActRenPlcSho */{ 894,-1,TabUnk,ActSeePlc , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Plc_RenamePlaceShort ,Plc_ContEditAfterChgPlc ,NULL},
/* ActRenPlcFul */{ 895,-1,TabUnk,ActSeePlc , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plc_RenamePlaceFull ,NULL}, /* ActRenPlcFul */{ 895,-1,TabUnk,ActSeePlc , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Plc_RenamePlaceFull ,Plc_ContEditAfterChgPlc ,NULL},
/* ActEdiDpt */{ 677,-1,TabUnk,ActSeeDpt , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Dpt_EditDepartments ,NULL}, /* ActEdiDpt */{ 677,-1,TabUnk,ActSeeDpt , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Dpt_EditDepartments ,NULL},
/* ActNewDpt */{ 687,-1,TabUnk,ActSeeDpt , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dpt_RecFormNewDpt ,Dpt_ContEditAfterChgDpt ,NULL}, /* ActNewDpt */{ 687,-1,TabUnk,ActSeeDpt , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dpt_RecFormNewDpt ,Dpt_ContEditAfterChgDpt ,NULL},

View File

@ -464,10 +464,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 18.102 (2019-04-08)" #define Log_PLATFORM_VERSION "SWAD 18.103 (2019-04-09)"
#define CSS_FILE "swad18.92.css" #define CSS_FILE "swad18.92.css"
#define JS_FILE "swad18.92.js" #define JS_FILE "swad18.92.js"
/* /*
Version 18.103: Apr 09, 2019 Code refactoring in edition of places. (242091 lines)
Version 18.102: Apr 08, 2019 Code refactoring in edition of departments. (242033 lines) Version 18.102: Apr 08, 2019 Code refactoring in edition of departments. (242033 lines)
Version 18.101.6: Apr 08, 2019 Code refactoring in edition of countries. (241940 lines) Version 18.101.6: Apr 08, 2019 Code refactoring in edition of countries. (241940 lines)
Version 18.101.5: Apr 08, 2019 Code refactoring in edition of institutions. (241898 lines) Version 18.101.5: Apr 08, 2019 Code refactoring in edition of institutions. (241898 lines)

View File

@ -1067,8 +1067,9 @@ void Dpt_RecFormNewDpt (void)
else // Add new department to database else // Add new department to database
{ {
Dpt_CreateDepartment (Dpt_EditingDpt); Dpt_CreateDepartment (Dpt_EditingDpt);
Ale_ShowAlert (Ale_SUCCESS,Txt_Created_new_department_X, Ale_CreateAlert (Ale_SUCCESS,NULL,
Dpt_EditingDpt->FullName); Txt_Created_new_department_X,
Dpt_EditingDpt->FullName);
} }
} }
else // If there is not a web else // If there is not a web
@ -1217,11 +1218,10 @@ static void Dpt_EditingDepartmentConstructor (void)
static void Dpt_EditingDepartmentDestructor (void) static void Dpt_EditingDepartmentDestructor (void)
{ {
/***** Free memory used for degree *****/ /***** Free memory used for department *****/
if (Dpt_EditingDpt != NULL) if (Dpt_EditingDpt != NULL)
{ {
free ((void *) Dpt_EditingDpt); free ((void *) Dpt_EditingDpt);
Dpt_EditingDpt = NULL; Dpt_EditingDpt = NULL;
} }
} }

View File

@ -252,9 +252,6 @@ void Gbl_InitializeGlobals (void)
Gbl.Plcs.Num = 0; Gbl.Plcs.Num = 0;
Gbl.Plcs.Lst = NULL; Gbl.Plcs.Lst = NULL;
Gbl.Plcs.SelectedOrder = Plc_ORDER_DEFAULT; Gbl.Plcs.SelectedOrder = Plc_ORDER_DEFAULT;
Gbl.Plcs.EditingPlc.PlcCod = -1L;
Gbl.Plcs.EditingPlc.ShrtName[0] = '\0';
Gbl.Plcs.EditingPlc.FullName[0] = '\0';
Gbl.Hlds.LstIsRead = false; // List is not read Gbl.Hlds.LstIsRead = false; // List is not read
Gbl.Hlds.Num = 0; Gbl.Hlds.Num = 0;

View File

@ -224,14 +224,12 @@ struct Globals
unsigned Num; // Number of departments unsigned Num; // Number of departments
struct Department *Lst; // List of departments struct Department *Lst; // List of departments
Dpt_Order_t SelectedOrder; Dpt_Order_t SelectedOrder;
struct Department EditingDpt;
} Dpts; } Dpts;
struct struct
{ {
unsigned Num; // Number of places unsigned Num; // Number of places
struct Place *Lst; // List of places struct Place *Lst; // List of places
Plc_Order_t SelectedOrder; Plc_Order_t SelectedOrder;
struct Place EditingPlc;
} Plcs; } Plcs;
struct struct
{ {

View File

@ -57,6 +57,8 @@ extern struct Globals Gbl;
/***************************** Private variables *****************************/ /***************************** Private variables *****************************/
/*****************************************************************************/ /*****************************************************************************/
static struct Place *Plc_EditingPlc = NULL; // Static variable to keep the place being edited
/*****************************************************************************/ /*****************************************************************************/
/***************************** Private prototypes ****************************/ /***************************** Private prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
@ -65,6 +67,7 @@ static void Plc_GetParamPlcOrder (void);
static bool Plc_CheckIfICanCreatePlaces (void); static bool Plc_CheckIfICanCreatePlaces (void);
static void Plc_PutIconsListingPlaces (void); static void Plc_PutIconsListingPlaces (void);
static void Plc_PutIconToEditPlaces (void); static void Plc_PutIconToEditPlaces (void);
static void Plc_EditPlacesInternal (void);
static void Plc_PutIconsEditingPlaces (void); static void Plc_PutIconsEditingPlaces (void);
static void Plc_ListPlacesForEdition (void); static void Plc_ListPlacesForEdition (void);
@ -78,6 +81,9 @@ static void Plc_PutFormToCreatePlace (void);
static void Plc_PutHeadPlaces (void); static void Plc_PutHeadPlaces (void);
static void Plc_CreatePlace (struct Place *Plc); static void Plc_CreatePlace (struct Place *Plc);
static void Plc_EditingPlaceConstructor (void);
static void Plc_EditingPlaceDestructor (void);
/*****************************************************************************/ /*****************************************************************************/
/*************************** List all the places *****************************/ /*************************** List all the places *****************************/
/*****************************************************************************/ /*****************************************************************************/
@ -249,6 +255,18 @@ static void Plc_PutIconToEditPlaces (void)
/*****************************************************************************/ /*****************************************************************************/
void Plc_EditPlaces (void) void Plc_EditPlaces (void)
{
/***** Place constructor *****/
Plc_EditingPlaceConstructor ();
/***** Edit places *****/
Plc_EditPlacesInternal ();
/***** Place destructor *****/
Plc_EditingPlaceDestructor ();
}
static void Plc_EditPlacesInternal (void)
{ {
extern const char *Hlp_INSTITUTION_Places_edit; extern const char *Hlp_INSTITUTION_Places_edit;
extern const char *Txt_Places; extern const char *Txt_Places;
@ -588,32 +606,33 @@ void Plc_RemovePlace (void)
{ {
extern const char *Txt_To_remove_a_place_you_must_first_remove_all_centres_of_that_place; extern const char *Txt_To_remove_a_place_you_must_first_remove_all_centres_of_that_place;
extern const char *Txt_Place_X_removed; extern const char *Txt_Place_X_removed;
struct Place Plc;
/***** Place constructor *****/
Plc_EditingPlaceConstructor ();
/***** Get place code *****/ /***** Get place code *****/
if ((Plc.PlcCod = Plc_GetParamPlcCod ()) == -1L) if ((Plc_EditingPlc->PlcCod = Plc_GetParamPlcCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of place is missing."); Lay_ShowErrorAndExit ("Code of place is missing.");
/***** Get data of the place from database *****/ /***** Get data of the place from database *****/
Plc_GetDataOfPlaceByCod (&Plc); Plc_GetDataOfPlaceByCod (Plc_EditingPlc);
/***** Check if this place has centres *****/ /***** Check if this place has centres *****/
if (Plc.NumCtrs) // Place has centres ==> don't remove if (Plc_EditingPlc->NumCtrs) // Place has centres ==> don't remove
Ale_ShowAlert (Ale_WARNING,Txt_To_remove_a_place_you_must_first_remove_all_centres_of_that_place); Ale_CreateAlert (Ale_WARNING,NULL,
Txt_To_remove_a_place_you_must_first_remove_all_centres_of_that_place);
else // Place has no centres ==> remove it else // Place has no centres ==> remove it
{ {
/***** Remove place *****/ /***** Remove place *****/
DB_QueryDELETE ("can not remove a place", DB_QueryDELETE ("can not remove a place",
"DELETE FROM places WHERE PlcCod=%ld", "DELETE FROM places WHERE PlcCod=%ld",
Plc.PlcCod); Plc_EditingPlc->PlcCod);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_Place_X_removed, Ale_CreateAlert (Ale_SUCCESS,NULL,
Plc.FullName); Txt_Place_X_removed,
Plc_EditingPlc->FullName);
} }
/***** Show the form again *****/
Plc_EditPlaces ();
} }
/*****************************************************************************/ /*****************************************************************************/
@ -622,6 +641,10 @@ void Plc_RemovePlace (void)
void Plc_RenamePlaceShort (void) void Plc_RenamePlaceShort (void)
{ {
/***** Place constructor *****/
Plc_EditingPlaceConstructor ();
/***** Rename place *****/
Plc_RenamePlace (Cns_SHRT_NAME); Plc_RenamePlace (Cns_SHRT_NAME);
} }
@ -631,6 +654,10 @@ void Plc_RenamePlaceShort (void)
void Plc_RenamePlaceFull (void) void Plc_RenamePlaceFull (void)
{ {
/***** Place constructor *****/
Plc_EditingPlaceConstructor ();
/***** Rename place *****/
Plc_RenamePlace (Cns_FULL_NAME); Plc_RenamePlace (Cns_FULL_NAME);
} }
@ -644,45 +671,44 @@ static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName)
extern const char *Txt_The_place_X_already_exists; extern const char *Txt_The_place_X_already_exists;
extern const char *Txt_The_place_X_has_been_renamed_as_Y; extern const char *Txt_The_place_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_place_X_has_not_changed; extern const char *Txt_The_name_of_the_place_X_has_not_changed;
struct Place *Plc;
const char *ParamName = NULL; // Initialized to avoid warning const char *ParamName = NULL; // Initialized to avoid warning
const char *FieldName = NULL; // Initialized to avoid warning const char *FieldName = NULL; // Initialized to avoid warning
unsigned MaxBytes = 0; // Initialized to avoid warning unsigned MaxBytes = 0; // Initialized to avoid warning
char *CurrentPlcName = NULL; // Initialized to avoid warning char *CurrentPlcName = NULL; // Initialized to avoid warning
char NewPlcName[Plc_MAX_BYTES_PLACE_FULL_NAME + 1]; char NewPlcName[Plc_MAX_BYTES_PLACE_FULL_NAME + 1];
Plc = &Gbl.Plcs.EditingPlc;
switch (ShrtOrFullName) switch (ShrtOrFullName)
{ {
case Cns_SHRT_NAME: case Cns_SHRT_NAME:
ParamName = "ShortName"; ParamName = "ShortName";
FieldName = "ShortName"; FieldName = "ShortName";
MaxBytes = Plc_MAX_BYTES_PLACE_SHRT_NAME; MaxBytes = Plc_MAX_BYTES_PLACE_SHRT_NAME;
CurrentPlcName = Plc->ShrtName; CurrentPlcName = Plc_EditingPlc->ShrtName;
break; break;
case Cns_FULL_NAME: case Cns_FULL_NAME:
ParamName = "FullName"; ParamName = "FullName";
FieldName = "FullName"; FieldName = "FullName";
MaxBytes = Plc_MAX_BYTES_PLACE_FULL_NAME; MaxBytes = Plc_MAX_BYTES_PLACE_FULL_NAME;
CurrentPlcName = Plc->FullName; CurrentPlcName = Plc_EditingPlc->FullName;
break; break;
} }
/***** Get parameters from form *****/ /***** Get parameters from form *****/
/* Get the code of the place */ /* Get the code of the place */
if ((Plc->PlcCod = Plc_GetParamPlcCod ()) == -1L) if ((Plc_EditingPlc->PlcCod = Plc_GetParamPlcCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of place is missing."); Lay_ShowErrorAndExit ("Code of place is missing.");
/* Get the new name for the place */ /* Get the new name for the place */
Par_GetParToText (ParamName,NewPlcName,MaxBytes); Par_GetParToText (ParamName,NewPlcName,MaxBytes);
/***** Get from the database the old names of the place *****/ /***** Get from the database the old names of the place *****/
Plc_GetDataOfPlaceByCod (Plc); Plc_GetDataOfPlaceByCod (Plc_EditingPlc);
/***** Check if new name is empty *****/ /***** Check if new name is empty *****/
if (!NewPlcName[0]) if (!NewPlcName[0])
Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_leave_the_name_of_the_place_X_empty, Ale_CreateAlert (Ale_WARNING,NULL,
CurrentPlcName); Txt_You_can_not_leave_the_name_of_the_place_X_empty,
CurrentPlcName);
else else
{ {
/***** Check if old and new names are the same /***** Check if old and new names are the same
@ -690,28 +716,30 @@ static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName)
if (strcmp (CurrentPlcName,NewPlcName)) // Different names if (strcmp (CurrentPlcName,NewPlcName)) // Different names
{ {
/***** If place was in database... *****/ /***** If place was in database... *****/
if (Plc_CheckIfPlaceNameExists (ParamName,NewPlcName,Plc->PlcCod)) if (Plc_CheckIfPlaceNameExists (ParamName,NewPlcName,Plc_EditingPlc->PlcCod))
Ale_ShowAlert (Ale_WARNING,Txt_The_place_X_already_exists, Ale_CreateAlert (Ale_WARNING,NULL,
NewPlcName); Txt_The_place_X_already_exists,
NewPlcName);
else else
{ {
/* Update the table changing old name by new name */ /* Update the table changing old name by new name */
Plc_UpdatePlcNameDB (Plc->PlcCod,FieldName,NewPlcName); Plc_UpdatePlcNameDB (Plc_EditingPlc->PlcCod,FieldName,NewPlcName);
/* Write message to show the change made */ /* Write message to show the change made */
Ale_ShowAlert (Ale_SUCCESS,Txt_The_place_X_has_been_renamed_as_Y, Ale_CreateAlert (Ale_SUCCESS,NULL,
CurrentPlcName,NewPlcName); Txt_The_place_X_has_been_renamed_as_Y,
CurrentPlcName,NewPlcName);
} }
} }
else // The same name else // The same name
Ale_ShowAlert (Ale_INFO,Txt_The_name_of_the_place_X_has_not_changed, Ale_CreateAlert (Ale_INFO,NULL,
CurrentPlcName); Txt_The_name_of_the_place_X_has_not_changed,
CurrentPlcName);
} }
/***** Show the form again *****/ /***** Update place name *****/
Str_Copy (CurrentPlcName,NewPlcName, Str_Copy (CurrentPlcName,NewPlcName,
MaxBytes); MaxBytes);
Plc_EditPlaces ();
} }
/*****************************************************************************/ /*****************************************************************************/
@ -742,6 +770,22 @@ static void Plc_UpdatePlcNameDB (long PlcCod,const char *FieldName,const char *N
FieldName,NewPlcName,PlcCod); FieldName,NewPlcName,PlcCod);
} }
/*****************************************************************************/
/********** Show alerts after changing a place and continue editing **********/
/*****************************************************************************/
void Plc_ContEditAfterChgPlc (void)
{
/***** Write message to show the change made *****/
Ale_ShowAlerts (NULL);
/***** Show the form again *****/
Plc_EditPlacesInternal ();
/***** Place destructor *****/
Plc_EditingPlaceDestructor ();
}
/*****************************************************************************/ /*****************************************************************************/
/********************* Put a form to create a new place **********************/ /********************* Put a form to create a new place **********************/
/*****************************************************************************/ /*****************************************************************************/
@ -750,10 +794,6 @@ static void Plc_PutFormToCreatePlace (void)
{ {
extern const char *Txt_New_place; extern const char *Txt_New_place;
extern const char *Txt_Create_place; extern const char *Txt_Create_place;
struct Place *Plc;
/***** Place data *****/
Plc = &Gbl.Plcs.EditingPlc;
/***** Start form *****/ /***** Start form *****/
Frm_StartForm (ActNewPlc); Frm_StartForm (ActNewPlc);
@ -779,7 +819,7 @@ static void Plc_PutFormToCreatePlace (void)
" class=\"INPUT_SHORT_NAME\"" " class=\"INPUT_SHORT_NAME\""
" required=\"required\" />" " required=\"required\" />"
"</td>", "</td>",
Plc_MAX_CHARS_PLACE_SHRT_NAME,Plc->ShrtName); Plc_MAX_CHARS_PLACE_SHRT_NAME,Plc_EditingPlc->ShrtName);
/***** Place full name *****/ /***** Place full name *****/
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">" fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
@ -788,7 +828,7 @@ static void Plc_PutFormToCreatePlace (void)
" class=\"INPUT_FULL_NAME\"" " class=\"INPUT_FULL_NAME\""
" required=\"required\" />" " required=\"required\" />"
"</td>", "</td>",
Plc_MAX_CHARS_PLACE_FULL_NAME,Plc->FullName); Plc_MAX_CHARS_PLACE_FULL_NAME,Plc_EditingPlc->FullName);
/***** Number of centres *****/ /***** Number of centres *****/
fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_MIDDLE\">" fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_MIDDLE\">"
@ -842,35 +882,41 @@ static void Plc_PutHeadPlaces (void)
void Plc_RecFormNewPlace (void) void Plc_RecFormNewPlace (void)
{ {
extern const char *Txt_The_place_X_already_exists; extern const char *Txt_The_place_X_already_exists;
extern const char *Txt_Created_new_place_X;
extern const char *Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_place; extern const char *Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_place;
struct Place *Plc;
Plc = &Gbl.Plcs.EditingPlc; /***** Place constructor *****/
Plc_EditingPlaceConstructor ();
/***** Get parameters from form *****/ /***** Get parameters from form *****/
/* Get place short name */ /* Get place short name */
Par_GetParToText ("ShortName",Plc->ShrtName,Plc_MAX_BYTES_PLACE_SHRT_NAME); Par_GetParToText ("ShortName",Plc_EditingPlc->ShrtName,Plc_MAX_BYTES_PLACE_SHRT_NAME);
/* Get place full name */ /* Get place full name */
Par_GetParToText ("FullName",Plc->FullName,Plc_MAX_BYTES_PLACE_FULL_NAME); Par_GetParToText ("FullName",Plc_EditingPlc->FullName,Plc_MAX_BYTES_PLACE_FULL_NAME);
if (Plc->ShrtName[0] && Plc->FullName[0]) // If there's a place name if (Plc_EditingPlc->ShrtName[0] &&
Plc_EditingPlc->FullName[0]) // If there's a place name
{ {
/***** If name of place was in database... *****/ /***** If name of place was in database... *****/
if (Plc_CheckIfPlaceNameExists ("ShortName",Plc->ShrtName,-1L)) if (Plc_CheckIfPlaceNameExists ("ShortName",Plc_EditingPlc->ShrtName,-1L))
Ale_ShowAlert (Ale_WARNING,Txt_The_place_X_already_exists, Ale_CreateAlert (Ale_WARNING,NULL,
Plc->ShrtName); Txt_The_place_X_already_exists,
else if (Plc_CheckIfPlaceNameExists ("FullName",Plc->FullName,-1L)) Plc_EditingPlc->ShrtName);
Ale_ShowAlert (Ale_WARNING,Txt_The_place_X_already_exists, else if (Plc_CheckIfPlaceNameExists ("FullName",Plc_EditingPlc->FullName,-1L))
Plc->FullName); Ale_CreateAlert (Ale_WARNING,NULL,
Txt_The_place_X_already_exists,
Plc_EditingPlc->FullName);
else // Add new place to database else // Add new place to database
Plc_CreatePlace (Plc); {
Plc_CreatePlace (Plc_EditingPlc);
Ale_CreateAlert (Ale_SUCCESS,NULL,Txt_Created_new_place_X,
Plc_EditingPlc->FullName);
}
} }
else // If there is not a place name else // If there is not a place name
Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_place); Ale_CreateAlert (Ale_WARNING,NULL,
Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_place);
/***** Show the form again *****/
Plc_EditPlaces ();
} }
/*****************************************************************************/ /*****************************************************************************/
@ -879,8 +925,6 @@ void Plc_RecFormNewPlace (void)
static void Plc_CreatePlace (struct Place *Plc) static void Plc_CreatePlace (struct Place *Plc)
{ {
extern const char *Txt_Created_new_place_X;
/***** Create a new place *****/ /***** Create a new place *****/
DB_QueryINSERT ("can not create place", DB_QueryINSERT ("can not create place",
"INSERT INTO places" "INSERT INTO places"
@ -888,8 +932,36 @@ static void Plc_CreatePlace (struct Place *Plc)
" VALUES" " VALUES"
" (%ld,'%s','%s')", " (%ld,'%s','%s')",
Gbl.Hierarchy.Ins.InsCod,Plc->ShrtName,Plc->FullName); Gbl.Hierarchy.Ins.InsCod,Plc->ShrtName,Plc->FullName);
}
/***** Write success message *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_Created_new_place_X, /*****************************************************************************/
Plc->FullName); /************************* Place constructor/destructor **********************/
/*****************************************************************************/
static void Plc_EditingPlaceConstructor (void)
{
/***** Pointer must be NULL *****/
if (Plc_EditingPlc != NULL)
Lay_ShowErrorAndExit ("Error initializing place.");
/***** Allocate memory for place *****/
if ((Plc_EditingPlc = (struct Place *) malloc (sizeof (struct Place))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for place.");
/***** Reset place *****/
Plc_EditingPlc->PlcCod = -1L;
Plc_EditingPlc->InsCod = -1L;
Plc_EditingPlc->ShrtName[0] = '\0';
Plc_EditingPlc->FullName[0] = '\0';
Plc_EditingPlc->NumCtrs = 0;
}
static void Plc_EditingPlaceDestructor (void)
{
/***** Free memory used for place *****/
if (Plc_EditingPlc != NULL)
{
free ((void *) Plc_EditingPlc);
Plc_EditingPlc = NULL;
}
} }

View File

@ -70,6 +70,8 @@ long Plc_GetParamPlcCod (void);
void Plc_RemovePlace (void); void Plc_RemovePlace (void);
void Plc_RenamePlaceShort (void); void Plc_RenamePlaceShort (void);
void Plc_RenamePlaceFull (void); void Plc_RenamePlaceFull (void);
void Plc_ContEditAfterChgPlc (void);
void Plc_RecFormNewPlace (void); void Plc_RecFormNewPlace (void);
#endif #endif