Ejemplo n.º 1
0
        private TblPromoHeader UpdateOrInsertTblPromoHeader(TblPromoHeader newRow, string company)
        {
            using (var context = new ccnewEntities(GetSqlConnectionString(company)))
            {
                var oldRow = (from e in context.TblPromoHeaders
                              where e.GlSerial == newRow.GlSerial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    GenericUpdate(oldRow, newRow, context);

                    foreach (var item in newRow.TblPromoCriterias)
                    {
                        UpdateOrInsertTblPromoCriteria(item, context);
                    }
                }
                else
                {
                    newRow.CreateDate = DateTime.Now;
                    context.TblPromoHeaders.AddObject(newRow);
                }

                context.SaveChanges();

                return(newRow);
            }
        }
Ejemplo n.º 2
0
 private int DeleteTblPromoHeader(TblPromoHeader row, string company)
 {
     using (var context = new ccnewEntities(GetSqlConnectionString(company)))
     {
         var oldRow = (from e in context.TblPromoHeaders
                       where e.GlSerial == row.GlSerial
                       select e).SingleOrDefault();
         if (oldRow != null)
         {
             context.DeleteObject(oldRow);
             context.SaveChanges();
         }
         return(row.GlSerial);
     }
 }
Ejemplo n.º 3
0
        public void Delete()
        {
            var data = new TblPromoHeader();

            data.InjectFrom(TransactionHeader);

            if (AllowDelete)
            {
                Loading = true;
                Client.DeleteTblPromoHeaderAsync(data, LoggedUserInfo.DatabasEname);
            }
            else
            {
                MessageBox.Show("You are Not Allowed to Delete");
            }
        }
Ejemplo n.º 4
0
        public void UpdateAndInsert()
        {
            var  valiationCollection = new List <ValidationResult>();
            bool isvalid             = Validator.TryValidateObject(TransactionHeader, new ValidationContext(TransactionHeader, null, null), valiationCollection, true);

            if (isvalid)
            {
                var data = new TblPromoHeader();
                data.InjectFrom(TransactionHeader);
                bool save = TransactionHeader.GlSerial == 0;
                if (save)
                {
                    if (AllowAdd)
                    {
                        Loading = true;
                        Client.UpdateOrInsertTblPromoHeaderAsync(data, LoggedUserInfo.DatabasEname);
                    }

                    else
                    {
                        MessageBox.Show("You are Not Allowed to Add");
                    }
                }
                else
                {
                    if (AllowUpdate)
                    {
                        Loading = true;
                        Client.UpdateOrInsertTblPromoHeaderAsync(data, LoggedUserInfo.DatabasEname);
                    }

                    else
                    {
                        MessageBox.Show("You are Not Allowed to Update");
                    }
                }
            }
        }