Exemple #1
0
        private TblBrandBudgetHeader UpdateOrInsertTblBrandBudgetHeader(TblBrandBudgetHeader newRow, int userIserial)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var oldRow = (from e in context.TblBrandBudgetHeaders
                              where e.Iserial == newRow.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    var temp = GenericUpdate(oldRow, newRow, context);

                    if (temp.Any())
                    {
                        newRow.LastUpdatedDate = DateTime.Now;
                        newRow.LastUpdatedBy   = userIserial;
                    }
                }
                else
                {
                    newRow.LastUpdatedDate = DateTime.Now;
                    newRow.CreatedBy       = userIserial;
                    context.TblBrandBudgetHeaders.AddObject(newRow);
                }

                context.SaveChanges();

                return(newRow);
            }
        }
Exemple #2
0
 private int DeleteTblBrandBudgetHeader(TblBrandBudgetHeader row)
 {
     using (var context = new WorkFlowManagerDBEntities())
     {
         var oldRow = (from e in context.TblBrandBudgetHeaders
                       where e.Iserial == row.Iserial
                       select e).SingleOrDefault();
         if (oldRow != null)
         {
             context.DeleteObject(oldRow);
             context.SaveChanges();
         }
         return(row.Iserial);
     }
 }
Exemple #3
0
        public void SaveMainRow()
        {
            //var valiationCollection = new List<ValidationResult>();
            //bool isvalid = Validator.TryValidateObject(TransactionHeader,
            //    new ValidationContext(TransactionHeader, null, null), valiationCollection, true);
            //if (isvalid)
            //{
            var data = new TblBrandBudgetHeader();

            data.InjectFrom(TransactionHeader);
            data.TransactionType = TransactionType;
            bool save = TransactionHeader.Iserial == 0;

            if (save)
            {
                if (AllowAdd)
                {
                    Loading = true;
                    Client.UpdateOrInsertTblBrandBudgetHeaderAsync(data, LoggedUserInfo.Iserial);
                }

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