Exemplo n.º 1
0
        private void GetBindingMachine(string mcNo)
        {
            Machine mc = null;

            try
            {
                using (MachineBLL mcBll = new MachineBLL())
                {
                    mc = mcBll.GetMachine(mcNo);
                }

                if (mc != null)
                {
                    this.txtMC_NO.Text             = mc.MC_NO;
                    this.txtMACHINE_NAME.Text      = mc.MACHINE_NAME;
                    this.lueMACHINE_TYPE.EditValue = mc.MACHINE_TYPE;
                    this.txtMACHINE_SIZE.Text      = mc.MACHINE_SIZE;
                    this.txtREMARK.Text            = mc.REMARK;
                    this.icbREC_STAT.EditValue     = mc.REC_STAT;
                }
                else
                {
                    this.ClearDataOnScreen();
                    XtraMessageBox.Show(this, "No Data found.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> DeleteConfirmed(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ResultObject resultObj;

            try
            {
                if (_cache.TryGetValue("CACHE_MASTER_MACHINE", out List <M_Machine> c_lstMac))
                {
                    var m_Machine = c_lstMac.Find(m => m.Id == id);

                    if (m_Machine == null)
                    {
                        return(NotFound());
                    }

                    m_Machine.Updated_By = await base.CurrentUserId();

                    using (var mcBll = new MachineBLL())
                    {
                        resultObj = await mcBll.DeleteMachine(m_Machine);

                        _cache.Remove("CACHE_MASTER_MACHINE");
                    }

                    return(Json(new { success = true, data = (M_Machine)resultObj.ObjectValue, message = "Machine Deleted." }));
                }

                using (var mcBll = new MachineBLL())
                {
                    var lstMc = await mcBll.GetMachine(id);

                    var m_Machine = lstMc.First();

                    if (m_Machine == null)
                    {
                        return(NotFound());
                    }

                    m_Machine.Updated_By = await base.CurrentUserId();

                    resultObj = await mcBll.DeleteMachine(m_Machine);

                    _cache.Remove("CACHE_MASTER_MACHINE");
                }

                return(Json(new { success = true, data = (M_Machine)resultObj.ObjectValue, message = "Machine Deleted." }));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = ex.Message }));
            }
        }
Exemplo n.º 3
0
        // GET: Master/Machine/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ViewBag.CompCode = await base.CurrentUserComp();

            try
            {
                if (_cache.TryGetValue("CACHE_MASTER_MACHINE", out List <M_Machine> c_lstMac))
                {
                    var m_Machine = c_lstMac.Find(m => m.Id == id);

                    if (m_Machine == null)
                    {
                        return(NotFound());
                    }

                    return(PartialView(m_Machine));
                }

                using (var mcBll = new MachineBLL())
                {
                    var lstMc = await mcBll.GetMachine(id);

                    var m_Machine = lstMc.First();

                    if (m_Machine == null)
                    {
                        return(NotFound());
                    }

                    return(PartialView(m_Machine));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(new { success = false, message = ex.Message }));
            }
        }
Exemplo n.º 4
0
        public async Task <IActionResult> GetMachine()
        {
            try
            {
                //var iResult = await base.GetCurUserIdAsync();

                if (_cache.TryGetValue("CACHE_MASTER_MACHINE", out List <M_Machine> c_lstMac))
                {
                    return(Json(new { data = c_lstMac }));
                }

                MemoryCacheEntryOptions options = new MemoryCacheEntryOptions
                {
                    AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(300),
                    SlidingExpiration = TimeSpan.FromSeconds(60),
                    Priority          = CacheItemPriority.NeverRemove
                };

                using (var mcBll = new MachineBLL())
                {
                    var lstMac = await mcBll.GetMachine(null);

                    _cache.Set("CACHE_MASTER_MACHINE", lstMac, options);

                    return(Json(new { data = lstMac }));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(new { success = false, message = ex.Message }));
            }

            //using (var mcBll = new MachineBLL())
            //{
            //    return Json(new { data = await mcBll.GetMachine(null) });
            //}
        }