public string GetMaxCode()
        {
            string code    = string.Empty;
            int    maxCode = 0;

            try
            {
                _objProductCategoryEntity = _dbContext.POS_PRODUCT_CATEGORY.OrderByDescending(x => x.CATOEGORY_CODE).FirstOrDefault();
                if (_objProductCategoryEntity == null)
                {
                    code = "0001";
                }
                else
                {
                    maxCode = Formatter.SetValidValueToInt(_objProductCategoryEntity.CATOEGORY_CODE) + 1;
                    code    = maxCode.ToString().PadLeft(4, '0');
                }

                return(code);
            }
            catch (Exception ex)
            {
                ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
                throw new DALException(ex.Message.ToString());
            }
        }
Beispiel #2
0
 public Notify Update(POS_PRODUCT_CATEGORY ProductCategoryModel)
 {
     try
     {
         objNotify.RowEffected = _objDALProductCategory.UpdateProductCategory(ProductCategoryModel);
         if (objNotify.RowEffected > 0)
         {
             objNotify.NotifyMessage = "Record Updated Successfully";
         }
         else
         {
             objNotify.NotifyMessage = "ProductCategory Not Updated";
         }
         return(objNotify);
     }
     catch (Exception ex)
     {
         if (ex is DALException)
         {
             throw ex;
         }
         else
         {
             ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
         }
         throw new BALException(ex.Message.ToString());
     }
 }
        public int CreateProductCategory(POS_PRODUCT_CATEGORY ProductCategoryModel)
        {
            int rowAffected = 0;
            POS_PRODUCT_CATEGORY _objProductCategoryEntity = new POS_PRODUCT_CATEGORY();

            try
            {
                _objProductCategoryEntity.CATOEGORY_CODE   = GetMaxCode();
                _objProductCategoryEntity.PRODUCT_CATEGORY = ProductCategoryModel.PRODUCT_CATEGORY;
                _objProductCategoryEntity.ISACTIVE_FLAG    = ProductCategoryModel.ISACTIVE_FLAG;
                _objProductCategoryEntity.ISPOSTED_FLAG    = false;
                _objProductCategoryEntity.CREATEDBY        = ProductCategoryModel.CREATEDBY;
                _objProductCategoryEntity.CREATEDWHEN      = ProductCategoryModel.CREATEDWHEN;

                _dbContext.POS_PRODUCT_CATEGORY.Add(_objProductCategoryEntity);
                rowAffected = _dbContext.SaveChanges();

                return(rowAffected);
            }
            catch (Exception ex)
            {
                ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
                throw new DALException(ex.Message.ToString());
            }
        }
 public POS_PRODUCT_CATEGORY GetById(long?id)
 {
     try
     {
         _objProductCategoryEntity = _dbContext.POS_PRODUCT_CATEGORY.Find(id);
         return(_objProductCategoryEntity);
     }
     catch (Exception ex)
     {
         ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
         throw new DALException(ex.Message.ToString());
     }
 }
        public ActionResult Edit(POS_PRODUCT_CATEGORY POS_PRODUCT_CATEGORY)
        {
            try
            {
                if (Session[SessionVariables.Session_UserInfo] != null)
                {
                    POS_PRODUCT_CATEGORY.MODIFIEDBY   = SessionHandling.UserInformation.USERNAME;
                    POS_PRODUCT_CATEGORY.MODIFIEDWHEN = DateTime.Now;
                    if (ModelState.IsValid)
                    {
                        objNotify = _objBALProductCategory.Update(POS_PRODUCT_CATEGORY);
                        if (objNotify.RowEffected > 0)
                        {
                            ShowAlert(AlertType.Success, objNotify.NotifyMessage);
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            ShowAlert(AlertType.Error, objNotify.NotifyMessage);
                        }
                    }
                    else
                    {
                        return(View(POS_PRODUCT_CATEGORY));
                    }

                    return(View(POS_PRODUCT_CATEGORY));
                }
                else
                {
                    return(RedirectToAction("Login", "Home"));
                }
            }
            catch (Exception ex)
            {
                error.Breadcrum = "Home > POINT OF SALE (POS) > GetProductCategory  > Edit";
                if (ex is BALException)
                {
                    error.ErrorMsg = ex.Message.ToString() + "from " + ex.TargetSite.DeclaringType.Name + " method in " + ex.TargetSite.Name + " layer";
                }
                else
                {
                    ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.UI, ExceptionType.Error);
                    error.ErrorMsg = ex.Message.ToString() + "from " + ex.TargetSite.DeclaringType.Name + " method in " + ex.TargetSite.Name + " layer";
                }
                return(RedirectToAction("ShowErrorPage", "Master", error));
            }
        }
        public int DeleteProductCategory(long id)
        {
            int rowAffected = 0;

            try
            {
                _objProductCategoryEntity = _dbContext.POS_PRODUCT_CATEGORY.Find(id);
                _dbContext.POS_PRODUCT_CATEGORY.Remove(_objProductCategoryEntity);
                rowAffected = _dbContext.SaveChanges();

                return(rowAffected);
            }
            catch (Exception ex)
            {
                ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
                throw new DALException(ex.Message.ToString());
            }
        }
Beispiel #7
0
 public POS_PRODUCT_CATEGORY GetById(long?id)
 {
     try
     {
         _objProductCategoryEntity = _objDALProductCategory.GetById(id);
         return(_objProductCategoryEntity);
     }
     catch (Exception ex)
     {
         if (ex is DALException)
         {
             throw ex;
         }
         else
         {
             ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
         }
         throw new BALException(ex.Message.ToString());
     }
 }
 // GET: /ProductCategory/Details/5
 public ActionResult Details(long id)
 {
     try
     {
         if (Session[SessionVariables.Session_UserInfo] != null)
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             POS_PRODUCT_CATEGORY POS_PRODUCT_CATEGORY = _objBALProductCategory.GetById(id);
             if (POS_PRODUCT_CATEGORY == null)
             {
                 return(HttpNotFound());
             }
             return(View(POS_PRODUCT_CATEGORY));
         }
         else
         {
             return(RedirectToAction("Login", "Home"));
         }
     }
     catch (Exception ex)
     {
         error.Breadcrum = "Home > POINT OF SALE (POS) > GetProductCategory  > Detail";
         if (ex is BALException)
         {
             error.ErrorMsg = ex.Message.ToString() + "from " + ex.TargetSite.DeclaringType.Name + " method in " + ex.TargetSite.Name + " layer";
         }
         else
         {
             ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.UI, ExceptionType.Error);
             error.ErrorMsg = ex.Message.ToString() + "from " + ex.TargetSite.DeclaringType.Name + " method in " + ex.TargetSite.Name + " layer";
         }
         return(RedirectToAction("ShowErrorPage", "Master", error));
     }
 }
        public long GetMaxId()
        {
            long id = 0;

            try
            {
                _objProductCategoryEntity = _dbContext.POS_PRODUCT_CATEGORY.OrderByDescending(x => x.CATEGORY_ID).FirstOrDefault();
                if (_objProductCategoryEntity.CATEGORY_ID.ToString() == null)
                {
                    id = 1;
                }
                else
                {
                    id = _objProductCategoryEntity.CATEGORY_ID + 1;
                }

                return(id);
            }
            catch (Exception ex)
            {
                ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
                throw new DALException(ex.Message.ToString());
            }
        }