protected void BtnIngresarInvent_Click(object sender, EventArgs e) { bool Insertar = true; DateTime StartDate = new DateTime(); DateTime EndDate = new DateTime(); try { StartDate = Convert.ToDateTime(TxtStartDate.Text); } catch { RequiredStartDate.Text = "Formato de fecha incorrecto"; RequiredStartDate.IsValid = false; Insertar = false; } if (!string.IsNullOrWhiteSpace(TxtEndDate.Text)) { try { EndDate = Convert.ToDateTime(TxtEndDate.Text); } catch { ErrorEndDate.Visible = true; ErrorEndDate.Text = "Formato de fecha incorrecto"; Insertar = false; } } if (DDListSucursal.SelectedIndex == 0) { ErrorDDListSucursal.Visible = true; ErrorDDListSucursal.Text = "Debe seleccionar una sucursal"; Insertar = false; } else { } if (Insertar) { //inserta en la tabla de inventarios y redirige a la asignacion de rutas Inventario inventario = new Inventario { Name = TxtNombreInv.Text, Description = TxtDescripInv.Text, DateCreate = DateTime.Now, KOSU = DDListSucursal.SelectedValue, Status = "0", StartTime = StartDate, EndTime = EndDate, }; LogClass logClass = new LogClass(); int IdReturn = logClass.InsertInventario(inventario); if (IdReturn > 0) { TokenClass token = new TokenClass(); Response.Redirect("~/View/Logistica/AdministracionRutas?ID=" + IdReturn + "&TOKEN=" + token.TokenId); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script> $(document).ready(function () {alert('Error al tratar de ingresar el inventario en la base de datos');});</script>", false); } } }