Пример #1
0
        private TblStandardBomHeader UpdateOrInsertTblStandardBOMHeader(TblStandardBomHeader newRow, bool save,
                                                                        int index, out int outindex, string UserName)
        {
            outindex = index;
            using (var context = new WorkFlowManagerDBEntities())
            {
                if (save)
                {
                    context.TblStandardBomHeaders.AddObject(newRow);
                }
                else
                {
                    var oldRow = (from e in context.TblStandardBomHeaders
                                  where e.Iserial == newRow.Iserial
                                  select e).SingleOrDefault();
                    if (oldRow != null)
                    {
                        GenericUpdate(oldRow, newRow, context);
                    }
                }

                context.SaveChanges();

                return(newRow);
            }
        }
Пример #2
0
        private TblStandardBomHeader DeleteTblStandardBOMHeader(TblStandardBomHeader row)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var oldRow = (from e in context.TblStandardBomHeaders
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();

                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row);
        }
Пример #3
0
        public void SaveMainRow()
        {
            if (SelectedMainRow != null)
            {
                var valiationCollection = new List <ValidationResult>();

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

                if (isvalid)
                {
                    if (AllowUpdate != true)
                    {
                        MessageBox.Show(strings.AllowAddMsg);
                        return;
                    }

                    var save    = SelectedMainRow.Iserial == 0;
                    var saveRow = new TblStandardBomHeader();
                    saveRow.InjectFrom(SelectedMainRow);
                    Loading = true;
                    Client.UpdateOrInsertTblStandardBOMHeaderAsync(saveRow, save, MainRowList.IndexOf(SelectedMainRow), LoggedUserInfo.WFM_UserName);
                }
            }
        }