예제 #1
0
        private int DeleteTblIssueJournalReceiveHeader(TblIssueJournalReceiveHeader row)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var oldRow = (from e in context.TblIssueJournalReceiveHeaders
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.Iserial);
        }
예제 #2
0
        public void SaveRecRow()
        {
            if (AllowAdd != true)
            {
                MessageBox.Show(strings.AllowAddMsg);
                return;
            }
            var detailsl = new ObservableCollection <TblIssueJournalReceiveDetail>();

            if (SelectedRecRow != null)
            {
                var valiationCollection = new List <ValidationResult>();

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

                foreach (var variable in SelectedRecRow.DetailList)
                {
                    var valiationCollectiondetail = new List <ValidationResult>();

                    var isvalidDetails = Validator.TryValidateObject(variable, new ValidationContext(variable, null, null), valiationCollectiondetail, true);

                    if (isvalidDetails)
                    {
                        detailsl.Add(new TblIssueJournalReceiveDetail().InjectFrom(variable) as TblIssueJournalReceiveDetail);
                    }
                    else
                    {
                        return;
                    }
                }

                if (isvalid)
                {
                    var save = SelectedRecRow.Iserial == 0;
                    SelectedRecRow.TblIssueJournalHeader = SelectedMainRow.Iserial;
                    var saveRow = new TblIssueJournalReceiveHeader();
                    saveRow.InjectFrom(SelectedRecRow);
                    saveRow.TblIssueJournalReceiveDetails = detailsl;
                    Loading = true;
                    Client.UpdateOrInsertTblIssueJournalReceiveHeaderAsync(saveRow, save, SelectedMainRow.SubDetailList.IndexOf(SelectedRecRow));
                }
            }
        }
예제 #3
0
 private TblIssueJournalReceiveHeader UpdateOrInsertTblIssueJournalReceiveHeader(TblIssueJournalReceiveHeader newRow, bool save, int index, out int outindex)
 {
     outindex = index;
     using (var context = new WorkFlowManagerDBEntities())
     {
         if (save)
         {
             context.TblIssueJournalReceiveHeaders.AddObject(newRow);
         }
         else
         {
             var oldRow = (from e in context.TblIssueJournalReceiveHeaders
                           where e.Iserial == newRow.Iserial
                           select e).SingleOrDefault();
             if (oldRow != null)
             {
                 GenericUpdate(oldRow, newRow, context);
             }
         }
         context.SaveChanges();
         return(newRow);
     }
 }