Exemplo n.º 1
0
        public void SaveOldDetailRow(TblPositionRouteViewModel oldRow)
        {
            if (!Loading)
            {
                if (oldRow != null)
                {
                    var valiationCollection = new List <ValidationResult>();

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

                    if (isvalid)
                    {
                        var save = oldRow.Iserial == 0;
                        if (AllowUpdate != true && !save)
                        {
                            MessageBox.Show(strings.AllowUpdateMsg);
                            return;
                        }
                        var saveRow = new TblPositionRoute();
                        saveRow.InjectFrom(oldRow);

                        if (SelectedMainRow != null && SelectedMainRow.DetailsList != null)
                        {
                            Loading = true;

                            Glclient.UpdateOrInsertTblPositionRouteAsync(saveRow, save, SelectedMainRow.DetailsList.IndexOf(oldRow),
                                                                         LoggedUserInfo.DatabasEname);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void SaveDetailRow()
        {
            if (!Loading)
            {
                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.Iserial == 0;
                        if (SelectedDetailRow.TblPositionRouteHeader == 0)
                        {
                            SelectedDetailRow.TblPositionRouteHeader = SelectedMainRow.Iserial;
                        }
                        if (AllowUpdate != true && !save)
                        {
                            MessageBox.Show(strings.AllowUpdateMsg);
                            return;
                        }

                        var rowToSave = new TblPositionRoute();
                        rowToSave.InjectFrom(SelectedDetailRow);
                        Loading = true;
                        Glclient.UpdateOrInsertTblPositionRouteAsync(rowToSave, save,
                                                                     SelectedMainRow.DetailsList.IndexOf(SelectedDetailRow), LoggedUserInfo.DatabasEname);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private int DeleteTblPositionRoute(TblPositionRoute row, int index, string company)
        {
            using (var entity = new ccnewEntities(GetSqlConnectionString(company)))
            {
                var query = (from e in entity.TblPositionRoutes
                             where e.Iserial == row.Iserial
                             select e).SingleOrDefault();
                if (query != null)
                {
                    entity.DeleteObject(query);
                }

                entity.SaveChanges();
            }
            return(row.Iserial);
        }
Exemplo n.º 4
0
 private TblPositionRoute UpdateOrInsertTblPositionRoute(TblPositionRoute newRow, bool save, int index, out int outindex, string company)
 {
     outindex = index;
     using (var entity = new ccnewEntities(GetSqlConnectionString(company)))
     {
         if (save)
         {
             entity.TblPositionRoutes.AddObject(newRow);
         }
         else
         {
             var oldRow = (from e in entity.TblPositionRoutes
                           where e.Iserial == newRow.Iserial
                           select e).SingleOrDefault();
             if (oldRow != null)
             {
                 GenericUpdate(oldRow, newRow, entity);
             }
         }
         entity.SaveChanges();
         return(newRow);
     }
 }