public Notify Update(POS_PRODUCT ProductModel) { try { objNotify.RowEffected = _objDALProduct.UpdateProduct(ProductModel); if (objNotify.RowEffected > 0) { objNotify.NotifyMessage = "Record Updated Successfully"; } else { objNotify.NotifyMessage = "Product 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 CreateProduct(POS_PRODUCT ProductModel) { int rowAffected = 0; POS_PRODUCT _objProductEntity = new POS_PRODUCT(); try { _objProductEntity.PRODUCT_CODE = GetMaxCode(); _objProductEntity.PRODUCT_DESC = ProductModel.PRODUCT_DESC; _objProductEntity.PROFIT_MARGIN_RATE = ProductModel.PROFIT_MARGIN_RATE; _objProductEntity.PAYBLE_PRICE = ProductModel.PAYBLE_PRICE; _objProductEntity.IS_TAX_APPLIED_FLAG = ProductModel.IS_TAX_APPLIED_FLAG; _objProductEntity.TAX_PER = ProductModel.TAX_PER; _objProductEntity.TAX_RS = ProductModel.TAX_RS; _objProductEntity.TYPE_ID = ProductModel.TYPE_ID; _objProductEntity.CATEGORY_ID = ProductModel.CATEGORY_ID; _objProductEntity.UNIT_ID = ProductModel.UNIT_ID; _objProductEntity.EXPIRY_FROM = ProductModel.EXPIRY_FROM; _objProductEntity.EXPIRY_TO = ProductModel.EXPIRY_TO; _objProductEntity.ISACTIVE_FLAG = ProductModel.ISACTIVE_FLAG; _objProductEntity.ISPOSTED_FLAG = false; _objProductEntity.CREATEDBY = ProductModel.CREATEDBY; _objProductEntity.CREATEDWHEN = ProductModel.CREATEDWHEN; _dbContext.POS_PRODUCT.Add(_objProductEntity); rowAffected = _dbContext.SaveChanges(); return(rowAffected); } catch (Exception ex) { ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error); throw new DALException(ex.Message.ToString()); } }
public int UpdateProduct(POS_PRODUCT ProductModel) { int rowAffected = 0; POS_PRODUCT entity = new POS_PRODUCT(); try { entity = _dbContext.POS_PRODUCT.Find(ProductModel.PRODUCT_ID); entity.PRODUCT_DESC = ProductModel.PRODUCT_DESC; entity.PROFIT_MARGIN_RATE = ProductModel.PROFIT_MARGIN_RATE; entity.PAYBLE_PRICE = ProductModel.PAYBLE_PRICE; entity.IS_TAX_APPLIED_FLAG = ProductModel.IS_TAX_APPLIED_FLAG; entity.TAX_PER = ProductModel.TAX_PER; entity.TAX_RS = ProductModel.TAX_RS; entity.TYPE_ID = ProductModel.TypeId; entity.CATEGORY_ID = ProductModel.CategoryId; entity.UNIT_ID = ProductModel.UnitId; entity.EXPIRY_FROM = ProductModel.EXPIRY_FROM; entity.EXPIRY_TO = ProductModel.EXPIRY_TO; entity.ISACTIVE_FLAG = ProductModel.ISACTIVE_FLAG; entity.ISPOSTED_FLAG = false; entity.MODIFIEDBY = ProductModel.MODIFIEDBY; entity.MODIFIEDWHEN = ProductModel.MODIFIEDWHEN; 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 { _objProductEntity = _dbContext.POS_PRODUCT.OrderByDescending(x => x.PRODUCT_CODE).FirstOrDefault(); if (_objProductEntity == null) { code = "0001"; } else { maxCode = Formatter.SetValidValueToInt(_objProductEntity.PRODUCT_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 ActionResult Edit(POS_PRODUCT POS_PRODUCT) { try { if (Session[SessionVariables.Session_UserInfo] != null) { POS_PRODUCT.MODIFIEDBY = SessionHandling.UserInformation.USERNAME; POS_PRODUCT.MODIFIEDWHEN = DateTime.Now; if (ModelState.IsValid) { objNotify = _objBALProduct.Update(POS_PRODUCT); if (objNotify.RowEffected > 0) { ShowAlert(AlertType.Success, objNotify.NotifyMessage); return(RedirectToAction("Index")); } else { ShowAlert(AlertType.Error, objNotify.NotifyMessage); } } else { return(View(POS_PRODUCT)); } return(View(POS_PRODUCT)); } else { return(RedirectToAction("Login", "Home")); } } catch (Exception ex) { error.Breadcrum = "Home > POINT OF SALE (POS) > Product > 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 DeleteProduct(long id) { int rowAffected = 0; try { _objProductEntity = _dbContext.POS_PRODUCT.Find(id); _dbContext.POS_PRODUCT.Remove(_objProductEntity); rowAffected = _dbContext.SaveChanges(); return(rowAffected); } catch (Exception ex) { ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error); throw new DALException(ex.Message.ToString()); } }
public ActionResult Create(POS_PRODUCT ProductModel) { try { if (Session[SessionVariables.Session_UserInfo] != null) { ProductModel.CREATEDBY = SessionHandling.UserInformation.USERNAME; ProductModel.CREATEDWHEN = DateTime.Now; if (ProductModel.PRODUCT_DESC != null) { objNotify = _objBALProduct.Create(ProductModel); if (objNotify.RowEffected > 0) { ShowAlert(AlertType.Success, objNotify.NotifyMessage); } else { ShowAlert(AlertType.Error, objNotify.NotifyMessage); } } //return View(POS_PRODUCT); } else { return(RedirectToAction("Login", "Home")); } } catch (Exception ex) { error.Breadcrum = "Home > POINT OF SALE (POS) > Product > Create"; 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)); } return(Json(new { Result = objNotify.RowEffected }, JsonRequestBehavior.AllowGet)); }
public POS_PRODUCT GetById(long?id) { try { _objProductEntity = _objDALProduct.GetById(id); return(_objProductEntity); } catch (Exception ex) { if (ex is DALException) { throw ex; } else { ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error); } throw new BALException(ex.Message.ToString()); } }
// GET: /Product/Edit/5 public ActionResult Edit(long?id) { try { if (Session[SessionVariables.Session_UserInfo] != null) { GetSelectList(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } POS_PRODUCT POS_PRODUCT = _objBALProduct.GetById(id); if (POS_PRODUCT == null) { return(HttpNotFound()); } return(View(POS_PRODUCT)); } else { return(RedirectToAction("Login", "Home")); } } catch (Exception ex) { error.Breadcrum = "Home > POINT OF SALE (POS) > Product > 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 long GetMaxId() { long id = 0; try { _objProductEntity = _dbContext.POS_PRODUCT.OrderByDescending(x => x.TYPE_ID).FirstOrDefault(); if (_objProductEntity.TYPE_ID.ToString() == null) { id = 1; } else { id = _objProductEntity.TYPE_ID + 1; } return(id); } catch (Exception ex) { ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error); throw new DALException(ex.Message.ToString()); } }