Ejemplo n.º 1
0
        //public long GetMaxId()
        //{
        //    long id = 0;
        //    try
        //    {
        //        _objCashierCounterEntity = _dbContext.POS_CASHIER_COUNTER.OrderByDescending(x => x.USER_ID).FirstOrDefault();
        //        if (_objCashierCounterEntity.USER_ID.ToString() == null)
        //            id = 1;
        //        else
        //            id = _objCashierCounterEntity.USER_ID + 1;

        //        return id;
        //    }
        //    catch (Exception ex)
        //    {
        //        ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
        //        throw new DALException();
        //    }
        //}
        //public string GetMaxCode()
        //{
        //    string code = string.Empty;
        //    int maxCode = 0;
        //    try
        //    {
        //        _objCashierCounterEntity = _dbContext.POS_CASHIER_COUNTER.OrderByDescending(x => x.CODE).FirstOrDefault();
        //        if (_objCashierCounterEntity.CODE.ToString() == null)
        //            code = "0001";
        //        else
        //            maxCode = Formatter.SetValidValueToInt(_objCashierCounterEntity.CODE) + 1;
        //        code = maxCode.ToString().PadLeft(4, '0');

        //        return code;
        //    }
        //    catch (Exception ex)
        //    {
        //        ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
        //        throw new DALException();
        //    }
        //}
        public int Create(POS_CASHIER_COUNTER userModel)
        {
            int rowAffected = 0;
            POS_CASHIER_COUNTER _objCashierCounterEntity = new POS_CASHIER_COUNTER();

            try
            {
                _objCashierCounterEntity.COUNTER_DESC  = userModel.COUNTER_DESC;
                _objCashierCounterEntity.PC_NAME       = userModel.PC_NAME;
                _objCashierCounterEntity.IP_ADDRESS    = userModel.MAC_ADDRESS;
                _objCashierCounterEntity.ISACTIVE_FLAG = userModel.ISACTIVE_FLAG;
                _objCashierCounterEntity.BRANCH_ID     = userModel.BRANCH_ID;
                _objCashierCounterEntity.ISPOSTED_FLAG = false;
                _objCashierCounterEntity.CREATEDBY     = userModel.CREATEDBY;
                _objCashierCounterEntity.CREATEDWHEN   = userModel.CREATEDWHEN;
                _objCashierCounterEntity.MODIFIEDBY    = userModel.MODIFIEDBY;
                _dbContext.POS_CASHIER_COUNTER.Add(_objCashierCounterEntity);
                rowAffected = _dbContext.SaveChanges();

                return(rowAffected);
            }
            catch (Exception ex)
            {
                ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
                throw new DALException("User Info not completed in Data Layer");
            }
        }
Ejemplo n.º 2
0
        public int Update(POS_CASHIER_COUNTER userModel)
        {
            int rowAffected            = 0;
            POS_CASHIER_COUNTER entity = new POS_CASHIER_COUNTER();

            try
            {
                //_dbContext.Entry(userModel).State = System.Data.Entity.EntityState.Modified;
                entity = _dbContext.POS_CASHIER_COUNTER.Find(userModel.COUNTER_ID);

                entity.COUNTER_DESC  = userModel.COUNTER_DESC;
                entity.PC_NAME       = userModel.PC_NAME;
                entity.IP_ADDRESS    = userModel.MAC_ADDRESS;
                entity.ISACTIVE_FLAG = userModel.ISACTIVE_FLAG;
                entity.BRANCH_ID     = userModel.BRANCH_ID;
                entity.ISPOSTED_FLAG = false;
                entity.CREATEDBY     = userModel.CREATEDBY;
                entity.CREATEDWHEN   = userModel.CREATEDWHEN;
                entity.MODIFIEDBY    = userModel.MODIFIEDBY;

                rowAffected = _dbContext.SaveChanges();

                return(rowAffected);
            }
            catch (Exception ex)
            {
                ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
                throw new DALException();
            }
        }
 public Notify Update(POS_CASHIER_COUNTER CompanyModel)
 {
     try
     {
         int rowAffected = _objDALCashierCounter.Update(CompanyModel);
         if (rowAffected > 0)
         {
             objNotify.RowEffected   = 1;
             objNotify.NotifyMessage = "Record Updated Successfully";
         }
         else
         {
             objNotify.RowEffected   = 0;
             objNotify.NotifyMessage = "Company 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());
     }
 }
Ejemplo n.º 4
0
        public ActionResult Create(POS_CASHIER_COUNTER pos_cashiercounter)
        {
            try
            {
                if (Session[SessionVariables.Session_UserInfo] != null)
                {
                    if (ModelState.IsValid)
                    {
                        BranchList();
                        string hostName = Dns.GetHostName(); // Retrive the Name of HOST
                        //// Get the IP
                        string myIP = Dns.GetHostEntry(hostName).AddressList[0].ToString();
                        //string MAC = GetMacAddress().ToString();
                        pos_cashiercounter.PC_NAME     = hostName;
                        pos_cashiercounter.IP_ADDRESS  = myIP;
                        pos_cashiercounter.CREATEDBY   = SessionHandling.UserInformation.USERNAME;
                        pos_cashiercounter.MODIFIEDBY  = SessionHandling.UserInformation.USERNAME;
                        pos_cashiercounter.CREATEDWHEN = DateTime.Now;
                        db.POS_CASHIER_COUNTER.Add(pos_cashiercounter);
                        db.SaveChanges();
                        // objNotify = _objBALCahierCounter.Create(pos_cashiercounter);
                        if (objNotify.RowEffected > 0)
                        {
                            ShowAlert(AlertType.Success, objNotify.NotifyMessage);
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            ShowAlert(AlertType.Error, objNotify.NotifyMessage);
                        }
                    }
                }
                else
                {
                    return(RedirectToAction("Login", "Home"));
                }
            }

            catch (Exception ex)
            {
                error.Breadcrum = "Home > Cashier Counter > List > 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(View(pos_cashiercounter));
        }
Ejemplo n.º 5
0
 public POS_CASHIER_COUNTER GetById(long?id)
 {
     try
     {
         _objCashierCounterEntity = _dbContext.POS_CASHIER_COUNTER.Find(id);
         return(_objCashierCounterEntity);
     }
     catch (Exception ex)
     {
         ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
         throw new DALException();
     }
 }
Ejemplo n.º 6
0
 public ActionResult Edit(POS_CASHIER_COUNTER pos_cashiercounter)
 {
     try
     {
         if (Session[SessionVariables.Session_UserInfo] != null)
         {
             BranchList();
             pos_cashiercounter.MODIFIEDBY   = SessionHandling.UserInformation.USERNAME;
             pos_cashiercounter.MODIFIEDWHEN = DateTime.Now;
             if (ModelState.IsValid)
             {
                 objNotify = _objBALCahierCounter.Update(pos_cashiercounter);
                 if (objNotify.RowEffected > 0)
                 {
                     ShowAlert(AlertType.Success, objNotify.NotifyMessage);
                     return(RedirectToAction("Index"));
                 }
                 else
                 {
                     ShowAlert(AlertType.Error, objNotify.NotifyMessage);
                 }
             }
             else
             {
                 return(View(pos_cashiercounter));
             }
             // }
             return(View(pos_cashiercounter));
         }
         else
         {
             return(RedirectToAction("Login", "Home"));
         }
     }
     catch (Exception ex)
     {
         error.Breadcrum = "Home > Cashier Counter > List  > 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));
     }
 }
Ejemplo n.º 7
0
        public List <POS_CASHIER_COUNTER> List()
        {
            List <POS_CASHIER_COUNTER> lst = new List <POS_CASHIER_COUNTER>();

            try
            {
                //lst = _dbContext.POS_CASHIER_COUNTER.ToList();
                var result = (from ctx in _dbContext.POS_CASHIER_COUNTER
                              join j in _dbContext.POS_CASHIER_COUNTER on ctx.BRANCH_ID equals j.BRANCH_ID
                              select new
                {
                    CounterDesc = ctx.COUNTER_DESC,
                    PCName = ctx.PC_NAME,
                    IPAddress = ctx.IP_ADDRESS,
                    MacAddress = ctx.MAC_ADDRESS,
                    IsActive = ctx.ISACTIVE_FLAG,
                    BranchId = ctx.BRANCH_ID,
                    IsPosted = ctx.ISPOSTED_FLAG,
                    CreatedBy = ctx.CREATEDBY,
                    ModifiedBy = ctx.MODIFIEDBY,
                    CreatedWhen = ctx.CREATEDWHEN,
                    ModifiedWhen = ctx.MODIFIEDWHEN
                }).ToList();
                foreach (var item in result)
                {
                    POS_CASHIER_COUNTER _entity = new POS_CASHIER_COUNTER();
                    _entity.COUNTER_DESC  = item.CounterDesc;
                    _entity.PC_NAME       = item.PCName;
                    _entity.IP_ADDRESS    = item.IPAddress;
                    _entity.MAC_ADDRESS   = item.MacAddress;
                    _entity.ISACTIVE_FLAG = item.IsActive;
                    _entity.BRANCH_ID     = item.BranchId;
                    _entity.ISPOSTED_FLAG = item.IsPosted;
                    _entity.CREATEDBY     = item.CreatedBy;
                    _entity.CREATEDWHEN   = item.CreatedWhen;
                    _entity.MODIFIEDWHEN  = item.ModifiedWhen;
                    lst.Add(_entity);
                }
                return(lst);
            }
            catch (Exception ex)
            {
                ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
                throw new DALException("User Info not completed in Data Layer");
            }
        }
Ejemplo n.º 8
0
        public int Delete(long id)
        {
            int rowAffected = 0;

            try
            {
                _objCashierCounterEntity = _dbContext.POS_CASHIER_COUNTER.Find(id);
                _dbContext.POS_CASHIER_COUNTER.Remove(_objCashierCounterEntity);
                rowAffected = _dbContext.SaveChanges();

                return(rowAffected);
            }
            catch (Exception ex)
            {
                ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
                throw new DALException();
            }
        }
 public POS_CASHIER_COUNTER GetById(long?id)
 {
     try
     {
         _objCashierCounterEntity = _objDALCashierCounter.GetById(id);
         return(_objCashierCounterEntity);
     }
     catch (Exception ex)
     {
         if (ex is DALException)
         {
             throw ex;
         }
         else
         {
             ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
         }
         throw new BALException(ex.Message.ToString());
     }
 }
Ejemplo n.º 10
0
 // GET: /Company/Edit/5
 public ActionResult Edit(long?id)
 {
     try
     {
         if (Session[SessionVariables.Session_UserInfo] != null)
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             POS_CASHIER_COUNTER pos_cashiercounter = _objBALCahierCounter.GetById(id);
             if (pos_cashiercounter == null)
             {
                 return(HttpNotFound());
             }
             BranchList();
             return(View(pos_cashiercounter));
         }
         else
         {
             return(RedirectToAction("Login", "Home"));
         }
     }
     catch (Exception ex)
     {
         error.Breadcrum = "Home > Cashier Counter > List  > 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));
     }
 }