public Operation Delete(InvIssueDetail objInvIssueDetail)
        {
            Operation objOperation = new Operation { Success = true, OperationId = objInvIssueDetail.Id };
            _IssueDetailRepository.Delete(objInvIssueDetail);

            try
            {
                _UnitOfWork.Commit();
            }
            catch (Exception)
            {

                objOperation.Success = false;
            }
            return objOperation;
        }
        public Operation Save(InvIssueDetail objInvIssueDetail)
        {
            Operation objOperation = new Operation { Success = true };

            long Id = _IssueDetailRepository.AddEntity(objInvIssueDetail);
            objOperation.OperationId = Id;

            try
            {
                _UnitOfWork.Commit();
            }
            catch (Exception ex)
            {
                objOperation.Success = false;
            }
            return objOperation;
        }
예제 #3
0
        public ActionResult Save(InvIssue iss, List<InvIssueDetail> issDetail)
        {
            int companyId = Convert.ToInt32(Session["companyId"]);
             int userId = Convert.ToInt32(Session["userId"]);
             Operation objOperation = new Operation { Success = false };
             if (ModelState.IsValid && issDetail != null)
             {
                 if (iss.Id == 0)
                 {
                     if ((bool)Session["Add"])
                     {
                         iss.SecCompanyId = companyId;
                         iss.CreatedBy = userId;
                         iss.CreatedDate = DateTime.Now;
                         objOperation = _IssueService.Save(iss);

                         int IssueId = Convert.ToInt32(objOperation.OperationId);

                         foreach (var item in issDetail)
                         {
                             InvIssueDetail objInvIssueDetail = _IssueDetailService.GetById(item.Id);
                             if (objInvIssueDetail != null)
                             {
                                 objInvIssueDetail.InvIssueId = iss.Id;
                                 objInvIssueDetail.SlsProductId = item.SlsProductId;
                                 objInvIssueDetail.RequiredQuantity = item.RequiredQuantity;
                                 objInvIssueDetail.IssuedQuantity = item.IssuedQuantity;
                                 objInvIssueDetail.SlsUnitId = item.SlsUnitId;
                                 _IssueDetailService.Update(objInvIssueDetail);
                             }
                             else
                             {
                                 objInvIssueDetail = new InvIssueDetail();
                                 objInvIssueDetail.InvIssueId = IssueId;
                                 objInvIssueDetail.SlsProductId = item.SlsProductId;
                                 objInvIssueDetail.RequiredQuantity = item.RequiredQuantity;
                                 objInvIssueDetail.IssuedQuantity = item.IssuedQuantity;
                                 objInvIssueDetail.SlsUnitId = item.SlsUnitId;
                                 _IssueDetailService.Save(objInvIssueDetail);
                             }

                         }

                     }

                 }
                 else
                 {
                     if ((bool)Session["Edit"])
                     {
                         iss.SecCompanyId = companyId;
                         iss.ModifiedBy = userId;
                         iss.ModifiedDate = DateTime.Now;
                         objOperation = _IssueService.Update(iss);

                         foreach (var item in issDetail)
                         {
                             InvIssueDetail objInvIssueDetail = _IssueDetailService.GetById(item.Id);
                             if (objInvIssueDetail != null)
                             {
                                 objInvIssueDetail.InvIssueId = iss.Id;
                                 objInvIssueDetail.SlsProductId = item.SlsProductId;
                                 objInvIssueDetail.RequiredQuantity = item.RequiredQuantity;
                                 objInvIssueDetail.IssuedQuantity = item.IssuedQuantity;
                                 objInvIssueDetail.SlsUnitId = item.SlsUnitId;
                                 _IssueDetailService.Update(objInvIssueDetail);
                             }
                             else
                             {
                                 objInvIssueDetail = new InvIssueDetail();
                                 objInvIssueDetail.InvIssueId = iss.Id;
                                 objInvIssueDetail.SlsProductId = item.SlsProductId;
                                 objInvIssueDetail.RequiredQuantity = item.RequiredQuantity;
                                 objInvIssueDetail.IssuedQuantity = item.IssuedQuantity;
                                 objInvIssueDetail.SlsUnitId = item.SlsUnitId;
                                 _IssueDetailService.Save(objInvIssueDetail);
                             }

                         }

                     }

                 }

                 objOperation = _IssueService.Commit();

             }

             return Json(objOperation, JsonRequestBehavior.DenyGet);
        }