public void SaveMainRow()
        {
            if (SelectedDetailRow != null)
            {
                var valiationCollection = new List <ValidationResult>();

                var isvalid = Validator.TryValidateObject(SelectedDetailRow, new ValidationContext(SelectedDetailRow, null, null), valiationCollection, true);

                if (isvalid)
                {
                    var save = SelectedDetailRow.votglserial == 0;
                    if (AllowUpdate != true)
                    {
                        MessageBox.Show(strings.AllowAddMsg);
                        return;
                    }

                    var saveRow = new tblcurrencydailyexchange();

                    saveRow.InjectFrom(SelectedDetailRow);
                    Client.ServerConnectionsAsync(LoggedUserInfo.Ip, LoggedUserInfo.Port, LoggedUserInfo.DatabasEname);
                    Client.UpdateOrInsertTblCurrencyDailyExchangeAsync(saveRow, save, 0, LoggedUserInfo.DatabasEname);
                }
                else
                {
                    MessageBox.Show("Data Was Not Saved");
                }
            }
        }
Example #2
0
        private List <tblcurrencydailyexchange> GenerateCurrencyDailyExchange(DateTime fromDate, DateTime toDate, float rate, int currency, string company)
        {
            using (var context = new ccnewEntities(GetSqlConnectionString(company)))
            {
                var listOfRows = new List <tblcurrencydailyexchange>();
                foreach (DateTime day in EachDay(fromDate, toDate))
                {
                    var oldRow = (from e in context.tblcurrencydailyexchanges
                                  where e.DocDate == day && e.TblCurrency == currency
                                  select e).SingleOrDefault();
                    if (oldRow != null)
                    {
                        oldRow.ExchRate = rate;
                        listOfRows.Add(oldRow);
                    }
                    else
                    {
                        var newrow = new tblcurrencydailyexchange
                        {
                            DocDate     = day,
                            ExchRate    = rate,
                            TblCurrency = currency
                        };
                        listOfRows.Add(newrow);
                        context.tblcurrencydailyexchanges.AddObject(newrow);
                    }
                }

                context.SaveChanges();
                return(listOfRows);
            }
        }
Example #3
0
        private int DeleteTblCurrencyDailyExchange(tblcurrencydailyexchange row, string company)
        {
            using (var context = new ccnewEntities(GetSqlConnectionString(company)))
            {
                var oldRow = (from e in context.tblcurrencydailyexchanges
                              where e.votglserial == row.votglserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.votglserial);
        }
Example #4
0
 private tblcurrencydailyexchange UpdateOrInsertTblCurrencyDailyExchange(tblcurrencydailyexchange newRow, bool save, int index, out int outindex, string company)
 {
     outindex = index;
     using (var context = new ccnewEntities(GetSqlConnectionString(company)))
     {
         if (save)
         {
             context.tblcurrencydailyexchanges.AddObject(newRow);
         }
         else
         {
             var oldRow = (from e in context.tblcurrencydailyexchanges
                           where e.votglserial == newRow.votglserial
                           select e).SingleOrDefault();
             if (oldRow != null)
             {
                 GenericUpdate(oldRow, newRow, context);
             }
         }
         context.SaveChanges();
         return(newRow);
     }
 }