Beispiel #1
0
        // Добавление новых пар в список по массив пр. имен
        internal void AddByManufactNames(string[] manufaсtNames)
        {
            var names = ManufactAgreeName.GetNamesByManufactNames(manufaсtNames);

            _names.AddRange(names);

            BindWithView();
        }
Beispiel #2
0
        // Получить перечисление имен из массива manufactNames.
        public static IEnumerable <ManufactAgreeName> GetNamesByManufactNames(string[] manufactNames)
        {
            DataTable table = new DataTable();

            using (SqlCommand command = new SqlCommand())
                using (SqlDataAdapter adapter = new SqlDataAdapter(command))
                {
                    command.Connection = dbinit.db;

                    command.CommandText = @"
SELECT
    mn.fo_manufactname AS manufactname
    , mn.fo_agreename AS agreename
    , o.idorder
    , do.name AS docopername
    , ISNULL(o.addstr4, '') AS ConstrComm
FROM fo_manufact_names AS mn
INNER JOIN orders AS o ON mn.fo_agreename = o.agreename
                        AND mn.fo_iddocoper = o.iddocoper
                        AND mn.fo_notrelevant IS NULL
                        AND o.deleted IS NULL
INNER JOIN docoper AS do ON o.iddocoper = do.iddocoper                        
WHERE mn.fo_manufactname IN(SELECT item FROM dbo.fnSplit(@manufactnames,','))";

                    command.Parameters.AddWithValue("@manufactnames", string.Join(",", manufactNames));

                    adapter.Fill(table);

                    string idorder = string.Join(",", table.AsEnumerable().Select(r => r.Field <int>("idorder").ToString()).ToArray());

                    foreach (DataRow row in table.Rows)
                    {
                        ManufactAgreeName name = new ManufactAgreeName();
                        name._manufactName = (string)row["manufactname"];
                        name._agreeName    = (string)row["agreename"];
                        name.IdOrder       = (int)row["idorder"];
                        name.DocOperName   = (string)row["docopername"];
                        name.ConstrComm    = (string)row["ConstrComm"];

                        yield return(name);
                    }
                }
        }