public List <BE_Schedule> GetScheduleGeneral(BE_Schedule bE_Schedule) { try { BE_Schedule _bE_Schedule = null; List <BE_Schedule> _lstSchedule = new List <BE_Schedule>(); Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("_InvoiceId", (string.IsNullOrWhiteSpace(bE_Schedule.Invoice.invoiceId)) ? DBNull.Value : (object)bE_Schedule.Invoice.invoiceId); // parameters.Add("_StartDate", bE_Schedule.StartDate); //parameters.Add("_EndDate", bE_Schedule.EndDate); //parameters.Add("_Delivery", bE_Schedule.Delivery); //parameters.Add("_PaymentMethod", (bE_Schedule.PaymentMethod == 0) ? DBNull.Value : (object)bE_Schedule.PaymentMethod); DA_Invoice InvoiceDA = new DA_Invoice(this._database); var rows = _database.QuerySP("sp_getScheduleGeneral", parameters); foreach (var row in rows) { BE_Schedule _temp = new BE_Schedule(); // _temp.Invoice = InvoiceDA.getInvoiceGeneral(new Pago.BE.n.Filters.BEInvoiceFilter() { invoiceId = bE_Schedule.Invoice.invoiceId })[0]; //InvoiceDA.getInvoiceGeneral(new Pago.BE.n.Filters.BEInvoiceFilter() { invoiceId = (bE_Schedule.Invoice.invoiceId) }); _temp.StartDate = (row["StartDate"] == null) ? null : _bE_Schedule.StartDate; _temp.StartDate = (row["StartDate"] == null) ? null : _bE_Schedule.StartDate; _temp.EndDate = (row["EndDate"] == null) ? null : _bE_Schedule.EndDate; _temp.Delivery = (row["Delivery"] == null) ? null : _bE_Schedule.Delivery; _temp.PaymentMethod = (row["PaymentMethod"] == null) ? 0 : int.Parse(row["PaymentMethod"].ToString()); _lstSchedule.Add(_temp); } return(_lstSchedule); } catch (Exception ex) { throw ex; } }
public VE_Invoice CreateInvoice(VE_Invoice _VeInvoice) { string invoiceId; _database = new MySQLDatabase(connectionString); var companysSystem = (new BL_Company() { connectionString = connectionString }).GetCompanyGeneral(new BECompanyFilter() { companyCode = _VeInvoice.companyCode }); BE_Company _companySystem = null; if (companysSystem.Count > 0) { _companySystem = companysSystem[0]; } else { throw new Exception("codigo Invalido"); } if (_VeInvoice.invoiceType.Equals("O") && _companySystem.companyType.Equals("3"))// del sistema { var companysEmisor = (new BL_Company() { connectionString = connectionString }).GetCompanyGeneral(new BECompanyFilter() { companyRUC = _VeInvoice.customerRuc }); BE_Company _companyEmisor = null; if (companysEmisor.Count > 0) { _companyEmisor = companysEmisor[0]; } else { throw new Exception("codigo Invalido"); } _VeInvoice.companyCode = _companyEmisor.companyCode; _VeInvoice.customerRuc = _companySystem.companyRUC; _VeInvoice.customerName = _companySystem.companyName; } if (_VeInvoice.documentId != null) { var numbers = _VeInvoice.documentId.Split('-'); if (numbers.Count() < 2) { throw new Exception("Ingrese una factura válida"); } _VeInvoice.nroSerie = numbers[0]; _VeInvoice.nroComprobante = numbers[1]; } invoiceId = new DA_Invoice(_database).createInvoice(_VeInvoice).invoiceId; foreach (VE_InvoiceDetail _veInvoiceDetail in _VeInvoice.invoiceDetail) { _veInvoiceDetail.invoiceId = int.Parse(invoiceId); new DA_Invoice(_database).createInvoiceDetail(_veInvoiceDetail); } return(_VeInvoice); }
/* * public VE_Invoice updateInvoiceGeneral(VE_Invoice _vE_Invoice) * { * _database = new MySQLDatabase(connectionString); * return new DA_Invoice(_database).updateInvoiceGeneral(_vE_Invoice); * }*/ public VE_Invoice updateInvoiceGeneral(VE_Invoice _VeInvoice) { _database = new MySQLDatabase(connectionString); BL_Option bL_Option = new BL_Option(this.connectionString); //bL_Option.connectionString = connectionString; var ok = bL_Option.ValidateOption(9, _VeInvoice.userName); if (ok == 0) { throw new ApplicationException("Ud. no cuenta con los permisos necesarios"); } if (_VeInvoice.documentId != null) { var numbers = _VeInvoice.documentId.Split('-'); if (numbers.Count() < 2) { throw new ApplicationException("Ingrese una factura válida"); } _VeInvoice.nroSerie = numbers[0]; _VeInvoice.nroComprobante = numbers[1]; } new DA_Invoice(_database).updateInvoiceGeneral(_VeInvoice); var invoice = new DA_Invoice(_database).getInvoiceGeneral(new BEInvoiceFilter { invoiceIdList = _VeInvoice.invoiceId }); if (_VeInvoice.invoiceStatusId != invoice[0].invoiceStatusId) { BL_WorkFlow _blWorkFlow = new BL_WorkFlow(); _blWorkFlow.connectionString = connectionString; var mensaje = ""; bool bOk = false; if (_VeInvoice.invoiceStatusId == 2) { bOk = _blWorkFlow.NextWorkFlowStep(ref mensaje, 9, int.Parse(_VeInvoice.invoiceId), _VeInvoice.userName, false); } else { bOk = _blWorkFlow.NextWorkFlowStep(ref mensaje, 1, int.Parse(_VeInvoice.invoiceId), _VeInvoice.userName, false); } if (!bOk) { throw new ApplicationException(mensaje); } } new DA_Invoice(_database).DeleteInvoiceDetailByInvoiceId(_VeInvoice.invoiceId); if (_VeInvoice.invoiceDetail != null) { foreach (VE_InvoiceDetail _veInvoiceDetail in _VeInvoice.invoiceDetail) { _veInvoiceDetail.invoiceId = int.Parse(_VeInvoice.invoiceId); new DA_Invoice(_database).createInvoiceDetail(_veInvoiceDetail); } } return(_VeInvoice); }
public VE_Invoice CreateInvoiceGeneral(VE_Invoice _VeInvoice) { string invoiceId; _database = new MySQLDatabase(connectionString); var companysSystem = (new BL_Company() { connectionString = connectionString }).GetCompanyGeneral(new BECompanyFilter() { companyCode = _VeInvoice.companyCode }); BE_Company _companySystem = null; if (companysSystem.Count > 0) { _companySystem = companysSystem[0]; } else { throw new Exception("codigo Invalido"); } if ((_VeInvoice.invoiceType.Equals(BE_Invoice.ORDER) || _VeInvoice.invoiceType.Equals(BE_Invoice.PURCHASEORDER)) && _companySystem.companyType.Equals("3")) // del sistema { var companysEmisor = (new BL_Company() { connectionString = connectionString }).GetCompanyGeneral(new BECompanyFilter() { companyRUC = _VeInvoice.customerRuc }); BE_Company _companyEmisor = null; if (companysEmisor.Count > 0) { _companyEmisor = companysEmisor[0]; } else { throw new Exception("codigo Invalido"); } _VeInvoice.companyCode = _companyEmisor.companyCode; _VeInvoice.customerRuc = _companySystem.companyRUC; _VeInvoice.customerName = _companySystem.companyName; } invoiceId = new DA_Invoice(_database).createInvoice(_VeInvoice).invoiceId; foreach (VE_InvoiceDetail _veInvoiceDetail in _VeInvoice.invoiceDetail) { _veInvoiceDetail.invoiceId = int.Parse(invoiceId); new DA_Invoice(_database).createInvoiceDetail(_veInvoiceDetail); } return(_VeInvoice); }