Patch level : 12.0 nopatch
Files correlati : ps Commento: Modifiche al salvataggio in formato dBase.
This commit is contained in:
		
							parent
							
								
									ef311955ee
								
							
						
					
					
						commit
						0d3ca7deb7
					
				| @ -1699,6 +1699,7 @@ void TReport_select::parse_output(TScanner& scanner) | ||||
| KEY TReport_select::run() | ||||
| { | ||||
|   TFilename path = field().get(); | ||||
| 
 | ||||
|   if (select_custom_file(path, "rep", _classe)) | ||||
|   { | ||||
| 		path = path.name(); | ||||
| @ -1732,18 +1733,21 @@ bool TReport_select::check(CheckTime ct) | ||||
| 
 | ||||
| 			if (repname.blank() && ct == FINAL_CHECK) | ||||
| 				return field().error_box(TR("Il report deve essere specificato")); | ||||
| 			bool found = false; | ||||
| 			FOR_EACH_ARRAY_ITEM(reps, r, obj) | ||||
| 			if (_classe.full()) | ||||
| 			{ | ||||
| 				TToken_string * row = (TToken_string *)obj; | ||||
| 				 | ||||
| 				found = (repname == row->get(0)); | ||||
| 				if (found) | ||||
| 					break; | ||||
| 			} | ||||
| 				bool found = false; | ||||
| 
 | ||||
| 			if (!found) | ||||
| 				return field().error_box(FR("Il report %s non è compatibile"), (const char *)repname); | ||||
| 				FOR_EACH_ARRAY_ITEM(reps, r, obj) | ||||
| 				{ | ||||
| 					TToken_string * row = (TToken_string *)obj; | ||||
| 
 | ||||
| 					found = (repname == row->get(0)); | ||||
| 					if (found) | ||||
| 						break; | ||||
| 				} | ||||
| 				if (!found) | ||||
| 					return field().error_box(FR("Il report %s non è compatibile"), (const char *)repname); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|   if (field().roman())  // Must exist
 | ||||
|  | ||||
| @ -18,6 +18,7 @@ class TConfig; | ||||
| #define DESCDIR "recdesc" | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| // @doc EXTERNAL
 | ||||
| 
 | ||||
| // @class TDir | Classe per la gestione del file "dir.gen"
 | ||||
|  | ||||
| @ -1,12 +1,12 @@ | ||||
| BUTTON DLG_PRINT 2 2 | ||||
| BEGIN | ||||
|   PROMPT 1 1 "Stampa" | ||||
|   PROMPT 1 1 "~Stampa" | ||||
|   PICTURE TOOL_PRINT | ||||
| END | ||||
| 
 | ||||
| BUTTON DLG_SETPRINT 2 2 | ||||
| BEGIN | ||||
|   PROMPT 2 1 "Imposta" | ||||
|   PROMPT 2 1 "~Imposta" | ||||
|   PICTURE TOOL_SETPRINT | ||||
| END | ||||
| 
 | ||||
|  | ||||
| @ -335,7 +335,7 @@ bool TProgress_monitor::set_status(long n) | ||||
|     _start = clock(); | ||||
| 
 | ||||
|   // Se è passato un secondo allora crea la progress dialog
 | ||||
|   if (_pd == NULL_WIN && n > 0 && (clock() - _start) >= CLOCKS_PER_SEC) | ||||
|   if (_pd == NULL_WIN && n > 0 && (clock() - _start) >= CLOCKS_PER_SEC && !is_batch()) | ||||
|   { | ||||
|     _pd = xvt_dm_progress_create(_pm_parent, main_app().title(), _total, _cancellable); | ||||
|     if (_txt.full()) | ||||
|  | ||||
| @ -391,48 +391,106 @@ bool TRecordset::save_as_dbf(const char* table, int mode) | ||||
|     else | ||||
|       pisam = new TFast_isamfile(logicnum); | ||||
|   } | ||||
| 	else | ||||
| 	{ | ||||
| 		const TString & query = query_text(); | ||||
| 		int pos = query.find("FROM"); | ||||
| 		TArray records; | ||||
| 
 | ||||
| 		if (pos > 0) | ||||
| 		{ | ||||
| 			TToken_string tables(query.mid(pos + 5), ','); | ||||
| 			const int len = tables.len(); | ||||
| 			int stop = 0; | ||||
| 			 | ||||
| 			tables.upper(); | ||||
| 			while (stop < len && ((tables[stop] >= 'A') && (tables[stop] <= 'Z') || tables[stop] == ',')) | ||||
| 				stop++; | ||||
| 			if (stop > 0) | ||||
| 				tables.cut(stop); | ||||
| 			FOR_EACH_STR_TOKEN(tables, table) | ||||
| 			{ | ||||
| 				int logic = table2logic(table); | ||||
| 
 | ||||
| 				if (logic > LF_USER) | ||||
| 					records.add(new TTrec(logic)); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		TTrec def(LF_EXTERNAL); | ||||
| 		TToken_string keydef("", '+'); | ||||
| 		int keylen = 0; | ||||
| 
 | ||||
| 		for (unsigned int j = 0; j < columns(); j++) | ||||
| 		{ | ||||
| 			TRecordset_column_info & c = (TRecordset_column_info &)column_info(j); | ||||
| 			const TString& name = c._name; | ||||
| 
 | ||||
| 			FOR_EACH_ARRAY_ITEM(records, r, obj) | ||||
| 			{ | ||||
| 				TTrec & rec = (TTrec &)*obj; | ||||
| 				const int nfield = rec.field(name); | ||||
| 
 | ||||
| 				if (nfield >= 0) | ||||
| 				{ | ||||
| 					TToken_string defstr(rec.fielddef(nfield)); | ||||
| 					int dec = defstr.get_int(3); | ||||
| 
 | ||||
| 					c._type = (TFieldtypes)defstr.get_int(1); | ||||
| 					c._width = defstr.get_int(2); | ||||
| 
 | ||||
| 					if (c._type == _realfld) | ||||
| 						c._width += dec; | ||||
| 					def.add_fielddef(c._name, c._type, c._width, dec); | ||||
| 					if (keylen + c._width < 80) | ||||
| 					{ | ||||
| 						keydef.add(c._name); | ||||
| 						keylen += c._width; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		def.add_keydef(keydef, true); | ||||
| 		pisam = new TExternisamfile(table, def); | ||||
| 	} | ||||
|   if (pisam == nullptr) | ||||
|     return error_box("Impossibile creare il file %s", table); | ||||
| 
 | ||||
|   TBaseisamfile& isam = *pisam; | ||||
|   TRectype& rec = isam.curr(); | ||||
| 
 | ||||
|   TString_array names; | ||||
|   int valid = 0; | ||||
|   for (unsigned int j = 0; j < columns(); j++) | ||||
|   { | ||||
|     const TVariant& var = get(j); | ||||
|     const TString& name = column_info(j)._name; | ||||
|     if (rec.exist(name)) | ||||
|     { | ||||
|       names.add(name); | ||||
|       valid++; | ||||
|     } | ||||
|     else | ||||
|       names.add(EMPTY_STRING); | ||||
|   } | ||||
| 
 | ||||
|   TProgress_monitor pi(items(), TR("Esportazione in corso..."), true); | ||||
|   bool ok = true; | ||||
| 
 | ||||
|   for (bool go = move_first(); go; go = move_next()) | ||||
|   { | ||||
| 		TToken_string recval("", ','); | ||||
| 
 | ||||
|     if (!pi.add_status()) | ||||
|       break; | ||||
|     rec.zero(); | ||||
|     FOR_EACH_ARRAY_ROW(names, j, name) if (name->not_empty()) | ||||
|       rec.put(*name, get(j).as_string()); | ||||
|     isam.zero(); | ||||
| 		for (unsigned int j = 0; j < columns(); j++) | ||||
| 		{ | ||||
| 			const TString& name = column_info(j)._name; | ||||
| 
 | ||||
| 			isam.put(name, get(j).as_string()); | ||||
| 			recval.add(get(j).as_string()); | ||||
| 		} | ||||
| 
 | ||||
|     int err = NOERR; | ||||
|     bool to_be_written = true; | ||||
| 
 | ||||
|     // Devo solo aggiornare parte dei campi?
 | ||||
|     if ((mode & 0x2) && valid < rec.items()) | ||||
|     if (mode & 0x2) | ||||
|     { | ||||
|       err = isam.read(_isequal, _lock); | ||||
|       if (err != NOERR) | ||||
|         rec.zero(); | ||||
|       FOR_EACH_ARRAY_ROW(names, j, name) if (name->not_empty()) | ||||
|         rec.put(*name, get(j).as_string()); | ||||
|         isam.zero(); | ||||
| 			for (unsigned int j = 0; j < columns(); j++) | ||||
| 			{ | ||||
| 				const TString& name = column_info(j)._name; | ||||
| 
 | ||||
| 				isam.put(name, get(j).as_string()); | ||||
| 			} | ||||
|       if (err == NOERR) | ||||
|         to_be_written = isam.rewrite() != NOERR; | ||||
|     } | ||||
| @ -444,11 +502,10 @@ bool TRecordset::save_as_dbf(const char* table, int mode) | ||||
|     } | ||||
|     if (err != NOERR) | ||||
|     { | ||||
|       ok = error_box(FR("Errore %d durante la scrittura del record %s"), err, rec.build_key()); | ||||
|       ok = error_box(FR("Errore %d durante la scrittura del record %s"), err, recval); | ||||
|       break; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   return ok; | ||||
| } | ||||
| 
 | ||||
| @ -717,9 +774,11 @@ void TRecordset::parsed_text(TString& sql) const | ||||
|     { | ||||
|       TVariant var = get_var(*name); | ||||
|       int pos = sql.find(*name); | ||||
| 
 | ||||
|       for ( ; pos > 0; pos = sql.find(*name, pos+1)) | ||||
|       { | ||||
|         const TString& after = sql.mid(pos+name->len()); | ||||
| 
 | ||||
|         sql.cut(pos); | ||||
|          | ||||
|         if (var.type() == _datefld) | ||||
| @ -1481,6 +1540,7 @@ TCursor_parser::TCursor_parser(istream& instr, TArray& col) | ||||
|     { | ||||
|       TRecordset_column_info* info = (TRecordset_column_info*)obj; | ||||
|       const int arrow = info->_name.find('.'); | ||||
| 
 | ||||
|       if (arrow > 0) | ||||
|         info->_name = info->_name.mid(arrow+1); | ||||
|     } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user