Example #1
0
 public ActionResult AddAccountSubType(VMAccountSubType VMAccountSubType)
 {
     try
     {
         if (ModelState.IsValid)
         {
             tblUser user = Session[WebUtil.CURRENT_USER] as tblUser;
             if (!(user != null))
             {
                 return(RedirectToAction("RedirectToLogin", "user"));
             }
             tblAccountSubType Table = (VMAccountSubType).TotblAccountSubType();
             Table.CompanyId   = user.CompanyId;
             Table.CreatedBy   = user.Id;
             Table.CreatedDate = DateTime.Now;
             new AccountSubTypeHandler().AddAccountSubType(Table);
             return(JavaScript("showMessage('success', 'Account Sub Type added Successfully','bottom-right','AccountSubType', 'Manage')"));
         }
         else
         {
             return(JavaScript("showMessage('error', 'All fields are required, Please try again','bottom-right','AccountSubType', 'Manage')"));
         }
     }
     catch (Exception ex)
     {
         return(JavaScript("showMessage('error', 'Failed to Add Account Sub Type, Please Contact to Administrator','bottom-right','AccountSubType', 'Manage')"));
     }
 }
Example #2
0
        public void UpdateAccountSubType(long id, tblAccountSubType AccountSubType)
        {
            using (OriginatorEntities db = new OriginatorEntities())
            {
                tblAccountSubType found = db.tblAccountSubTypes.Find(id);
                if (!string.IsNullOrWhiteSpace(AccountSubType.TypeName))
                {
                    found.TypeName = AccountSubType.TypeName;
                }
                if (!string.IsNullOrWhiteSpace(AccountSubType.SubTypeName))
                {
                    found.SubTypeName = AccountSubType.SubTypeName;
                }
                if (AccountSubType.CompanyId != null && AccountSubType.CompanyId > 0)
                {
                    found.CompanyId = AccountSubType.CompanyId;
                }
                if (AccountSubType.ModifiedBy != null && AccountSubType.ModifiedBy > 0)
                {
                    found.ModifiedBy = AccountSubType.ModifiedBy;
                }
                if (!string.IsNullOrWhiteSpace(AccountSubType.ModifiedDate.ToString()))
                {
                    found.ModifiedDate = AccountSubType.ModifiedDate;
                }

                db.SaveChanges();
            }
        }
Example #3
0
        public static tblAccountSubType TotblAccountSubType(this VMAccountSubType model)
        {
            tblAccountSubType table = new tblAccountSubType();

            table.TypeName    = model.TypeName;
            table.SubTypeName = model.SubTypeName;
            return(table);
        }
Example #4
0
 public void AddAccountSubType(tblAccountSubType AccountSubType)
 {
     using (OriginatorEntities db = new OriginatorEntities())
     {
         db.tblAccountSubTypes.Add(AccountSubType);
         db.SaveChanges();
     }
 }
Example #5
0
        public static VMAccountSubType ToVMAccountSubType(this tblAccountSubType entity)
        {
            VMAccountSubType model = new VMAccountSubType();

            model.Id          = entity.Id;
            model.TypeName    = entity.TypeName;
            model.SubTypeName = entity.SubTypeName;
            return(model);
        }
Example #6
0
 public void DeleteAccountSubType(long Id, long DeletedBy)
 {
     using (OriginatorEntities db = new OriginatorEntities())
     {
         tblAccountSubType found = db.tblAccountSubTypes.Find(Id);
         found.DeletedBy   = DeletedBy;
         found.DeletedDate = DateTime.Now;
         found.IsDeleted   = true;
         db.SaveChanges();
     }
 }