예제 #1
0
 public void Add(TestRequest model)
 {
     var sqlquery = @"INSERT INTO TBLTESTREQUEST
         (TESTREQUESTID,REQUESTNO,REQDATE,STARTDATE,
         ENDDATE,APPLICANTID,REQTYPE,CREATEID,CONFIRMID,
         CONFIRM,ENABLE,SAMPLENAME,CONTRACT,COM_ID)
          VALUES(:TESTREQUESTID,:REQUESTNO,:REQDATE,
         :STARTDATE,:ENDDATE,:APPLICANTID,:REQTYPE,
         :CREATEID,:CONFIRMID,:CONFIRM,:ENABLE,
         :SAMPLENAME,:CONTRACT,:COM_ID)";
     _context.OracleContextConnectionString
         .Execute(sqlquery,
         new
         {
             model.TestRequestId,
             model.RequestNo,
             model.ReqDate,
             model.StartDate,
             model.EndDate,
             model.ApplicantId,
             model.ReqType,
             model.CreateId,
             model.ConfirmId,
             model.Confirm,
             model.Enable,
             model.SampleName,
             model.Contract,
             model.Com_Id
         });
 }
예제 #2
0
 public void Edit(int id, TestRequest model)
 {
     var sqlquery = @"UPDATE TBLTESTREQUEST SET
                     TESTREQUESTID= :TESTREQUESTID ,REQUESTNO = :REQUESTNO,
                     REQDATE =: REQDATE,STARTDATE = :STARTDATE,
                     ENDDATE =:ENDDATE,APPLICANTID =:APPLICANTID,
                     REQTYPE =:REQTYPE,CREATEID =:CREATEID,CONFIRMID = :CONFIRMID,
                     CONFIRM =:CONFIRM,ENABLE = :ENABLE,
                     SAMPLENAME = :SAMPLENAME,CONTRACT= :CONTRACT
                     WHERE TESTREQUESTID=:TESTREQUESTID";
     _context.OracleContextConnectionString
         .Execute(sqlquery,
         new
         {
             model.TestRequestId,
             model.RequestNo,
             model.ReqDate,
             model.StartDate,
             model.EndDate,
             model.ApplicantId,
             model.ReqType,
             model.CreateId,
             model.ConfirmId,
             model.Confirm,
             model.Enable,
             model.SampleName,
             model.Contract,
             TESTREQUESTID = id
         });
 }
예제 #3
0
        public ActionResult TestRequestAdd(TestRequestViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Companies = new SelectList(_testrequestrepository.GetAllCompanies(
                    _userrepository.GetUser(User.Identity.Name, int.Parse(CookieEncryptor.Decrypt(Request.Cookies["LabRequest-Cookie"].Value))).PersonId),
                 "IdRec", "Des", int.Parse(model.Company));
                ViewBag.Units = new SelectList(new List<string>(), "ApplicantId", "ApplicantName");
                ViewBag.RequestTitles = new SelectList(new List<string>(), "IdRec", "Des");
                return View(model);
            }

            if (model.RequestDetail == null)
            {
                ModelState.AddModelError("", "حداقل یک عنوان درخواست از جزئیات میبایست وارد شود");
                ViewBag.Companies = new SelectList(_testrequestrepository.GetAllCompanies(
                    _userrepository.GetUser(User.Identity.Name,
                    int.Parse(CookieEncryptor.Decrypt(Request.Cookies["LabRequest-Cookie"].Value))).PersonId),
                 "IdRec", "Des", int.Parse(model.Company));
                ViewBag.Units = new SelectList(new List<string>(), "ApplicantId", "ApplicantName");
                ViewBag.RequestTitles = new SelectList(new List<string>(), "IdRec", "Des");
                return View(model);
            }

            var user = _userrepository.GetUser(User.Identity.Name,
                int.Parse(CookieEncryptor.Decrypt(Request.Cookies["LabRequest-Cookie"].Value)));

            var testreq = new TestRequest
            {
                TestRequestId = _testrequestrepository.MaxTextRequestId,
                RequestNo = _testrequestrepository.RequestNewCode(model.RequestType),
                ReqDate = model.RequestDate,
                StartDate = model.RequestDate,
                EndDate = model.RequestDate,
                ApplicantId = int.Parse(model.Unit),
                ReqType = 1,
                CreateId = user.PersonId,
                ConfirmId = 0,
                Confirm = "N",
                Enable = false,
                SampleName = model.SampleName,
                Contract = _testrequestrepository.RequestNewCode(model.RequestType),
                Com_Id = user.Com_Id
            };
            _testrequestrepository.Add(testreq);

            var testreqgen = new TestRequestGenerate
            {
                RequestgenId = _testrequestgenrepository.MaxRequestGenId,
                TestRequestId = testreq.TestRequestId,
                PCode = testreq.RequestNo,
                PCodeDate = model.RequestDate,
                PCodeTime = _datetimerepository.GetShortLocalTime,
                RequestDate = model.RequestDate,
                RequestTime = _datetimerepository.GetShortLocalTime,
                UnitSendDate = model.RequestDate,
                UnitSendTime = _datetimerepository.GetShortLocalTime,
                UnitSendConfirm = 1,
                UnitNotSendDes = string.Empty,
                TestType = 1,
                UnitControl = 0,
                RequestType = (int)model.RequestType,
                CreateId = testreq.CreateId,
                ConfirmId = 0,
                Confirm = (int)model.RequestPriority,
                Status = 0,
                TestCount = 0,
                RequestFinish = 0,
                TestExe = 0,
                TestReject = 0,
                ReceiveDate = string.Empty,
                ReceiveTime = string.Empty,
                Shift = _testrequestgenrepository
                    .GetCurrentShift(_datetimerepository.GetLongLocalTime
                        , _datetimerepository.GetLocalDate),
                SampleNo = string.Empty,
                VeselNo = string.Empty,
                LatNo = model.LotNumber,
                SampleMan = model.SampleName
            };
            _testrequestgenrepository.Add(testreqgen);

            foreach (var t in model.RequestDetail)
            {
                var reqtest = new RequestTest
                {
                    ReqTestsId = _requesttestrepository.Max,
                    RequestGenId = testreqgen.RequestgenId,
                    TestRequestId = testreq.TestRequestId,
                    RequestNameId = int.Parse(model.RequestTitle),
                    TestId = int.Parse(t),
                    ConfirmId = 0,
                    Confirm = 0,
                    ExeDate = string.Empty,
                    ExeTime = string.Empty,
                    ExeManId = 0,
                    TestState = 0,
                    TestDes = string.Empty,
                    ReTestCount = 0,
                    ConfirmDate = string.Empty,
                    ConfirmTime = string.Empty,
                    MachinId = 0,
                    Price = _testrepository.GetPrice(int.Parse(t)).Price,
                    PersonShift = 0,
                    ExeShift = 0
                };
                _requesttestrepository.Add(reqtest);
            }

            return RedirectToAction("TestRequestResult", new { reqno = testreq.RequestNo });
        }