Пример #1
0
        public int UpdateUnits(POS_UNI UnitsModel)
        {
            int     rowAffected = 0;
            POS_UNI entity      = new POS_UNI();

            try
            {
                entity = _dbContext.POS_UNI.Find(UnitsModel.UNIT_ID);

                _objUnitsEntity.UNIT = UnitsModel.UNIT;
                entity.ISACTIVE_FLAG = UnitsModel.ISACTIVE_FLAG;
                entity.ISPOSTED_FLAG = false;
                entity.MODIFIEDBY    = UnitsModel.MODIFIEDBY;
                entity.MODIFIEDWHEN  = UnitsModel.MODIFIEDWHEN;

                rowAffected = _dbContext.SaveChanges();

                return(rowAffected);
            }
            catch (Exception ex)
            {
                ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
                throw new DALException(ex.Message.ToString());
            }
        }
Пример #2
0
 public Notify Update(POS_UNI UnitsModel)
 {
     try
     {
         objNotify.RowEffected = _objDALUnits.UpdateUnits(UnitsModel);
         if (objNotify.RowEffected > 0)
         {
             objNotify.NotifyMessage = "Record Updated Successfully";
         }
         else
         {
             objNotify.NotifyMessage = "Units 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());
     }
 }
Пример #3
0
 public POS_UNI GetById(long?id)
 {
     try
     {
         _objUnitsEntity = _dbContext.POS_UNI.Find(id);
         return(_objUnitsEntity);
     }
     catch (Exception ex)
     {
         ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
         throw new DALException(ex.Message.ToString());
     }
 }
Пример #4
0
        public ActionResult Edit(POS_UNI POS_UNI)
        {
            try
            {
                if (Session[SessionVariables.Session_UserInfo] != null)
                {
                    POS_UNI.MODIFIEDBY   = SessionHandling.UserInformation.USERNAME;
                    POS_UNI.MODIFIEDWHEN = DateTime.Now;
                    if (ModelState.IsValid)
                    {
                        objNotify = _objBALUnits.Update(POS_UNI);
                        if (objNotify.RowEffected > 0)
                        {
                            ShowAlert(AlertType.Success, objNotify.NotifyMessage);
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            ShowAlert(AlertType.Error, objNotify.NotifyMessage);
                        }
                    }
                    else
                    {
                        return(View(POS_UNI));
                    }

                    return(View(POS_UNI));
                }
                else
                {
                    return(RedirectToAction("Login", "Home"));
                }
            }
            catch (Exception ex)
            {
                error.Breadcrum = "Home > POINT OF SALE (POS) > Units  > 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));
            }
        }
Пример #5
0
        public int DeleteUnits(long id)
        {
            int rowAffected = 0;

            try
            {
                _objUnitsEntity = _dbContext.POS_UNI.Find(id);
                _dbContext.POS_UNI.Remove(_objUnitsEntity);
                rowAffected = _dbContext.SaveChanges();

                return(rowAffected);
            }
            catch (Exception ex)
            {
                ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
                throw new DALException(ex.Message.ToString());
            }
        }
Пример #6
0
 public POS_UNI GetById(long?id)
 {
     try
     {
         _objUnitsEntity = _objDALUnits.GetById(id);
         return(_objUnitsEntity);
     }
     catch (Exception ex)
     {
         if (ex is DALException)
         {
             throw ex;
         }
         else
         {
             ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
         }
         throw new BALException(ex.Message.ToString());
     }
 }
Пример #7
0
 // GET: /Units/Details/5
 public ActionResult Details(long id)
 {
     try
     {
         if (Session[SessionVariables.Session_UserInfo] != null)
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             POS_UNI POS_UNI = _objBALUnits.GetById(id);
             if (POS_UNI == null)
             {
                 return(HttpNotFound());
             }
             return(View(POS_UNI));
         }
         else
         {
             return(RedirectToAction("Login", "Home"));
         }
     }
     catch (Exception ex)
     {
         error.Breadcrum = "Home > POINT OF SALE (POS) > Units  > 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));
     }
 }
Пример #8
0
        public int CreateUnits(POS_UNI UnitsModel)
        {
            int     rowAffected     = 0;
            POS_UNI _objUnitsEntity = new POS_UNI();

            try
            {
                _objUnitsEntity.UNIT          = UnitsModel.UNIT;
                _objUnitsEntity.ISACTIVE_FLAG = UnitsModel.ISACTIVE_FLAG;
                _objUnitsEntity.ISPOSTED_FLAG = false;
                _objUnitsEntity.CREATEDBY     = UnitsModel.CREATEDBY;
                _objUnitsEntity.CREATEDWHEN   = UnitsModel.CREATEDWHEN;

                _dbContext.POS_UNI.Add(_objUnitsEntity);
                rowAffected = _dbContext.SaveChanges();

                return(rowAffected);
            }
            catch (Exception ex)
            {
                ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
                throw new DALException(ex.Message.ToString());
            }
        }
Пример #9
0
        public long GetMaxId()
        {
            long id = 0;

            try
            {
                _objUnitsEntity = _dbContext.POS_UNI.OrderByDescending(x => x.UNIT_ID).FirstOrDefault();
                if (_objUnitsEntity.UNIT_ID.ToString() == null)
                {
                    id = 1;
                }
                else
                {
                    id = _objUnitsEntity.UNIT_ID + 1;
                }

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