Example #1
0
        private TblBrandStoreTargetDetail UpdateOrInsertTblBrandStoreTargetDetail(TblBrandStoreTargetDetail newRow, bool save, int index, string company,
                                                                                  out int outindex)
        {
            outindex = index;

            using (var context = new ccnewEntities(GetSqlConnectionString(company)))
            {
                if (save)
                {
                    context.TblBrandStoreTargetDetails.AddObject(newRow);
                }
                else
                {
                    var oldRow = (from e in context.TblBrandStoreTargetDetails
                                  where e.Iserial == newRow.Iserial
                                  select e).SingleOrDefault();
                    if (oldRow != null)
                    {
                        GenericUpdate(oldRow, newRow, context);
                    }
                }
                context.SaveChanges();
                return(newRow);
            }
        }
        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)
                {
                    var save    = SelectedMainRow.Iserial == 0;
                    var saveRow = new TblBrandStoreTargetDetail();
                    saveRow.InjectFrom(SelectedMainRow);
                    if (TransactionHeader.Glserial == 0)
                    {
                        saveRow.TblBrandStoreTargetHeader = new TblBrandStoreTargetHeader();
                        saveRow.TblBrandStoreTargetHeader.InjectFrom(TransactionHeader);
                    }
                    else
                    {
                        saveRow.Glserial = TransactionHeader.Glserial;
                    }
                    Client.ServerConnectionsAsync(LoggedUserInfo.Ip, LoggedUserInfo.Port, LoggedUserInfo.DatabasEname);
                    Client.UpdateOrInsertTblBrandStoreTargetDetailAsync(saveRow, save, TransactionHeader.MainRowList.IndexOf(SelectedMainRow), LoggedUserInfo.DatabasEname);
                }
            }
        }
Example #3
0
        private int DeleteTblBrandStoreTargetDetail(TblBrandStoreTargetDetail row, string company)
        {
            using (var context = new ccnewEntities(GetSqlConnectionString(company)))
            {
                var oldRow = (from e in context.TblBrandStoreTargetDetails
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.Iserial);
        }