public static void InputTarifs(int counterID, float tarif1Current, float tarif2Current, float tarif3Current,
                                       float tarif4Current, float tarif1Past, float tarif2Past, float tarif3Past, float tarif4Past)
        {
            var query = from f in db.CounterStatements
                        where f.CounterID == counterID &&
                        ((f.Year == DateTime.Now.Year && f.Month == DateTime.Now.Month) ||
                         (f.Year == DateTime.Now.AddMonths(-1).Year&& f.Month == DateTime.Now.AddMonths(-1).Month))
                        select f;

            if (query.Any())
            {
                db.CounterStatements.DeleteAllOnSubmit(query);
            }

            CounterStatement statPast = new CounterStatement
            {
                CounterID = counterID,
                Year      = DateTime.Now.AddMonths(-1).Year,
                Month     = DateTime.Now.AddMonths(-1).Month,
                Tarif1    = (decimal)tarif1Past,
                Tarif2    = (decimal)tarif2Past,
                Tarif3    = (decimal)tarif3Past,
                Tarif4    = (decimal)tarif4Past
            };

            db.CounterStatements.InsertOnSubmit(statPast);

            CounterStatement statCurrent = new CounterStatement
            {
                CounterID = counterID,
                Year      = DateTime.Now.Year,
                Month     = DateTime.Now.Month,
                Tarif1    = (decimal)tarif1Current,
                Tarif2    = (decimal)tarif2Current,
                Tarif3    = (decimal)tarif3Current,
                Tarif4    = (decimal)tarif4Current
            };

            db.CounterStatements.InsertOnSubmit(statCurrent);

            db.SubmitChanges();
        }
Esempio n. 2
0
 partial void DeleteCounterStatement(CounterStatement instance);
Esempio n. 3
0
 private void detach_CounterStatements(CounterStatement entity)
 {
     this.SendPropertyChanging();
     entity.Counter = null;
 }
Esempio n. 4
0
 partial void UpdateCounterStatement(CounterStatement instance);
Esempio n. 5
0
 private void attach_CounterStatements(CounterStatement entity)
 {
     this.SendPropertyChanging();
     entity.Counter = this;
 }
Esempio n. 6
0
 partial void InsertCounterStatement(CounterStatement instance);