Exemple #1
0
        public JsonResult Update([FromBody] AssetTransferHeadersJtableModel obj)
        {
            var msg = new JMessage {
                Error = false, Title = ""
            };

            try
            {
                var data = _context.AssetTransferHeaders.FirstOrDefault(x => x.AssetID == obj.AssetID);
                data.Ticket           = obj.Ticket;
                data.DepartTransf     = obj.DepartTransf;
                data.UserTransf       = obj.UserTransf;
                data.LocationTransf   = obj.LocationTransf;
                data.StartTime        = !string.IsNullOrEmpty(obj.StartTime) ? DateTime.ParseExact(obj.StartTime, "dd/MM/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null;
                data.DepartReceived   = obj.DepartReceived;
                data.UserReceived     = obj.UserReceived;
                data.ReceivedTime     = !string.IsNullOrEmpty(obj.ReceivedTime) ? DateTime.ParseExact(obj.ReceivedTime, "dd/MM/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null;
                data.ReceivedLocation = obj.ReceivedLocation;
                data.Status           = obj.Status;
                data.Note             = obj.Note;
                data.UpdatedTime      = DateTime.Now.Date;
                data.UpdatedBy        = ESEIM.AppContext.UserName;

                _context.AssetTransferHeaders.Update(data);
                _context.SaveChanges();
                msg.Title = "Cập nhật phiếu điều chuyển thành công";
            }
            catch (Exception)
            {
                msg.Error = true;
                msg.Title = "Có lỗi khi cập nhật phiếu điều chuyển";
            }

            return(Json(msg));
        }
Exemple #2
0
        public JsonResult Insert([FromBody] AssetTransferHeadersJtableModel obj)
        {
            var msg = new JMessage {
                Title = "", Error = false
            };

            try
            {
                DateTime?startTime    = !string.IsNullOrEmpty(obj.StartTime) ? DateTime.ParseExact(obj.StartTime, "dd/MM/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null;
                DateTime?receivedTime = !string.IsNullOrEmpty(obj.ReceivedTime) ? DateTime.ParseExact(obj.ReceivedTime, "dd/MM/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null;
                var      data         = _context.AssetTransferHeaders.FirstOrDefault(x => x.Ticketcode == obj.Ticketcode && x.IsDeleted == false);
                if (data == null)
                {
                    var dt = new AssetTransferHeader();
                    dt.Ticketcode       = obj.Ticketcode;
                    dt.Ticket           = obj.Ticket;
                    dt.DepartTransf     = obj.DepartTransf;
                    dt.DepartReceived   = obj.DepartReceived;
                    dt.UserTransf       = obj.UserTransf;
                    dt.UserReceived     = obj.UserReceived;
                    dt.LocationTransf   = obj.LocationTransf;
                    dt.ReceivedLocation = obj.ReceivedLocation;
                    dt.Note             = obj.Note;
                    dt.StartTime        = startTime;
                    dt.ReceivedTime     = receivedTime;
                    dt.CreatedBy        = ESEIM.AppContext.UserName;
                    dt.CreatedTime      = DateTime.Now;
                    dt.Status           = obj.Status;
                    // dt.fullname = obj.fullname;
                    _context.AssetTransferHeaders.Add(dt);
                    _context.SaveChanges();
                    msg.Title = String.Format(CommonUtil.ResourceValue("SUCCESS") /*, CommonUtil.ResourceValue("DCD_MSG_TITLE_DCD")*/);
                }
                else
                {
                    msg.Error = true;
                    msg.Title = String.Format(CommonUtil.ResourceValue("OK"));/*DCD_MSG_DOCUMENT_NOT*/
                }
            }
            catch (Exception)
            {
                msg.Error = true;
                // msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_FAILED")/*, CommonUtil.ResourceValue("DCD_MSG_TITLE_DCD")*/);
                msg.Title = "lỗi";
            }
            return(Json(msg));
        }