public void UpdateTable(string tablename, CorreggiDateListiniDS ds)
        {
            string query = string.Format(CultureInfo.InvariantCulture, "SELECT * FROM {0}", tablename);

            using (DbDataAdapter a = BuildDataAdapter(query))
            {
                try
                {
                    a.ContinueUpdateOnError = false;
                    DataTable        dt  = ds.Tables[tablename];
                    DbCommandBuilder cmd = BuildCommandBuilder(a);
                    a.UpdateCommand = cmd.GetUpdateCommand();
                    a.DeleteCommand = cmd.GetDeleteCommand();
                    a.InsertCommand = cmd.GetInsertCommand();
                    a.Update(dt);
                }
                catch (DBConcurrencyException ex)
                {
                }
                catch
                {
                    throw;
                }
            }
        }
        public void FillUSR_LIS_ACQ_COR(CorreggiDateListiniDS ds)
        {
            string select = @"select * from USR_LIS_ACQ_COR";

            using (DbDataAdapter da = BuildDataAdapter(select))
            {
                da.Fill(ds.USR_LIS_ACQ_COR);
            }
        }
Пример #3
0
        private static void CorreggiListini(CorreggiDateListiniDS ds, string Azienda)
        {
            List <string> articoliMP = ds.USR_LIS_ACQ_COR.Where(x => !x.IsIDMAGAZZNull() && x.AZIENDA == Azienda).Select(x => x.IDMAGAZZ).Distinct().ToList();
            int           indice     = 1;

            foreach (string idmagazz in articoliMP)
            {
                Console.WriteLine(string.Format("{2} {0} di {1}", indice, articoliMP.Count, Azienda));
                indice++;

                List <string> clifo = ds.USR_LIS_ACQ_COR.Where(x => !x.IsCODICECLIFONull() && !x.IsIDMAGAZZNull() && x.IDMAGAZZ == idmagazz && x.AZIENDA == Azienda).Select(x => x.CODICECLIFO).Distinct().ToList();

                List <CorreggiDateListiniDS.USR_LIS_ACQ_CORRow> listini = ds.USR_LIS_ACQ_COR.Where(x => x.IsCODICECLIFONull() && x.AZIENDA == Azienda && !x.IsIDMAGAZZNull() && x.IDMAGAZZ == idmagazz).OrderByDescending(x => x.VALIDITA).ToList();

                if (listini.Count > 1)
                {
                    DateTime dataInizioValidita = new DateTime(2000, 1, 1);
                    foreach (CorreggiDateListiniDS.USR_LIS_ACQ_CORRow listino in listini)
                    {
                        if (!(dataInizioValidita.Year == 2000 && dataInizioValidita.Month == 1 && dataInizioValidita.Day == 1))
                        {
                            listino.FINEVALIDITA = dataInizioValidita;
                        }
                        dataInizioValidita = listino.VALIDITA;
                    }
                }

                foreach (string cl in clifo)
                {
                    listini = ds.USR_LIS_ACQ_COR.Where(x => !x.IsCODICECLIFONull() && x.CODICECLIFO == cl && x.AZIENDA == Azienda && !x.IsIDMAGAZZNull() && x.IDMAGAZZ == idmagazz).OrderByDescending(x => x.VALIDITA).ToList();
                    if (listini.Count <= 1)
                    {
                        continue;
                    }

                    DateTime dataInizioValidita = new DateTime(2000, 1, 1);
                    foreach (CorreggiDateListiniDS.USR_LIS_ACQ_CORRow listino in listini)
                    {
                        if (!(dataInizioValidita.Year == 2000 && dataInizioValidita.Month == 1 && dataInizioValidita.Day == 1))
                        {
                            listino.FINEVALIDITA = dataInizioValidita;
                        }
                        dataInizioValidita = listino.VALIDITA;
                    }
                }
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            CorreggiDateListiniDS ds = new CorreggiDateListiniDS();

            using (CorreggiDateListiniBusiness bCorreggi = new CorreggiDateListiniBusiness())
            {
                bCorreggi.FillUSR_LIS_ACQ_COR(ds);
            }

            CorreggiListini(ds, "MP");
            CorreggiListini(ds, "TF");


            Console.WriteLine("***** UPDATE IN CORSO ****");
            using (CorreggiDateListiniBusiness bCorreggi = new CorreggiDateListiniBusiness())
            {
                bCorreggi.UpdateTable(ds.USR_LIS_ACQ_COR.TableName, ds);
            }
        }
        public void UpdateTable(string tablename, CorreggiDateListiniDS ds)
        {
            CorreggiDateListiniAdapter a = new CorreggiDateListiniAdapter(DbConnection, DbTransaction);

            a.UpdateTable(tablename, ds);
        }
        public void FillUSR_LIS_ACQ_COR(CorreggiDateListiniDS ds)
        {
            CorreggiDateListiniAdapter a = new CorreggiDateListiniAdapter(DbConnection, DbTransaction);

            a.FillUSR_LIS_ACQ_COR(ds);
        }