Example #1
0
        private TblStoreIntialOrder UpdateOrInsertTblStoreIntialOrder(TblStoreIntialOrder newRow, bool save, int index, out int outindex)
        {
            outindex = index;
            using (var context = new ccnewEntities())
            {
                if (save)
                {
                    context.TblStoreIntialOrders.AddObject(newRow);
                }
                else
                {
                    var oldRow = (from e in context.TblStoreIntialOrders
                                  where e.Style == newRow.Style &&
                                  e.Color == newRow.Color &&
                                  e.Store == newRow.Store
                                  select e).SingleOrDefault();
                    if (oldRow != null)
                    {
                        GenericUpdate(oldRow, newRow, context);
                    }
                }

                context.SaveChanges();
                return(newRow);
            }
        }
Example #2
0
        private TblStoreIntialOrder DeleteTblStoreIntialOrder(TblStoreIntialOrder row)
        {
            using (var context = new ccnewEntities())
            {
                var oldRow = (from e in context.TblStoreIntialOrders
                              where e.Style == row.Style &&
                              e.Color == row.Color &&
                              e.Store == row.Store
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row);
        }
        public void SaveDetailRow()
        {
            if (AllowUpdate != true)
            {
                MessageBox.Show(strings.AllowAddMsg);
                return;
            }
            if (SelectedDetailRow != null)
            {
                var valiationCollection = new List <ValidationResult>();

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

                if (isvalid && !Loading)//&& !SelectedMainRow.LockedRow)
                {
                    var save    = SelectedDetailRow.Iserial == 0;
                    var saveRow = new TblStoreIntialOrder();
                    saveRow.InjectFrom(SelectedDetailRow);

                    Loading = true;
                    Client.UpdateOrInsertTblStoreIntialOrderAsync(saveRow, save, SelectedMainRow.DetailList.IndexOf(SelectedDetailRow));
                }
            }
        }