public Notify Update(POS_PRODUCT_TYPE ProductTypeModel) { try { objNotify.RowEffected = _objDALProductType.UpdateProductType(ProductTypeModel); if (objNotify.RowEffected > 0) { objNotify.NotifyMessage = "Record Updated Successfully"; } else { objNotify.NotifyMessage = "ProductType 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 CreateProductType(POS_PRODUCT_TYPE ProductTypeModel) { int rowAffected = 0; POS_PRODUCT_TYPE _objProductTypeEntity = new POS_PRODUCT_TYPE(); try { _objProductTypeEntity.TYPE_CODE = GetMaxCode(); _objProductTypeEntity.PRODUCT_TYPE = ProductTypeModel.PRODUCT_TYPE; _objProductTypeEntity.ISACTIVE_FLAG = ProductTypeModel.ISACTIVE_FLAG; _objProductTypeEntity.ISPOSTED_FLAG = false; _objProductTypeEntity.CREATEDBY = ProductTypeModel.CREATEDBY; _objProductTypeEntity.CREATEDWHEN = ProductTypeModel.CREATEDWHEN; _dbContext.POS_PRODUCT_TYPE.Add(_objProductTypeEntity); rowAffected = _dbContext.SaveChanges(); return(rowAffected); } catch (Exception ex) { ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error); throw new DALException(ex.Message.ToString()); } }
public string GetMaxCode() { string code = string.Empty; int maxCode = 0; try { _objProductTypeEntity = _dbContext.POS_PRODUCT_TYPE.OrderByDescending(x => x.TYPE_CODE).FirstOrDefault(); if (_objProductTypeEntity == null) { code = "0001"; } else { maxCode = Formatter.SetValidValueToInt(_objProductTypeEntity.TYPE_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()); } }
public int UpdateProductType(POS_PRODUCT_TYPE ProductTypeModel) { int rowAffected = 0; POS_PRODUCT_TYPE entity = new POS_PRODUCT_TYPE(); try { entity = _dbContext.POS_PRODUCT_TYPE.Find(ProductTypeModel.TYPE_ID); _objProductTypeEntity.PRODUCT_TYPE = ProductTypeModel.PRODUCT_TYPE; entity.ISACTIVE_FLAG = ProductTypeModel.ISACTIVE_FLAG; entity.ISPOSTED_FLAG = false; entity.MODIFIEDBY = ProductTypeModel.MODIFIEDBY; entity.MODIFIEDWHEN = ProductTypeModel.MODIFIEDWHEN; rowAffected = _dbContext.SaveChanges(); return(rowAffected); } catch (Exception ex) { ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error); throw new DALException(ex.Message.ToString()); } }
public POS_PRODUCT_TYPE GetById(long?id) { try { _objProductTypeEntity = _dbContext.POS_PRODUCT_TYPE.Find(id); return(_objProductTypeEntity); } catch (Exception ex) { ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error); throw new DALException(ex.Message.ToString()); } }
public ActionResult Edit(POS_PRODUCT_TYPE POS_PRODUCT_TYPE) { try { if (Session[SessionVariables.Session_UserInfo] != null) { POS_PRODUCT_TYPE.MODIFIEDBY = SessionHandling.UserInformation.USERNAME; POS_PRODUCT_TYPE.MODIFIEDWHEN = DateTime.Now; if (ModelState.IsValid) { objNotify = _objBALProductType.Update(POS_PRODUCT_TYPE); if (objNotify.RowEffected > 0) { ShowAlert(AlertType.Success, objNotify.NotifyMessage); return(RedirectToAction("Index")); } else { ShowAlert(AlertType.Error, objNotify.NotifyMessage); } } else { return(View(POS_PRODUCT_TYPE)); } return(View(POS_PRODUCT_TYPE)); } else { return(RedirectToAction("Login", "Home")); } } catch (Exception ex) { error.Breadcrum = "Home > POINT OF SALE (POS) > ProductType > 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 DeleteProductType(long id) { int rowAffected = 0; try { _objProductTypeEntity = _dbContext.POS_PRODUCT_TYPE.Find(id); _dbContext.POS_PRODUCT_TYPE.Remove(_objProductTypeEntity); rowAffected = _dbContext.SaveChanges(); return(rowAffected); } catch (Exception ex) { ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error); throw new DALException(ex.Message.ToString()); } }
public POS_PRODUCT_TYPE GetById(long?id) { try { _objProductTypeEntity = _objDALProductType.GetById(id); return(_objProductTypeEntity); } catch (Exception ex) { if (ex is DALException) { throw ex; } else { ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error); } throw new BALException(ex.Message.ToString()); } }
// GET: /ProductType/Details/5 public ActionResult Details(long id) { try { if (Session[SessionVariables.Session_UserInfo] != null) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } POS_PRODUCT_TYPE POS_PRODUCT_TYPE = _objBALProductType.GetById(id); if (POS_PRODUCT_TYPE == null) { return(HttpNotFound()); } return(View(POS_PRODUCT_TYPE)); } else { return(RedirectToAction("Login", "Home")); } } catch (Exception ex) { error.Breadcrum = "Home > POINT OF SALE (POS) > ProductType > 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 { _objProductTypeEntity = _dbContext.POS_PRODUCT_TYPE.OrderByDescending(x => x.TYPE_ID).FirstOrDefault(); if (_objProductTypeEntity.TYPE_ID.ToString() == null) { id = 1; } else { id = _objProductTypeEntity.TYPE_ID + 1; } return(id); } catch (Exception ex) { ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error); throw new DALException(ex.Message.ToString()); } }