public ActionResult Post(bool IsNew, Detalle_Facturacion_VendedoresModel varDetalle_Facturacion_Vendedores) { try { if (ModelState.IsValid) { if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IDetalle_Facturacion_VendedoresApiConsumer.SetAuthHeader(_tokenManager.Token); if (varDetalle_Facturacion_Vendedores.Archivo_XMLRemoveAttachment != 0 && varDetalle_Facturacion_Vendedores.Archivo_XMLFile == null) { varDetalle_Facturacion_Vendedores.Archivo_XML = 0; } if (varDetalle_Facturacion_Vendedores.Archivo_XMLFile != null) { var fileAsBytes = HttpPostedFileHelper.GetPostedFileAsBytes(varDetalle_Facturacion_Vendedores.Archivo_XMLFile); _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token); varDetalle_Facturacion_Vendedores.Archivo_XML = (int)_ISpartane_FileApiConsumer.Insert(new Spartane_File() { File = fileAsBytes, Description = varDetalle_Facturacion_Vendedores.Archivo_XMLFile.FileName, File_Size = fileAsBytes.Length }).Resource; } if (varDetalle_Facturacion_Vendedores.Archivo_PDFRemoveAttachment != 0 && varDetalle_Facturacion_Vendedores.Archivo_PDFFile == null) { varDetalle_Facturacion_Vendedores.Archivo_PDF = 0; } if (varDetalle_Facturacion_Vendedores.Archivo_PDFFile != null) { var fileAsBytes = HttpPostedFileHelper.GetPostedFileAsBytes(varDetalle_Facturacion_Vendedores.Archivo_PDFFile); _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token); varDetalle_Facturacion_Vendedores.Archivo_PDF = (int)_ISpartane_FileApiConsumer.Insert(new Spartane_File() { File = fileAsBytes, Description = varDetalle_Facturacion_Vendedores.Archivo_PDFFile.FileName, File_Size = fileAsBytes.Length }).Resource; } var result = ""; var Detalle_Facturacion_VendedoresInfo = new Detalle_Facturacion_Vendedores { Folio = varDetalle_Facturacion_Vendedores.Folio , Fecha_de_Registro = (!String.IsNullOrEmpty(varDetalle_Facturacion_Vendedores.Fecha_de_Registro)) ? DateTime.ParseExact(varDetalle_Facturacion_Vendedores.Fecha_de_Registro, ConfigurationProperty.DateFormat, CultureInfo.InvariantCulture as IFormatProvider) : (DateTime?)null , Folio_Factura = varDetalle_Facturacion_Vendedores.Folio_Factura , Periodo_Facturado = varDetalle_Facturacion_Vendedores.Periodo_Facturado , Cantidad = varDetalle_Facturacion_Vendedores.Cantidad , Archivo_XML = (varDetalle_Facturacion_Vendedores.Archivo_XML.HasValue && varDetalle_Facturacion_Vendedores.Archivo_XML != 0) ? ((int?)Convert.ToInt32(varDetalle_Facturacion_Vendedores.Archivo_XML.Value)) : null , Archivo_PDF = (varDetalle_Facturacion_Vendedores.Archivo_PDF.HasValue && varDetalle_Facturacion_Vendedores.Archivo_PDF != 0) ? ((int?)Convert.ToInt32(varDetalle_Facturacion_Vendedores.Archivo_PDF.Value)) : null , Estatus = varDetalle_Facturacion_Vendedores.Estatus , Fecha_programada_de_Pago = (!String.IsNullOrEmpty(varDetalle_Facturacion_Vendedores.Fecha_programada_de_Pago)) ? DateTime.ParseExact(varDetalle_Facturacion_Vendedores.Fecha_programada_de_Pago, ConfigurationProperty.DateFormat, CultureInfo.InvariantCulture as IFormatProvider) : (DateTime?)null , Pagada = varDetalle_Facturacion_Vendedores.Pagada , Fecha_de_Pago = (!String.IsNullOrEmpty(varDetalle_Facturacion_Vendedores.Fecha_de_Pago)) ? DateTime.ParseExact(varDetalle_Facturacion_Vendedores.Fecha_de_Pago, ConfigurationProperty.DateFormat, CultureInfo.InvariantCulture as IFormatProvider) : (DateTime?)null }; result = !IsNew? _IDetalle_Facturacion_VendedoresApiConsumer.Update(Detalle_Facturacion_VendedoresInfo, null, null).Resource.ToString() : _IDetalle_Facturacion_VendedoresApiConsumer.Insert(Detalle_Facturacion_VendedoresInfo, null, null).Resource.ToString(); return(Json(result, JsonRequestBehavior.AllowGet)); } return(Json(false, JsonRequestBehavior.AllowGet)); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public ActionResult Create(int Id = 0, int consult = 0) { int ModuleId = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0; var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 44588); ViewBag.Permission = permission; var varDetalle_Facturacion_Vendedores = new Detalle_Facturacion_VendedoresModel(); ViewBag.ObjectId = "44588"; ViewBag.Operation = "New"; ViewBag.IsNew = true; if ((Id.GetType() == typeof(string) && Id.ToString() != "") || ((Id.GetType() == typeof(int) || Id.GetType() == typeof(Int16) || Id.GetType() == typeof(Int32) || Id.GetType() == typeof(Int64) || Id.GetType() == typeof(short)) && Id.ToString() != "0")) { ViewBag.IsNew = false; ViewBag.Operation = "Update"; if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IDetalle_Facturacion_VendedoresApiConsumer.SetAuthHeader(_tokenManager.Token); var Detalle_Facturacion_VendedoresData = _IDetalle_Facturacion_VendedoresApiConsumer.GetByKeyComplete(Id).Resource.Detalle_Facturacion_Vendedoress[0]; if (Detalle_Facturacion_VendedoresData == null) { return(HttpNotFound()); } varDetalle_Facturacion_Vendedores = new Detalle_Facturacion_VendedoresModel { Folio = (int)Detalle_Facturacion_VendedoresData.Folio , Fecha_de_Registro = (Detalle_Facturacion_VendedoresData.Fecha_de_Registro == null ? string.Empty : Convert.ToDateTime(Detalle_Facturacion_VendedoresData.Fecha_de_Registro).ToString(ConfigurationProperty.DateFormat)) , Folio_Factura = Detalle_Facturacion_VendedoresData.Folio_Factura , Periodo_Facturado = Detalle_Facturacion_VendedoresData.Periodo_Facturado , Cantidad = Detalle_Facturacion_VendedoresData.Cantidad , Archivo_XML = Detalle_Facturacion_VendedoresData.Archivo_XML , Archivo_PDF = Detalle_Facturacion_VendedoresData.Archivo_PDF , Estatus = Detalle_Facturacion_VendedoresData.Estatus , EstatusDescripcion = CultureHelper.GetTraduction(Convert.ToString(Detalle_Facturacion_VendedoresData.Estatus), "Estatus_Facturas") ?? (string)Detalle_Facturacion_VendedoresData.Estatus_Estatus_Facturas.Descripcion , Fecha_programada_de_Pago = (Detalle_Facturacion_VendedoresData.Fecha_programada_de_Pago == null ? string.Empty : Convert.ToDateTime(Detalle_Facturacion_VendedoresData.Fecha_programada_de_Pago).ToString(ConfigurationProperty.DateFormat)) , Pagada = Detalle_Facturacion_VendedoresData.Pagada.GetValueOrDefault() , Fecha_de_Pago = (Detalle_Facturacion_VendedoresData.Fecha_de_Pago == null ? string.Empty : Convert.ToDateTime(Detalle_Facturacion_VendedoresData.Fecha_de_Pago).ToString(ConfigurationProperty.DateFormat)) }; _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token); ViewBag.Archivo_XMLSpartane_File = _ISpartane_FileApiConsumer.GetByKey(varDetalle_Facturacion_Vendedores.Archivo_XML).Resource; _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token); ViewBag.Archivo_PDFSpartane_File = _ISpartane_FileApiConsumer.GetByKey(varDetalle_Facturacion_Vendedores.Archivo_PDF).Resource; } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IEstatus_FacturasApiConsumer.SetAuthHeader(_tokenManager.Token); var Estatus_Facturass_Estatus = _IEstatus_FacturasApiConsumer.SelAll(true); if (Estatus_Facturass_Estatus != null && Estatus_Facturass_Estatus.Resource != null) { ViewBag.Estatus_Facturass_Estatus = Estatus_Facturass_Estatus.Resource.Where(m => m.Descripcion != null).OrderBy(m => m.Descripcion).Select(m => new SelectListItem { Text = CultureHelper.GetTraduction(Convert.ToString(m.Clave), "Estatus_Facturas", "Descripcion") ?? m.Descripcion.ToString(), Value = Convert.ToString(m.Clave) }).ToList(); } ViewBag.Consult = consult == 1; if (consult == 1) { ViewBag.Operation = "Consult"; } return(View(varDetalle_Facturacion_Vendedores)); }
public ActionResult AddDetalle_Facturacion_Vendedores(int rowIndex = 0, int functionMode = 0, int id = 0) { int ModuleId = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0; ViewBag.currentRowIndex = rowIndex; ViewBag.functionMode = functionMode; ViewBag.Consult = false; var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 44588); ViewBag.Permission = permission; if (!_tokenManager.GenerateToken()) { return(null); } _IDetalle_Facturacion_VendedoresApiConsumer.SetAuthHeader(_tokenManager.Token); Detalle_Facturacion_VendedoresModel varDetalle_Facturacion_Vendedores = new Detalle_Facturacion_VendedoresModel(); if (id.ToString() != "0") { var Detalle_Facturacion_VendedoressData = _IDetalle_Facturacion_VendedoresApiConsumer.ListaSelAll(0, 1000, "Detalle_Facturacion_Vendedores.Folio=" + id, "").Resource.Detalle_Facturacion_Vendedoress; if (Detalle_Facturacion_VendedoressData != null && Detalle_Facturacion_VendedoressData.Count > 0) { var Detalle_Facturacion_VendedoresData = Detalle_Facturacion_VendedoressData.First(); varDetalle_Facturacion_Vendedores = new Detalle_Facturacion_VendedoresModel { Folio = Detalle_Facturacion_VendedoresData.Folio , Fecha_de_Registro = (Detalle_Facturacion_VendedoresData.Fecha_de_Registro == null ? string.Empty : Convert.ToDateTime(Detalle_Facturacion_VendedoresData.Fecha_de_Registro).ToString(ConfigurationProperty.DateFormat)) , Folio_Factura = Detalle_Facturacion_VendedoresData.Folio_Factura , Periodo_Facturado = Detalle_Facturacion_VendedoresData.Periodo_Facturado , Cantidad = Detalle_Facturacion_VendedoresData.Cantidad , Archivo_XML = Detalle_Facturacion_VendedoresData.Archivo_XML , Archivo_PDF = Detalle_Facturacion_VendedoresData.Archivo_PDF , Estatus = Detalle_Facturacion_VendedoresData.Estatus , EstatusDescripcion = CultureHelper.GetTraduction(Convert.ToString(Detalle_Facturacion_VendedoresData.Estatus), "Estatus_Facturas") ?? (string)Detalle_Facturacion_VendedoresData.Estatus_Estatus_Facturas.Descripcion , Fecha_programada_de_Pago = (Detalle_Facturacion_VendedoresData.Fecha_programada_de_Pago == null ? string.Empty : Convert.ToDateTime(Detalle_Facturacion_VendedoresData.Fecha_programada_de_Pago).ToString(ConfigurationProperty.DateFormat)) , Pagada = Detalle_Facturacion_VendedoresData.Pagada.GetValueOrDefault() , Fecha_de_Pago = (Detalle_Facturacion_VendedoresData.Fecha_de_Pago == null ? string.Empty : Convert.ToDateTime(Detalle_Facturacion_VendedoresData.Fecha_de_Pago).ToString(ConfigurationProperty.DateFormat)) }; } _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token); ViewBag.Archivo_XMLSpartane_File = _ISpartane_FileApiConsumer.GetByKey(varDetalle_Facturacion_Vendedores.Archivo_XML).Resource; _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token); ViewBag.Archivo_PDFSpartane_File = _ISpartane_FileApiConsumer.GetByKey(varDetalle_Facturacion_Vendedores.Archivo_PDF).Resource; } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IEstatus_FacturasApiConsumer.SetAuthHeader(_tokenManager.Token); var Estatus_Facturass_Estatus = _IEstatus_FacturasApiConsumer.SelAll(true); if (Estatus_Facturass_Estatus != null && Estatus_Facturass_Estatus.Resource != null) { ViewBag.Estatus_Facturass_Estatus = Estatus_Facturass_Estatus.Resource.Where(m => m.Descripcion != null).OrderBy(m => m.Descripcion).Select(m => new SelectListItem { Text = CultureHelper.GetTraduction(Convert.ToString(m.Clave), "Estatus_Facturas", "Descripcion") ?? m.Descripcion.ToString(), Value = Convert.ToString(m.Clave) }).ToList(); } return(PartialView("AddDetalle_Facturacion_Vendedores", varDetalle_Facturacion_Vendedores)); }