示例#1
0
        // GET: SampleRequest/Details/By ID
        public ActionResult Details(long id)
        {
            var errorViewModel = new ErrorViewModel();

            try
            {
                var model = _SampleRequestService.BMSUnit.SampleRequestRepository.GetByID(id);
                if (model != null)
                {
                    SampleRequestModel viewModel = new SampleRequestModel
                    {
                        Id           = model.Id,
                        RequestNo    = model.RequestNo,
                        RequestDate  = model.RequestDate,
                        Organization = _SampleRequestService.BMSUnit.SupplierRepository.GetByID(model.SupplierId).SupplierName,
                        SupplierName = _SampleRequestService.BMSUnit.SupplierRepository.GetByID(model.SupplierId).SupplierName,
                        //NET = model.NET,
                        //IsActive = Convert.ToBoolean(model.IsActive)
                    };

                    return(PartialView("_Details", viewModel));
                }
                else
                {
                    errorViewModel.ErrorMessage = CommonMessage.ErrorOccurred;
                    return(PartialView("_ErrorPopUp", errorViewModel));
                }
            }
            catch (Exception ex)
            {
                errorViewModel.ErrorMessage = CommonExceptionMessage.GetExceptionMessage(ex);
                return(PartialView("_ErrorPopUp", errorViewModel));
            }
        }
示例#2
0
        // GET: Invoice/Delete/By ID
        public ActionResult Delete(long id)
        {
            var errorViewModel = new ErrorViewModel();

            try
            {
                var model = _SampleRequestService.BMSUnit.SampleRequestRepository.GetByID(id);

                if (model != null)
                {
                    SampleRequestModel viewModel = new SampleRequestModel
                    {
                        Id          = model.Id,
                        RequestNo   = model.RequestNo,
                        RequestDate = model.RequestDate
                    };

                    return(PartialView("_Delete", viewModel));
                }
                else
                {
                    errorViewModel.ErrorMessage = CommonMessage.ErrorOccurred;
                    return(PartialView("_ErrorPopUp", errorViewModel));
                }
            }
            catch (Exception ex)
            {
                errorViewModel.ErrorMessage = CommonExceptionMessage.GetExceptionMessage(ex);
                return(PartialView("_ErrorPopUp", errorViewModel));
            }
        }
示例#3
0
 public HttpResponseMessage Post([FromBody] SampleRequestModel model)
 {
     return(new HttpResponseMessage
     {
         Content = new ObjectContent(typeof(SampleResponseModel), new SampleResponseModel(), new JsonMediaTypeFormatter()),
         StatusCode = HttpStatusCode.OK
     });
 }
示例#4
0
        // GET: SampleRequest/SearchArticle

        /*
         *          public ActionResult SearchArticle()
         *          {
         *              var errorViewModel = new ErrorViewModel();
         *
         *              try
         *              {
         *
         *                  var articleList = SelectListItemExtension.PopulateDropdownList(_SampleRequestService.BMSUnit.ArticleRepository.GetAll().Where(x=> x.IsActive) .ToList<tblArticle>(), "Id", "ArticleName").ToList();
         *
         *                  var model = new InvoiceDetailModel()
         *                  {
         *                      ddlArticle = articleList
         *                  };
         *
         *                  return PartialView("_SearchArticle", model);
         *              }
         *              catch (Exception ex)
         *              {
         *                  errorViewModel.ErrorMessage = CommonExceptionMessage.GetExceptionMessage(ex);
         *                  return PartialView("_ErrorPopUp", errorViewModel);
         *              }
         *          }
         *
         *          // POST: Invoice/SearchArticle
         *          [HttpPost]
         *          public ActionResult SearchArticle(InvoiceDetailModel viewModel)
         *          {
         *              var strMessage = string.Empty;
         *              try
         *              {
         *                  if (ModelState.IsValid)
         *                  {
         *
         *                      //var entity = viewModel.ToEntity();
         *                      //_invSampleRequestService.BMSUnit.SampleRequestRepository.Add(entity);
         *                      //_invSampleRequestService.BMSUnit.SampleRequestRepository.SaveChanges();
         *
         *                      return Content(Boolean.TrueString);
         *                      //return Content("Information has been saved successfully");
         *                  }
         *
         *                  strMessage = Common.GetModelStateErrorMessage(ModelState);
         *              }
         *              catch (Exception ex)
         *              {
         *                  strMessage = CommonExceptionMessage.GetExceptionMessage(ex, CommonAction.Save);
         *              }
         *
         *              return Content(strMessage);
         *          }
         */

        // GET: SampleRequest/Create
        public ActionResult Create()
        {
            var errorViewModel = new ErrorViewModel();

            try
            {
                var supplierList      = SelectListItemExtension.PopulateDropdownList(_SampleRequestService.BMSUnit.SupplierRepository.GetAll().Where(c => c.IUser.ToUpper() != "SYSTEM").ToList <tblSupplier>(), "Id", "SupplierName", isEdit: true).ToList();
                var organizationList  = SelectListItemExtension.PopulateDropdownList(_SampleRequestService.BMSUnit.OrganizationRepository.GetAll().ToList <tblOrganization>(), "Id", "Organization").ToList();
                var transporterList   = SelectListItemExtension.PopulateDropdownList(_SampleRequestService.BMSUnit.TransporterRepository.GetAll().ToList <tblTransporter>(), "Id", "TransporterName").ToList();
                var deliveryStateList = Common.PopulateDeliveryStateDDList();


                var sampleDocumentModels = _SampleRequestService.BMSUnit.SampleDocumentRequiredRepository.GetAll().ToList().Select(
                    md => new SampleDocumentModel
                {
                    Id         = md.Id,
                    DocName    = md.DocName,
                    IsSelected = md.IsSelected
                }).OrderBy(o => o.DocName).ThenBy(ot => ot.Id);


                //List<SampleDocumentModel> fr = new List<SampleDocumentModel>();
                //fr.Add(new SampleDocumentModel() { Id = 1, DocName = "asdad", IsSelected = true });
                //fr.Add(new SampleDocumentModel() { Id = 2, DocName = "sfsfsfs", IsSelected = false });



                //DocumentList docList = new DocumentList();
                //docList.sampleDocumentModels = fr;

                var userOrganization     = 3; // Query and Set Defaul Organization Here
                var defaultDeliveryState = Common.DeliveryStateEnum.Undelivered;

                var model = new SampleRequestModel()
                {
                    ddlSupplier          = supplierList,
                    RequestDate          = DateTime.Now,
                    ddlOrganization      = organizationList,
                    OrganizationId       = Convert.ToInt64(userOrganization),
                    ddlTransporter       = transporterList,
                    ddlDeliveryState     = deliveryStateList,
                    DeliveryStateId      = Convert.ToInt32(defaultDeliveryState),
                    sampleDocumentModels = sampleDocumentModels.ToList()
                };


                return(PartialView("_Create", model));
            }
            catch (Exception ex)
            {
                errorViewModel.ErrorMessage = CommonExceptionMessage.GetExceptionMessage(ex);
                return(PartialView("_ErrorPopUp", errorViewModel));
            }
        }
示例#5
0
        public JsonResult SetSampleRequestDetailsListForSave(List <SampleRequestDetailViewModel> lstSampleRequestDetails)
        {
            var strMessage = string.Empty;

            // Clear detail list
            Session["lstSampleRequestDetails"] = null;

            try
            {
                List <SampleRequestDetailModel> list = new List <SampleRequestDetailModel>();
                var _SampleRequestModel = new SampleRequestModel();

                // Add new detail information
                foreach (var item in lstSampleRequestDetails)
                {
                    SampleRequestDetailModel entityModel = new SampleRequestDetailModel();

                    entityModel.RequestId        = item.RequestId;
                    entityModel.ProductId        = item.ProductId;
                    entityModel.RequestQuantity  = Convert.ToDecimal(item.RequestQuantity);
                    entityModel.CustomerId       = item.CustomerId;
                    entityModel.Purpose          = item.Purpose;
                    entityModel.ReceivedQuantity = Convert.ToDecimal(item.ReceivedQuantity);
                    entityModel.ReceivedDate     = item.ReceivedDate;
                    entityModel.DetailText       = item.DetailText;
                    list.Add(entityModel);
                }

                Session["lstSampleRequestDetails"] = list;
                return(Json(_SampleRequestModel, JsonRequestBehavior.AllowGet));
                //strMessage = Boolean.TrueString;
            }
            catch (Exception ex)
            {
                strMessage = CommonExceptionMessage.GetExceptionMessage(ex, CommonAction.Save);
            }

            return(Json(new { strMessage = strMessage }));
        }
示例#6
0
        public ActionResult Edit(SampleRequestModel viewModel)
        {
            var strMessage = string.Empty;

            try
            {
                if (ModelState.IsValid)
                {
                    var model = _SampleRequestService.BMSUnit.SampleRequestRepository.GetByID(viewModel.Id);

                    #region Current User

                    viewModel.IUser = model.IUser;
                    viewModel.IDate = model.IDate;

                    var userName = HttpContext.User.Identity.Name;
                    viewModel.EUser = userName;
                    viewModel.EDate = DateTime.Now;

                    #endregion

                    if (viewModel.TransporterId == 0)
                    {
                        viewModel.TransporterId = null;
                    }

                    List <SampleRequestDetailModel> list = new List <SampleRequestDetailModel>();
                    if (Session["lstSampleRequestDetails"] != null)
                    {
                        list = (List <SampleRequestDetailModel>)Session["lstSampleRequestDetails"];
                    }

                    #region Releated Data
                    viewModel.RequestNo = "Test";
                    viewModel.Remarks   = "N/A";
                    //viewModel.testVal1 = _SampleRequestService.Get_New_InvoiceId().FirstOrDefault().testVal1;
                    #endregion

                    var entity = viewModel.ToEntity();

                    // Get previous detail list
                    var lst = _SampleRequestService.BMSUnit.SampleRequestDetailsRepository.GetAll().Where(
                        q => q.RequestId == entity.Id);

                    foreach (var dt in lst)
                    {
                        _SampleRequestService.BMSUnit.SampleRequestDetailsRepository.Delete_64Bit(Convert.ToInt64(dt.Id));
                    }

                    #region Save SampleRequest Detail

                    if (list != null && list.Count > 0)
                    {
                        foreach (SampleRequestDetailModel detail in list)
                        {
                            detail.RequestId = Convert.ToInt64(entity.Id);
                            var detailEntity = detail.ToEntity();
                            _SampleRequestService.BMSUnit.SampleRequestDetailsRepository.Add(detailEntity);
                            _SampleRequestService.BMSUnit.SampleRequestDetailsRepository.SaveChanges();
                        }
                    }
                    #endregion

                    _SampleRequestService.BMSUnit.SampleRequestRepository.Update(entity);
                    _SampleRequestService.BMSUnit.SampleRequestRepository.SaveChanges();

                    Session["lstSampleRequestDetails"] = null;



                    #region Save Sample Request Document

                    var sampleDocEntity = viewModel.ToEntity();
                    var docList         = _SampleRequestService.BMSUnit.SampleRequestDocumentRepository.GetAll().Where(
                        q => q.RequestId == sampleDocEntity.Id);

                    foreach (var dt in docList)
                    {
                        _SampleRequestService.BMSUnit.SampleRequestDocumentRepository.Delete_64Bit(Convert.ToInt64(dt.Id));
                    }



                    foreach (SampleDocumentModel doc in viewModel.sampleDocumentModels)
                    {
                        if (doc.IsSelected == true)
                        {
                            SampleRequestDocumentModel aaa = new SampleRequestDocumentModel();
                            aaa.RequestId  = Convert.ToInt64(entity.Id);
                            aaa.DocumentId = doc.Id;
                            var detailDocumentEntity = aaa.ToEntity();
                            _SampleRequestService.BMSUnit.SampleRequestDocumentRepository.Add(detailDocumentEntity);
                            _SampleRequestService.BMSUnit.SampleRequestDocumentRepository.SaveChanges();
                        }
                    }
                    #endregion

                    return(Content(Boolean.TrueString));
                }

                strMessage = Common.GetModelStateErrorMessage(ModelState);
            }
            catch (Exception ex)
            {
                strMessage = CommonExceptionMessage.GetExceptionMessage(ex, CommonAction.Update);
            }

            return(Content(strMessage));
        }
示例#7
0
        // GET: Invoice/Edit/By ID
        public ActionResult Edit(long id)
        {
            var errorViewModel = new ErrorViewModel();

            try
            {
                var model = _SampleRequestService.BMSUnit.SampleRequestRepository.GetByID(id);

                Session["SampleRequestId"] = model.Id;

                var supplierList      = SelectListItemExtension.PopulateDropdownList(_SampleRequestService.BMSUnit.SupplierRepository.GetAll().Where(c => c.IUser.ToUpper() != "SYSTEM").ToList <tblSupplier>(), "Id", "SupplierName").ToList();
                var organizationList  = SelectListItemExtension.PopulateDropdownList(_SampleRequestService.BMSUnit.OrganizationRepository.GetAll().ToList <tblOrganization>(), "Id", "Organization").ToList();
                var transporterList   = SelectListItemExtension.PopulateDropdownList(_SampleRequestService.BMSUnit.TransporterRepository.GetAll().ToList <tblTransporter>(), "Id", "TransporterName").ToList();
                var deliveryStateList = Common.PopulateDeliveryStateDDList();

                var defaultDeliveryState = Common.DeliveryStateEnum.Undelivered;

                var sampleDocumentModels = _SampleRequestService.BMSUnit.SampleDocumentRequiredRepository.GetAll().ToList().Select(
                    md => new SampleDocumentModel
                {
                    Id         = md.Id,
                    DocName    = md.DocName,
                    IsSelected = _SampleRequestService.BMSUnit.SampleRequestDocumentRepository.GetAll().ToList().Where(x => x.RequestId == model.Id && x.DocumentId == md.Id).Count() > 0 ? true:false

                                 //md.IsSelected
                }).OrderBy(o => o.DocName).ThenBy(ot => ot.Id);


                if (model != null)
                {
                    SampleRequestModel viewModel = new SampleRequestModel
                    {
                        Id              = Convert.ToInt64(model.Id),
                        RequestNo       = model.RequestNo,
                        RequestDate     = model.RequestDate,
                        ddlOrganization = organizationList,
                        //Organization = _SampleRequestService.BMSUnit.OrganizationRepository.GetByID(model.OrganizationId).Organization,
                        OrganizationId   = Convert.ToInt64(model.OrganizationId),
                        ddlSupplier      = supplierList,
                        SupplierId       = model.SupplierId,
                        SupplierAddress  = _SampleRequestService.BMSUnit.SupplierRepository.GetByID(model.SupplierId).Address,
                        ddlTransporter   = transporterList,
                        TransporterId    = Convert.ToInt32(model.TransporterId),
                        DocTrackingNo    = model.DocTrackingNo,
                        ddlDeliveryState = deliveryStateList,
                        //DeliveryStateId = (int)model.DeliveryStateId,
                        DeliveryStateId      = model.DeliveryStateId != null ? (int)model.DeliveryStateId : Convert.ToInt32(defaultDeliveryState),
                        sampleDocumentModels = sampleDocumentModels.ToList()
                                               //(int)Common.DeliveryStateEnum.Undelivered
                                               //DeliveryState = Enum.GetName(typeof(Common.DeliveryStateEnum), (int)model.DeliveryStateId)
                                               //,IsActive = Convert.ToBoolean(model.IsActive)
                    };

                    return(PartialView("_Edit", viewModel));
                }
                else
                {
                    errorViewModel.ErrorMessage = CommonMessage.ErrorOccurred;
                    return(PartialView("_ErrorPopUp", errorViewModel));
                }
            }
            catch (Exception ex)
            {
                errorViewModel.ErrorMessage = CommonExceptionMessage.GetExceptionMessage(ex);
                return(PartialView("_ErrorPopUp", errorViewModel));
            }
        }
示例#8
0
        public ActionResult Create(SampleRequestModel viewModel)
        {
            var strMessage = string.Empty;

            try
            {
                if (Session["lstSampleRequestDetails"] != null)
                {
                    if (ModelState.IsValid)
                    {
                        #region Current User
                        var userName = HttpContext.User.Identity.Name;
                        viewModel.IUser = userName;
                        viewModel.IDate = DateTime.Now;
                        viewModel.EDate = DateTime.Now;
                        #endregion

                        #region Releated Data
                        viewModel.RequestNo = "Test";
                        viewModel.Remarks   = "N/A";

                        if (viewModel.TransporterId == 0)
                        {
                            viewModel.TransporterId = null;
                        }
                        #endregion

                        List <SampleRequestDetailModel> list = new List <SampleRequestDetailModel>();
                        if (Session["lstSampleRequestDetails"] != null)
                        {
                            list = (List <SampleRequestDetailModel>)Session["lstSampleRequestDetails"];
                        }

                        var entity = viewModel.ToEntity();

                        _SampleRequestService.BMSUnit.SampleRequestRepository.Add(entity);
                        _SampleRequestService.BMSUnit.SampleRequestRepository.SaveChanges();

                        Session["SampleRequestMasterId"] = entity.Id;

                        #region Save SampleRequest Detail

                        if (list != null && list.Count > 0)
                        {
                            foreach (SampleRequestDetailModel detail in list)
                            {
                                detail.RequestId = Convert.ToInt64(entity.Id);
                                var detailEntity = detail.ToEntity();
                                _SampleRequestService.BMSUnit.SampleRequestDetailsRepository.Add(detailEntity);
                                _SampleRequestService.BMSUnit.SampleRequestDetailsRepository.SaveChanges();
                            }
                        }

                        Session["lstSampleRequestDetails"] = null;

                        #endregion

                        #region Save Sample Request Document


                        foreach (SampleDocumentModel doc in viewModel.sampleDocumentModels)
                        {
                            if (doc.IsSelected == true)
                            {
                                SampleRequestDocumentModel aaa = new SampleRequestDocumentModel();
                                aaa.RequestId  = Convert.ToInt64(entity.Id);
                                aaa.DocumentId = doc.Id;
                                var detailDocumentEntity = aaa.ToEntity();
                                _SampleRequestService.BMSUnit.SampleRequestDocumentRepository.Add(detailDocumentEntity);
                                _SampleRequestService.BMSUnit.SampleRequestDocumentRepository.SaveChanges();
                            }
                        }

                        #endregion

                        return(Content(Boolean.TrueString));
                    }
                }
                strMessage = Common.GetModelStateErrorMessage(ModelState);
            }
            catch (Exception ex)
            {
                strMessage = CommonExceptionMessage.GetExceptionMessage(ex, CommonAction.Save);
            }

            return(Content(strMessage));
        }
 public static tblSampleRequest ToEntity(this SampleRequestModel model)
 {
     return(Mapper.Map <SampleRequestModel, tblSampleRequest>(model));
 }