Exemplo n.º 1
0
        public ResultBM UpdateReleaseOrder(ReleaseOrderBM releaseOrderBm)
        {
            try
            {
                ReleaseOrderDetailBLL releaseOrderDetailBll = new ReleaseOrderDetailBLL();
                ResultBM        detailResult    = null;
                ReleaseOrderDAL releaseOrderDal = new ReleaseOrderDAL();
                ReleaseOrderDTO releaseOrderDto = null;
                ResultBM        validResult     = IsValid(releaseOrderBm);

                if (!validResult.IsValid())
                {
                    return(validResult);
                }
                releaseOrderDto = new ReleaseOrderDTO(releaseOrderBm.id, releaseOrderBm.beneficiary.beneficiaryId, releaseOrderBm.Comment, releaseOrderBm.released, releaseOrderBm.received, releaseOrderBm.OrderStatus);
                releaseOrderDal.UpdateReleaseOrder(releaseOrderDto);

                detailResult = releaseOrderDetailBll.UpdateReleaseOrderDetail(releaseOrderBm);
                if (!detailResult.IsValid())
                {
                    return(detailResult);
                }

                return(new ResultBM(ResultBM.Type.OK, "Orden de salida actualizada.", releaseOrderBm));
            }
            catch (Exception exception)
            {
                return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("UPDATING_ERROR") + " " + exception.Message, exception));
            }
        }
Exemplo n.º 2
0
 public ReleaseOrderBM(ReleaseOrderDTO releaseorderDto, BeneficiaryBM beneficiaryBm = null, List<ReleaseOrderDetailBM> releaseOrderDetailBms = null)
 {
     this.id = releaseorderDto.id;
     this.beneficiary = beneficiaryBm;
     this.comment = releaseorderDto.comment;
     this.released = releaseorderDto.released;
     this.received = releaseorderDto.released;
     this.status = releaseorderDto.status;
     this.detail = releaseOrderDetailBms;
 }
Exemplo n.º 3
0
        public bool UpdateReleaseOrder(ReleaseOrderDTO releaseOrderDto)
        {
            DBSql  dbsql = new DBSql();
            String sql;

            sql  = "UPDATE release_order SET ";
            sql += "beneficiaryId = " + releaseOrderDto.beneficiaryId + ", ";
            sql += "comment = '" + releaseOrderDto.comment + "', ";
            sql += "status = '" + releaseOrderDto.status + "' ";
            sql += "WHERE id = " + releaseOrderDto.id;
            dbsql.ExecuteNonQuery(sql);
            return(true);
        }
Exemplo n.º 4
0
        public bool SaveReleaseOrder(ReleaseOrderDTO releaseOrderDto)
        {
            DBSql  dbsql = new DBSql();
            String sql;

            sql  = "INSERT INTO release_order (beneficiaryId, comment, released, received, status) VALUES (";
            sql += releaseOrderDto.beneficiaryId + ", ";
            sql += "'" + releaseOrderDto.comment + "', ";
            sql += "null,";
            sql += "null,";
            sql += "'" + releaseOrderDto.status + "' ";
            sql += ");SELECT @@IDENTITY";
            releaseOrderDto.id = dbsql.ExecuteNonQuery(sql);
            return(true);
        }
Exemplo n.º 5
0
        private ReleaseOrderDTO Resolve(List <String> item)
        {
            ReleaseOrderDTO result = new ReleaseOrderDTO();

            result.id            = int.Parse(item[0]);
            result.beneficiaryId = int.Parse(item[1]);
            result.comment       = item[2];
            if (item[3] != null && item[3].Length > 0)
            {
                result.released = DateTime.Parse(item[3]);
            }
            if (item[4] != null && item[4].Length > 0)
            {
                result.received = DateTime.Parse(item[4]);
            }
            result.status = item[5];
            return(result);
        }
Exemplo n.º 6
0
        public ResultBM GetReleaseOrder(int releaseOrderId)
        {
            try
            {
                BeneficiaryBLL        beneficiaryBll           = new BeneficiaryBLL();
                ResultBM              beneficiaryResult        = null;
                ReleaseOrderDAL       releaseOrderDal          = new ReleaseOrderDAL();
                ReleaseOrderDTO       releaseOrderDto          = releaseOrderDal.GetReleaseOrder(releaseOrderId);
                ReleaseOrderBM        releaseOrderBm           = null;
                ReleaseOrderDetailBLL releaseOrderDetailBll    = new ReleaseOrderDetailBLL();
                ResultBM              releaseOrderDetailResult = null;

                //Si la orden de salida existe, deben existir beneficiario y detalles
                if (releaseOrderDto != null)
                {
                    beneficiaryResult = beneficiaryBll.GetBeneficiary(releaseOrderDto.beneficiaryId);
                    if (!beneficiaryResult.IsValid())
                    {
                        return(beneficiaryResult);
                    }
                    if (beneficiaryResult.GetValue() == null)
                    {
                        throw new Exception(SessionHelper.GetTranslation("RETRIEVING_ERROR") + " beneficiaryId " + releaseOrderDto.beneficiaryId);
                    }

                    releaseOrderDetailResult = releaseOrderDetailBll.GetReleaseOrderDetail(releaseOrderId);
                    if (!releaseOrderDetailResult.IsValid())
                    {
                        return(releaseOrderDetailResult);
                    }
                    if (releaseOrderDetailResult.GetValue() == null)
                    {
                        throw new Exception(SessionHelper.GetTranslation("RETRIEVING_ERROR") + " releaseOrderId " + releaseOrderId);
                    }
                }

                releaseOrderBm = new ReleaseOrderBM(releaseOrderDto, beneficiaryResult.GetValue <BeneficiaryBM>(), releaseOrderDetailResult.GetValue <List <ReleaseOrderDetailBM> >());
                return(new ResultBM(ResultBM.Type.OK, "Operación exitosa.", releaseOrderBm));
            }
            catch (Exception exception)
            {
                return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("RETRIEVING_ERROR") + " " + exception.Message, exception));
            }
        }
Exemplo n.º 7
0
        private List <ReleaseOrderDetailBM> GetDetail(ReleaseOrderDTO releaseOrderDto)
        {
            ResultBM detailResult = new ReleaseOrderDetailBLL().GetReleaseOrderDetail(releaseOrderDto.id);

            return(detailResult.GetValue <List <ReleaseOrderDetailBM> >());
        }
Exemplo n.º 8
0
        //No está bueno esto, pero me permite recuperar los beneficiarios. Poco performante... pero no hay tiempo.
        private BeneficiaryBM GetBeneficiary(ReleaseOrderDTO releaseOrderDto)
        {
            ResultBM beneficiaryResult = new BeneficiaryBLL().GetBeneficiary(releaseOrderDto.beneficiaryId);

            return(beneficiaryResult.GetValue <BeneficiaryBM>());
        }