Пример #1
0
        public JsonResult setRegister(string tdoRegisterID, string jobNumber, string dateReceived, string expiryDate, string status, string cargoTypeID, string fileRef,
                                      string destinationID, string terminalID, string containerNo, string returnTerminal, string truckID, string tdoReceiptDate, string schDelDate,
                                      string remarks, string createdByID, string sessionID)
        {
            List <ClsUserDisplay> userDisplay = new List <ClsUserDisplay>();

            using (tdoEntities db = new tdoEntities())
            {
                userDisplay = db.uspGetUserDisplay(GetID()).ToList <ClsUserDisplay>();
            }
            List <string> editableForms = Restriction.GetEditableForms(userDisplay);
            List <string> addableForms  = Restriction.GetAddableForms(userDisplay);

            if (int.Parse(tdoRegisterID) == 0 && !addableForms.Contains("Register"))
            {
                return(Json(new { id = 0, isSuccess = false, msg = "You are not allowed to add new records." }));
            }
            else if (int.Parse(tdoRegisterID) != 0 && !editableForms.Contains("Register"))
            {
                return(Json(new { id = 0, isSuccess = false, msg = "You are not allowed to edit records." }));
            }

            if (tdoRegisterID == "")
            {
                tdoRegisterID = "0";
            }

            Guid Session = new Guid(GetSession()); //do not hard code session ID and createdbyID
            int  _id     = 0;

            try { _id = int.Parse(tdoRegisterID.Trim()); }
            catch { }
            ClsRegister obj = new ClsRegister()
            {
                tdoRegisterID  = _id,
                jobNumber      = jobNumber,
                dateReceived   = StringToArray.ConvertToDate(dateReceived),
                expiryDate     = StringToArray.ConvertToDate(expiryDate),
                status         = status,
                cargoTypeID    = int.Parse(cargoTypeID),
                fileRef        = fileRef,
                destinationID  = int.Parse(destinationID),
                terminalID     = int.Parse(terminalID),
                containerNo    = containerNo,
                returnTerminal = int.Parse(returnTerminal),
                truckID        = int.Parse(truckID),
                tdoReceiptDate = StringToArray.ConvertToDate(tdoReceiptDate),
                schDelDate     = StringToArray.ConvertToDate(schDelDate),
                remarks        = remarks,
                createdByID    = GetID(),
                sessionID      = Session
            };
            ClsReturnValues k = Modules.setRegister(obj);

            return(Json(new { id = k.ID, isSuccess = k.IsSuccess ?? false ? 1 : 0, msg = k.Response }));
        }
Пример #2
0
        public JsonResult setDispatch(string tdoRegisterID, string status, string loadingDate, string loadingTime, string dispatchDate, string dispatchTime, string remarks, string createdByID, string sessionID)
        {
            List <ClsUserDisplay> userDisplay = new List <ClsUserDisplay>();

            using (tdoEntities db = new tdoEntities())
            {
                userDisplay = db.uspGetUserDisplay(GetID()).ToList <ClsUserDisplay>();
            }
            List <string> editableForms = Restriction.GetEditableForms(userDisplay);
            List <string> addableForms  = Restriction.GetAddableForms(userDisplay);

            if (int.Parse(tdoRegisterID) == 0 && !addableForms.Contains("Dispatch"))
            {
                return(Json(new { id = 0, isSuccess = false, msg = "You are not allowed to add new records." }));
            }
            else if (int.Parse(tdoRegisterID) != 0 && !editableForms.Contains("Dispatch"))
            {
                return(Json(new { id = 0, isSuccess = false, msg = "You are not allowed to edit records." }));
            }

            if (tdoRegisterID == "")
            {
                tdoRegisterID = "0";
            }

            Guid Session = new Guid(GetSession()); //do not hard code session ID and createdbyID
            int  _id     = 0;

            try { _id = int.Parse(tdoRegisterID.Trim()); }
            catch { }
            ClsRegister rg = Modules.getRegister(_id).FirstOrDefault();

            //var ldTime = StringToArray.ConvertToDate(loadingDate);
            //var dpTime = StringToArray.ConvertToDate(dispatchDate);
            if (dispatchDate == "")
            {
                dispatchDate = "1900-01-01";
            }
            if (dispatchTime == "")
            {
                dispatchTime = "00:00";
            }
            if (loadingDate == "")
            {
                loadingDate = "1900-01-01";
            }
            if (loadingTime == "")
            {
                loadingTime = "00:00";
            }
            //var ldTime = Convert.ToDateTime(loadingDate+" "+loadingTime);
            //var dpTime = Convert.ToDateTime(dispatchDate+" "+dispatchTime);
            //DateTime dt1 = DateTime.ParseExact(one + " " + two, "dd/MM/yy h:mm:ss tt", CultureInfo.InvariantCulture);
            var         ldTime = DateTime.Parse(loadingDate + " " + loadingTime);
            var         dpTime = DateTime.Parse(dispatchDate + " " + dispatchTime);
            ClsRegister obj    = new ClsRegister()
            {
                tdoRegisterID  = _id,
                jobNumber      = rg.jobNumber,
                dateReceived   = rg.dateReceived,
                expiryDate     = rg.expiryDate,
                status         = status,
                cargoTypeID    = rg.cargoTypeID,
                fileRef        = rg.fileRef,
                destinationID  = rg.destinationID,
                terminalID     = rg.terminalID,
                containerNo    = rg.containerNo,
                returnTerminal = rg.returnTerminal,
                truckID        = rg.truckID,
                tdoReceiptDate = rg.tdoReceiptDate,
                schDelDate     = rg.schDelDate,
                loadingTime    = ldTime,
                dispatchTime   = dpTime,
                remarks        = remarks,
                createdByID    = GetID(),
                sessionID      = Session
            };
            ClsReturnValues k = Modules.setRegister(obj);

            return(Json(new { id = k.ID, isSuccess = k.IsSuccess ?? false ? 1 : 0, msg = k.Response }));
        }