Exemple #1
0
        /// <summary>
        /// Получить контрагента с незащищенными данными по ID
        /// </summary>
        /// <param name="id">ID</param>
        public static Counterparty GetCounterpartyByID(int id)
        {
            Counterparty counterparty = new Counterparty();

            if (counterparty.GetPublicDataByID(id))
            {
                return(counterparty);
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        /// Получить список контрагентов
        /// </summary>
        /// <param name="provider_value">значение поля IS_PROVIDER</param>
        /// <returns></returns>
        private static List <Counterparty> GetContragentList(int provider_value)
        {
            List <Counterparty> Counterparties = new List <Counterparty>();

            try
            {
                using (MySqlConnection connection = new MySqlConnection(Criptex.UnCript(ProgramSettings.ConnectionString)))
                {
                    connection.Open();

                    string sql = "SELECT * FROM `COUNTERPARTY` WHERE `COUNTERPARTY`.`IS_PROVIDER` = \'" + provider_value + "\' AND `COUNTERPARTY`.`IS_ANNULATED` = \'0\'";

                    using (MySqlCommand command = new MySqlCommand(sql, connection))
                    {
                        using (MySqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                Counterparty item = new Counterparty();

                                item.ID         = Conversion.ToInt(reader["ID"].ToString());
                                item.Code       = reader["CODE"].ToString();
                                item.Surname    = reader["SURNAME"].ToString();
                                item.Name       = reader["NAME"].ToString();
                                item.Patronymic = reader["PATRONYMIC"].ToString();
                                item.Nomination = reader["NOMINATION"].ToString();

                                item.Adress = Conversion.ToUncriptString(reader["ADRESS"].ToString());
                                item.Phone  = Conversion.ToUncriptString(reader["PHONE"].ToString());

                                item.IsProvider = Conversion.ToBool(reader["IS_PROVIDER"].ToString());

                                Counterparties.Add(item);
                            }
                        }
                    }

                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                Dialog.ErrorMessage(null, "Ошибка получения данных о контрагенте", ex.Message);
            }

            return(Counterparties);
        }