/// <summary> /// Получение данных текущего лица по IpPerson /// </summary> private void InitPerson() { if (PersonId <= 0) { throw new Exception(string.Format("Неправильно переданы параметры! Id = {0}", PersonId)); } PersonObj = new PersonOld(PersonId.ToString()); if (PersonObj == null && PersonObj.Unavailable) { throw new Exception(string.Format("Лицо с кодом #{0} не найдено или не доступно!", PersonId)); } var crd = PersonObj.GetCard(DateTime.Today); if (crd == null) { throw new Exception( string.Format("У лица {0} нет действующих реквизитов на текущую дату!", PersonObj.Name)); } PersonName = crd.NameRus; PersonNameEn = crd.NameLat; PersonKpp = crd.КПП; PersonAddress = crd.АдресЮридический; PersonAddressEn = crd.АдресЮридическийЛат; }
//used on Sqlite main convertPersonAndPersonSessionTo77() public ArrayList SelectAllPersons() { dbcmd.CommandText = "SELECT * FROM " + Constants.PersonOldTable + " ORDER BY uniqueID"; LogB.SQL(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ArrayList myArray = new ArrayList(1); while (reader.Read()) { PersonOld p = new PersonOld( Convert.ToInt32(reader[0].ToString()), //uniqueID reader[1].ToString(), //name reader[2].ToString(), //sex UtilDate.FromSql(reader[3].ToString()), //dateBorn Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString())), //height Convert.ToDouble(Util.ChangeDecimalSeparator(reader[5].ToString())), //weight Convert.ToInt32(reader[6].ToString()), //sportID Convert.ToInt32(reader[7].ToString()), //speciallityID Convert.ToInt32(reader[8].ToString()), //practice reader[9].ToString(), //description Convert.ToInt32(reader[10].ToString()), //race Convert.ToInt32(reader[11].ToString()), //countryID Convert.ToInt32(reader[12].ToString()) //serverUniqueID ); myArray.Add(p); } reader.Close(); return(myArray); }
/// <summary> /// /// </summary> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <param name="birthDate"></param> /// <returns></returns> public PersonOld CreatePerson(String firstName, String lastName, DateTime birthDate) { PersonOld p = new PersonOld(firstName, lastName, birthDate); personMap.Add(p.ID, p); return(p); }
/// <summary> /// Получение информации о лице по индетификатору /// </summary> /// <param name="pId">КодЛица</param> /// <param name="lang">На каком языке нужны данные</param> /// <param name="fullName">Возвращает краткое название лица</param> /// <param name="address">Возвращает адрес лица</param> /// <param name="kpp">Возвращает КПП</param> /// <returns>Новый объект лица</returns> private PersonOld GetPerson(int?pId, string lang, ref string fullName, ref string address, ref string kpp) { if (!pId.HasValue) { return(null); } var p = new PersonOld(pId.Value.ToString()); if (p == null || p.Unavailable) { return(null); } if (p == null && p.Unavailable) { throw new Exception(string.Format("Лицо с кодом #{0} не найдено или не доступно!", pId.Value)); } var crd = p.GetCard(DateTime.Today); if (crd == null) { throw new Exception( string.Format("У лица {0} нет действующих реквизитов на текущую дату!", p.Name)); } kpp = crd.КПП; if (lang == "en") { fullName = crd.NameLat; address = crd.АдресЮридическийЛат; } else { fullName = crd.NameRus; address = crd.АдресЮридический; } return(p); }
//used on Sqlite main convertPersonAndPersonSessionTo77() public ArrayList SelectAllPersons() { dbcmd.CommandText = "SELECT * FROM " + Constants.PersonOldTable + " ORDER BY uniqueID"; Log.WriteLine(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ArrayList myArray = new ArrayList(1); while(reader.Read()) { PersonOld p = new PersonOld( Convert.ToInt32(reader[0].ToString()), //uniqueID reader[1].ToString(), //name reader[2].ToString(), //sex UtilDate.FromSql(reader[3].ToString()),//dateBorn Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString())), //height Convert.ToDouble(Util.ChangeDecimalSeparator(reader[5].ToString())), //weight Convert.ToInt32(reader[6].ToString()), //sportID Convert.ToInt32(reader[7].ToString()), //speciallityID Convert.ToInt32(reader[8].ToString()), //practice reader[9].ToString(), //description Convert.ToInt32(reader[10].ToString()), //race Convert.ToInt32(reader[11].ToString()), //countryID Convert.ToInt32(reader[12].ToString()) //serverUniqueID ); myArray.Add(p); } reader.Close(); return myArray; }
/// <summary> /// Обработчик события изменения расчетного счета лица /// </summary> /// <param name="sender">Объект источник события</param> /// <param name="args">Параметры события</param> private void Store_Changed(object sender, ProperyChangedEventArgs args) { Item s = new Item(); if (null != _store.ValueObject) { s = (Item)_store.ValueObject; } //ValueObject не коррелирует с Value, оно устанавливается только при выборе значения из списка if (string.IsNullOrEmpty(_store.Value) || null == s.Value) { _page.Hide(_prefix + "StoreInfoPanel"); _store_info.Visible = false; //_store_info.Value = string.Empty; _store_info.BindDocField.Value = string.Empty; _current_store = null; } else { //_current_store = new Store(_store.Value); _current_store = _page.GetObjectById(typeof(Store), _store.Value) as Store; _page.Display(_prefix + "StoreInfoPanel"); _store_info.Visible = true; //_store_info.Value = s.Value.ToString(); PersonOld p = _page.GetObjectById(typeof(PersonOld), _current_store.KeeperId.ToString()) as PersonOld; if (p != null && p.Id != "") { //var card = p.GetCard(_page.Doc.Date == DateTime.MinValue ? DateTime.Today : _page.Doc.Date); var card = _page.GetCardById(p, _page.Doc.Date == DateTime.MinValue ? DateTime.Today : _page.Doc.Date); if (card != null && card.NameRus.Length == 0 && card.NameLat.Length == 0) { return; } var crdName = ""; if (card != null) { crdName = " в " + (card.NameRus.Length > 0 ? card.NameRus : card.NameLat); } _store_info.BindDocField.Value = "№" + s.Value + crdName; if (_current_store.Subsidiary.Length > 0) { _store_info.BindDocField.Value += " в " + _current_store.Subsidiary; } if (p.BIK.Length > 0 && ((Kesco.Lib.Entities.Documents.EF.Trade.TTN)_page.Doc).CurrencyField.ValueString == ((int)Currency.Code.RUR).ToString()) { _store_info.BindDocField.Value += ", БИК " + p.BIK; } if (p.SWIFT.Length > 0 && ((Kesco.Lib.Entities.Documents.EF.Trade.TTN)_page.Doc).CurrencyField.ValueString.Length > 0 && !((Kesco.Lib.Entities.Documents.EF.Trade.TTN)_page.Doc).CurrencyField.ValueString.Equals(((int)Currency.Code.RUR).ToString())) { _store_info.BindDocField.Value += ", SWIFT " + p.SWIFT; } if (p.CorrAccount.Length > 0) { _store_info.BindDocField.Value += ", КС " + p.CorrAccount; } } if (string.IsNullOrEmpty(_person.Value)) { //_person.ValueInt = _current_store.ManagerId; _person.BindDocField.Value = _current_store.ManagerId.ToString(); BindFieldsByPerson(); } _store_info.RenderNtf(); } UpdateBindedPanel(sender, args); }
public void BindFieldsByPerson() { UpdateFieldVisibility(); if (!string.IsNullOrEmpty(_person.Value)) { PersonOld p = _page.GetObjectById(typeof(PersonOld), _person.Value) as PersonOld; if (p.Unavailable) { _current_code = string.Empty; } else { _current_code = p.OKPO; if (string.IsNullOrEmpty(_store.Value)) { //_page.Store_BeforeSearch(_store, _person.Value); if (_store.TryFindSingleValue()) { _store.BindDocField.Value = _store.Value; Store_Changed(null, null); _store.RenderNtf(); } else { if (_prefix == "Go") { var sqlParamsSt = new Dictionary <string, object> { { "@ДатаДокумента", ((Kesco.Lib.Entities.Documents.EF.Trade.TTN)_page.Doc).Date }, { "@КодПоставщика", _person.Value }, { "@КодВалюты", ((Kesco.Lib.Entities.Documents.EF.Trade.TTN)_page.Doc).CurrencyField.Value } }; var st = DBManager.ExecuteScalar(SQLQueries.SELECT_ПоследнийСчетПоставщикаВТТН, CommandType.Text, Config.DS_document, sqlParamsSt); if (st != DBNull.Value) { _store.BindDocField.Value = st.ToString(); Store_Changed(null, null); _store.RenderNtf(); } } } } var sqlParams = new Dictionary <string, object> { { "@КодЛица", _person.BindDocField.Value } }; var dt = DBManager.GetData(SQLQueries.SELECT_КонтактыЛицаExt, Config.DS_person, CommandType.Text, sqlParams); if (dt != null && dt.Rows.Count == 1) { _address.Value = dt.Rows[0]["Контакт"].ToString(); } if (null != _address.BindDocField) { _address.BindDocField.Value = _address.Value; } //var card = p.GetCard(_page.Doc.Date == DateTime.MinValue ? DateTime.Today : _page.Doc.Date); var card = _page.GetCardById(p, _page.Doc.Date == DateTime.MinValue ? DateTime.Today : _page.Doc.Date); /* * if (_prefix == "Shipper" || _prefix == "Payer") * { * if (string.IsNullOrEmpty(_address.Value)) * { * if (card != null) * { * _address.Value = card.АдресЮридический.Length == 0 * ? card.АдресЮридическийЛат * : card.АдресЮридический; * } * * if (null != _address.BindDocField) * _address.BindDocField.Value = _address.Value; * } * } */ // Название поставщика/плательщика реквизиты ГО/ГП if (card != null) { _info.BindDocField.Value = card.NameRus.Length > 0 ? card.NameRus : card.NameLat; } if (_prefix == "Go" || _prefix == "Gp") { V4Control[] ctrls = { _transport_node, _address, _notes }; var addInfo = GetHtmlPersonDescription(ctrls, ", "); _info.BindDocField.Value += (_info.Value.Length > 0 && addInfo.Length > 0 ? ", " : "") + addInfo; } } } _code.BindDocField.Value = _current_code; UpdatePersonDeps(); }
public void RemovePerson(PersonOld p) { personMap.Remove(p.ID); }
/* * The problem of this method is that uses class constructors: person, jump, ... * and if the sqlite version is updated from a really old version * maybe the object has to be converted from really older class to old, and then to new class (two conversions) * and this can have problems in the class construction * The best seem to have a boolean that indicates if certain conversion has done before * (see bool runAndRunIntervalInitialSpeedAdded) */ protected internal static void convertTables(Sqlite sqliteObject, string tableName, int columnsBefore, ArrayList columnsToAdd, bool putDescriptionInMiddle) { conversionSubRate = 1; conversionSubRateTotal = -1; //unknown yet //2st create convert temp table sqliteObject.createTable(Constants.ConvertTempTable); //2nd copy all data from desired table to temp table (in event tables, adding the simulated column) ArrayList myArray = new ArrayList(2); dbcmd.CommandText = "SELECT * " + "FROM " + tableName + " ORDER BY uniqueID"; LogB.SQL(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); while(reader.Read()) { string [] myReaderStr = new String[columnsBefore + columnsToAdd.Count]; int i; for (i=0; i < columnsBefore; i ++) myReaderStr[i] = reader[i].ToString(); foreach (string myStr in columnsToAdd) myReaderStr[i++] = myStr; if (putDescriptionInMiddle) { //string [] strFull = changePos.Split(new char[] {':'}); //int row1 = Convert.ToInt32(strFull[0]); //int row2 = Convert.ToInt32(strFull[1]); string desc = myReaderStr[6]; myReaderStr[6] = myReaderStr[7]; myReaderStr[7] = myReaderStr[8]; myReaderStr[8] = myReaderStr[9]; myReaderStr[9] = desc; } if(tableName == Constants.PersonOldTable) { PersonOld myPerson = new PersonOld(myReaderStr); myArray.Add(myPerson); } else if(tableName == Constants.SessionTable) { Session mySession = new Session(myReaderStr); myArray.Add(mySession); } else if(tableName == Constants.RunIntervalTypeTable) { RunType myType = new RunType(myReaderStr, true); //interval myArray.Add(myType); } else if(tableName == Constants.PersonSessionOldWeightTable) { PersonSessionOld myPS = new PersonSessionOld(myReaderStr); myArray.Add(myPS); } else { Event myEvent = new Event(); switch (tableName) { case Constants.JumpTable: myEvent = new Jump(myReaderStr); break; case Constants.JumpRjTable: myEvent = new JumpRj(myReaderStr); break; case Constants.RunTable: myEvent = new Run(myReaderStr); break; case Constants.RunIntervalTable: myEvent = new RunInterval(myReaderStr); break; case Constants.ReactionTimeTable: myEvent = new ReactionTime(myReaderStr); break; case Constants.PulseTable: myEvent = new Pulse(myReaderStr); break; } myArray.Add(myEvent); } } reader.Close(); LogB.SQL("1" + tableName); conversionSubRateTotal = myArray.Count * 2; if(tableName == Constants.PersonOldTable) { foreach (PersonOld myPerson in myArray) { myPerson.InsertAtDB(true, Constants.ConvertTempTable); conversionSubRate ++; } } else if(tableName == Constants.SessionTable) { foreach (Session mySession in myArray) { mySession.InsertAtDB(true, Constants.ConvertTempTable); conversionSubRate ++; } } else if(tableName == Constants.RunIntervalTypeTable) { foreach (RunType type in myArray) { type.InsertAtDB(true, Constants.ConvertTempTable, true); //last true is for interval conversionSubRate ++; } } else if(tableName == Constants.PersonSessionOldWeightTable) { foreach (PersonSessionOld ps in myArray) { ps.InsertAtDB(true, Constants.ConvertTempTable); conversionSubRate ++; } } else { foreach (Event myEvent in myArray) { myEvent.InsertAtDB(true, Constants.ConvertTempTable); conversionSubRate ++; } } LogB.SQL("2" + tableName); //3rd drop desired table Sqlite.dropTable(tableName); LogB.SQL("3" + tableName); //4d create desired table (now with new columns) sqliteObject.createTable(tableName); LogB.SQL("4" + tableName); //5th insert data in desired table if(tableName == Constants.PersonOldTable) { foreach (PersonOld myPerson in myArray) { myPerson.InsertAtDB(true, tableName); conversionSubRate ++; } } else if(tableName == Constants.SessionTable) { foreach (Session mySession in myArray) { mySession.InsertAtDB(true, tableName); conversionSubRate ++; } } else if(tableName == Constants.RunIntervalTypeTable) { foreach (RunType type in myArray) { type.InsertAtDB(true, tableName, true); //last true is for interval conversionSubRate ++; } } else if(tableName == Constants.PersonSessionOldWeightTable) { foreach (PersonSessionOld ps in myArray) { ps.InsertAtDB(true, tableName); conversionSubRate ++; } } else { foreach (Event myEvent in myArray) { myEvent.InsertAtDB(true, tableName); conversionSubRate ++; } } LogB.SQL("5" + tableName); //6th drop temp table Sqlite.dropTable(Constants.ConvertTempTable); }