public void Add(RequestTest entity) { var sqlquery = @"INSERT INTO CENTRAL_LAB.TBLREQTESTS (REQTESTSID,REQUESTGENID,TESTREQUESTID,REQUESTNAMEID ,TESTID,CONFIRMID,CONFIRM,EXEDATE,EXETIME,EXEMANID ,TESTSTATE,TESTDES,RETESTCOUNT,CONFIRMDATE,CONFIRMTIME ,MACHINID,PRICE,PERSONSHIFT,EXESHIFT) VALUES(:REQTESTSID,:REQUESTGENID,:TESTREQUESTID,:REQUESTNAMEID ,:TESTID,:CONFIRMID,:CONFIRM,:EXEDATE,:EXETIME,:EXEMANID ,:TESTSTATE,:TESTDES,:RETESTCOUNT,:CONFIRMDATE,:CONFIRMTIME ,:MACHINID,:PRICE,:PERSONSHIFT,:EXESHIFT)"; _context.OracleContextConnectionString .Execute(sqlquery, new { entity.ReqTestsId, entity.RequestGenId, entity.TestRequestId, entity.RequestNameId, entity.TestId, entity.ConfirmId, entity.Confirm, entity.ExeDate, entity.ExeTime, entity.ExeManId, entity.TestState, entity.TestDes, entity.ReTestCount, entity.ConfirmDate, entity.ConfirmTime, entity.MachinId, entity.Price, entity.PersonShift, entity.ExeShift, }); }
public void Edit(RequestTest entity, int id) { var sqlquery = @"UPDATE CENTRAL_LAB.TBLREQTESTS SET REQUESTGENID =:REQUESTGENID,TESTREQUESTID = :TESTREQUESTID,REQUESTNAMEID = :REQUESTNAMEID ,TESTID = :TESTID,CONFIRMID = :CONFIRMID,CONFIRM = :CONFIRM,EXEDATE = :EXEDATE,EXETIME = :EXETIME ,EXEMANID = :EXEMANID,TESTSTATE = :TESTSTATE,TESTDES = :TESTDES,RETESTCOUNT = :RETESTCOUNT ,CONFIRMDATE = :CONFIRMDATE,CONFIRMTIME = :CONFIRMTIME,MACHINID = :MACHINID,PRICE = :PRICE ,PERSONSHIFT = :PERSONSHIFT,EXESHIFT = :EXESHIFT WHERE REQTESTSID = :REQTESTSID"; _context.OracleContextConnectionString .Execute(sqlquery, new { ReqTestId = entity.ReqTestsId, entity.RequestGenId, entity.TestRequestId, entity.RequestNameId, entity.TestId, entity.ConfirmId, entity.Confirm, entity.ExeDate, entity.ExeTime, entity.ExeManId, entity.TestState, entity.TestDes, entity.ReTestCount, entity.ConfirmDate, entity.ConfirmTime, entity.MachinId, entity.Price, entity.PersonShift, entity.ExeShift, REQTESTSID = id }); }
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 }); }